88 lines
2.6 KiB
Lua
88 lines
2.6 KiB
Lua
local PageParent = require "scenes.overworld.screens.mainmenu.character.pageparent"
|
|
local StatPage = PageParent:extend()
|
|
|
|
local menu = require "game.modules.menus.list"
|
|
local gui = require "game.modules.gui"
|
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
|
|
|
local EquipMenu = menu.ListMenu:extend()
|
|
local EquipWidget = menu.DualTextWidget:extend()
|
|
|
|
local STATS = require "datas.consts.stats"
|
|
|
|
function StatPage:new(view, character)
|
|
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40 + 32)
|
|
|
|
StatPage.super.new(self, view, character, {"Remove item"})
|
|
end
|
|
|
|
function StatPage:getCustomMenus()
|
|
return EquipMenu(self)
|
|
end
|
|
|
|
function StatPage:menuResponses(i)
|
|
self.view.scene.menusystem:switchMenu("equip")
|
|
end
|
|
|
|
function StatPage:draw()
|
|
self:drawStats(const.X, 100)
|
|
end
|
|
|
|
function StatPage:drawStats(x, y)
|
|
love.graphics.draw(self.statBox, x, y)
|
|
|
|
local char = self.character
|
|
for i, statName in ipairs(STATS.LIST) do
|
|
local xStat = x + (((i - 1) % 2) * (const.CHARPAGESIZE/2)) + 6
|
|
local yStat = y + (math.floor((i-1)/2) * 16) + 4
|
|
local middle = xStat + 10 + const.CHARPAGESIZE/4
|
|
local stat = char.stats:get(statName)
|
|
self.view.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, const.CHARPAGESIZE, "left")
|
|
self.view.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9)
|
|
self.view.scene.assets.fonts["small"]:draw(stat, middle, yStat, -1, "center")
|
|
self.view.scene.assets.fonts["small"]:setColor(1, 1, 1, 1)
|
|
utils.graphics.resetColor()
|
|
end
|
|
end
|
|
|
|
function StatPage:removeEquip(type)
|
|
self.character:removeEquip(type)
|
|
end
|
|
|
|
function EquipMenu:new(page)
|
|
self.page = page
|
|
EquipMenu.super.new(self, page.view.scene, "equip", const.X, const.Y + 4, const.CHARPAGESIZE, 3, true, true)
|
|
EquipWidget(page, "gloves")
|
|
EquipWidget(page, "shoes")
|
|
EquipWidget(page, "accessories")
|
|
end
|
|
|
|
function EquipMenu:cancelAction()
|
|
self.scene.menusystem.menus["menu"]:getFocus()
|
|
self.scene.assets.sfx["mBack"]:play()
|
|
end
|
|
|
|
function EquipWidget:new(page, type)
|
|
self.page = page
|
|
self.type = type
|
|
local label = self:getLabel()
|
|
EquipWidget.super.new(self, self.page.view.scene, "equip", label, "")
|
|
end
|
|
|
|
function EquipWidget:getLabel()
|
|
local obj = self.page.character.equip[self.type]
|
|
if (utils.string.isEmpty(obj)) then
|
|
return "No " .. self.type
|
|
end
|
|
local data = core.datas:get("items", obj)
|
|
return data.fullname
|
|
end
|
|
|
|
function EquipWidget:action()
|
|
self.page:removeEquip(self.type)
|
|
self.label = self:getLabel()
|
|
self:redrawCanvas()
|
|
self.scene.assets.sfx["mSelect"]:play()
|
|
end
|
|
|
|
return StatPage
|