chore: extract character menu and widgets
This commit is contained in:
parent
f72c416f57
commit
a95c562a7f
3 changed files with 69 additions and 58 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
local baseMenu = require "game.modules.menus.parents.menu"
|
||||||
|
local CharacterMenu = baseMenu:extend()
|
||||||
|
|
||||||
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
||||||
|
|
||||||
|
function CharacterMenu:new(scene)
|
||||||
|
local x = const.X + 136
|
||||||
|
local w = const.WIDTH - x + 28
|
||||||
|
CharacterMenu.super.new(self, scene, "character", x, const.Y, w, const.HEIGHT, 4)
|
||||||
|
end
|
||||||
|
|
||||||
|
return CharacterMenu
|
|
@ -0,0 +1,53 @@
|
||||||
|
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
|
|
@ -1,16 +1,12 @@
|
||||||
local ParentScreen = require "scenes.overworld.screens.parent"
|
local ParentScreen = require "scenes.overworld.screens.parent"
|
||||||
local PauseScreen = ParentScreen:extend()
|
local PauseScreen = ParentScreen:extend()
|
||||||
|
|
||||||
local ComplexHPBar = require "game.modules.gui.complexhpbar"
|
|
||||||
|
|
||||||
local Emblem = require "game.modules.gui.emblem"
|
|
||||||
|
|
||||||
local menu = require "game.modules.menus.fancy"
|
local menu = require "game.modules.menus.fancy"
|
||||||
local baseMenu = require "game.modules.menus.parents.menu"
|
|
||||||
local baseWidget = require "game.modules.menus.parents.widget"
|
|
||||||
|
|
||||||
local CharacterMenu = baseMenu:extend()
|
local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu"
|
||||||
local CharacterWidget = baseWidget:extend()
|
local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget"
|
||||||
|
local CharacterMenu = baseCharacterMenu:extend()
|
||||||
|
local CharacterWidget = baseCharacterWidget:extend()
|
||||||
|
|
||||||
local TeamWidget = menu.BaseWidget:extend()
|
local TeamWidget = menu.BaseWidget:extend()
|
||||||
local ViewWidget = menu.BaseWidget:extend()
|
local ViewWidget = menu.BaseWidget:extend()
|
||||||
|
@ -61,62 +57,12 @@ function PauseScreen:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Character menu
|
-- Character menu
|
||||||
function CharacterMenu:new(scene)
|
|
||||||
local x = const.X + 136
|
|
||||||
local w = const.WIDTH - x + 28
|
|
||||||
CharacterMenu.super.new(self, scene, "character", x, const.Y, w, const.HEIGHT, 4)
|
|
||||||
end
|
|
||||||
|
|
||||||
function CharacterMenu:cancelAction()
|
function CharacterMenu:cancelAction()
|
||||||
self.scene.menusystem:switchMenu("main")
|
self.scene.menusystem:switchMenu("main")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hero custom widget
|
-- 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
|
|
||||||
|
|
||||||
function CharacterWidget:action()
|
function CharacterWidget:action()
|
||||||
self.scene.screens.mainmenu.character(self.scene, self.charName)
|
self.scene.screens.mainmenu.character(self.scene, self.charName)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue