sonic-radiance/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charwidget.lua

54 lines
1.8 KiB
Lua
Raw Normal View History

local baseWidget = require "game.modules.menus.parents.widget"
local CharacterWidget = baseWidget:extend()
local ComplexHPBar = require "game.modules.gui.complexhpbar"
local Emblem = require "game.modules.gui.emblem"
-- Hero custom widget
--
function CharacterWidget:new(scene, name)
self.charName = name
self.emblem = Emblem(game.characters.list[name], scene)
self.font2 = scene.assets.fonts["hudnbrs_small"]
CharacterWidget.super.new(self, scene, "character")
self.hpbar = ComplexHPBar(88)
self.ppbar = ComplexHPBar(88)
self.hpbar:setColorForeground(248 / 255, 160 / 255, 0, 1)
self.hpbar:setColorBackground(112 / 255, 0, 0)
self.ppbar:setColorForeground(0, 248 / 255, 248 / 255, 1)
self.ppbar:setColorBackground(0, 54 / 255, 229 / 255)
end
function CharacterWidget:drawCanvas()
local character = game.characters.list[self.charName]
self.font:setFilter("shadow")
local debut = 0
local xDebut = 32
self.font:draw(character.fullname, xDebut, debut, -1, "left")
local yLvl = debut + 16
local xLvl = xDebut
self.scene.assets.images["lvl"]:draw(xLvl, yLvl)
self.scene.assets.images["exp"]:draw(xLvl, yLvl + 10)
self.font2:print(character.level, xLvl + 19, yLvl, "left")
local expString = character.exp .. "/" .. character.exp_next
self.font2:print(expString, xLvl + 19, yLvl + 10, "left")
end
function CharacterWidget:draw(x, y)
local character = game.characters.list[self.charName]
self.emblem:draw(x, y + 6)
local xDebut = x + 52
local yDebut = y + 15
self.scene.assets.fonts["hudnbrs_small"]:set()
self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, character.stats.hpmax)
self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, character.stats.ppmax)
if self.canvas.texture ~= nil then
love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy)
end
end
return CharacterWidget