2021-04-23 10:21:54 +02:00
|
|
|
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 = ""
|
2021-04-23 11:10:52 +02:00
|
|
|
self.showMessage = false
|
2021-04-23 10:21:54 +02:00
|
|
|
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")
|
2021-04-23 11:10:52 +02:00
|
|
|
self.showMessage = true
|
2021-04-23 10:21:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function StatPage:drawOverEverything()
|
2021-04-23 11:10:52 +02:00
|
|
|
if (not utils.string.isEmpty(self.message) and self.showMessage) then
|
2021-04-23 10:21:54 +02:00
|
|
|
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()
|
2021-04-23 11:10:52 +02:00
|
|
|
self.page.showMessage = false
|
|
|
|
self.scene.assets.sfx["mBack"]:play()
|
2021-04-23 10:21:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function SkillWidget:new(page, skill)
|
|
|
|
self.page = page
|
2021-05-16 08:48:05 +02:00
|
|
|
self.skillData = core.datas:get("skills", skill)
|
2021-04-23 10:21:54 +02:00
|
|
|
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
|