sonic-bluestreak/sonic-bluestreak.love/scenes/overworld/screens/mainmenu/character/skillpage.lua

72 lines
2.1 KiB
Lua
Raw Permalink Normal View History

2021-11-25 10:57:13 +01: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 = ""
self.showMessage = false
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")
self.showMessage = true
end
end
function StatPage:drawOverEverything()
if (not utils.string.isEmpty(self.message) and self.showMessage) 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.showMessage = false
self.scene.assets.sfx["mBack"]:play()
end
function SkillWidget:new(page, skill)
self.page = page
self.skillData = core.datas:get("skills", 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