e5d8a7f874
Fixes #61 Fixes #62
68 lines
2 KiB
Lua
68 lines
2 KiB
Lua
local PageParent = require "scenes.overworld.screens.mainmenu.character.pageparent"
|
|
local StatPage = PageParent:extend()
|
|
|
|
local menu = require "game.modules.menus.list"
|
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
|
|
|
local SkillMenu = menu.ListMenu:extend()
|
|
local SkillWidget = menu.DualTextWidget:extend()
|
|
local PLAYER_MESSAGE = 240 - 24
|
|
|
|
function StatPage:new(view, character)
|
|
StatPage.super.new(self, view, character, {"See skill"})
|
|
self.message = ""
|
|
end
|
|
|
|
function StatPage:getCustomMenus()
|
|
return SkillMenu(self, self.character)
|
|
end
|
|
|
|
function StatPage:menuResponses(i)
|
|
if (#self.character.skills > 0) then
|
|
self.view.scene.menusystem:switchMenu("equip")
|
|
end
|
|
end
|
|
|
|
function StatPage:drawOverEverything()
|
|
if (not utils.string.isEmpty(self.message)) then
|
|
love.graphics.setColor(0,0,0, 0.66)
|
|
love.graphics.rectangle("fill", 0, PLAYER_MESSAGE, 424, 16)
|
|
self.view.scene.assets.fonts["small"]:setColor(1,1,1, 1)
|
|
self.view.scene.assets.fonts["small"]:draw(self.message, 424/2, PLAYER_MESSAGE - 1, -1, "center")
|
|
self.view.scene.assets.fonts["small"]:setColor(1,1,1, 1)
|
|
utils.graphics.resetColor()
|
|
end
|
|
end
|
|
|
|
function StatPage:setMessage(message)
|
|
self.message = message
|
|
end
|
|
|
|
function StatPage:removeEquip(type)
|
|
self.character:removeEquip(type)
|
|
end
|
|
|
|
function SkillMenu:new(page, character)
|
|
self.page = page
|
|
SkillMenu.super.new(self, page.view.scene, "equip", const.X, const.Y + 4, const.CHARPAGESIZE, 9, true, true)
|
|
for _, skill in ipairs(character.skills) do
|
|
SkillWidget(page, skill.name)
|
|
end
|
|
end
|
|
|
|
function SkillMenu:cancelAction()
|
|
self.scene.menusystem.menus["menu"]:getFocus()
|
|
self.page:setMessage("")
|
|
end
|
|
|
|
function SkillWidget:new(page, skill)
|
|
self.page = page
|
|
self.skillData = game.skills:getSkillData(skill)
|
|
SkillWidget.super.new(self, self.page.view.scene, "equip", self.skillData.fullname, utils.math.numberToString(self.skillData.cost, 2))
|
|
end
|
|
|
|
function SkillWidget:selectAction()
|
|
self.page:setMessage(self.skillData.description)
|
|
end
|
|
|
|
return StatPage
|