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 gui = require "game.modules.gui"
|
|
|
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
|
|
|
|
|
|
|
local EquipMenu = menu.ListMenu:extend()
|
|
|
|
local EquipWidget = menu.DualTextWidget:extend()
|
|
|
|
|
2021-05-16 08:38:09 +02:00
|
|
|
local STATS = require "datas.consts.stats"
|
2021-04-23 10:21:54 +02:00
|
|
|
|
|
|
|
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
|
2021-07-03 09:51:19 +02:00
|
|
|
local stat = char.stats:get(statName)
|
2021-04-23 10:21:54 +02:00
|
|
|
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()
|
2021-04-23 11:10:52 +02:00
|
|
|
self.scene.assets.sfx["mBack"]:play()
|
2021-04-23 10:21:54 +02:00
|
|
|
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
|
2021-05-15 21:43:15 +02:00
|
|
|
local data = core.datas:get("items", obj)
|
2021-04-23 10:21:54 +02:00
|
|
|
return data.fullname
|
|
|
|
end
|
|
|
|
|
|
|
|
function EquipWidget:action()
|
|
|
|
self.page:removeEquip(self.type)
|
|
|
|
self.label = self:getLabel()
|
|
|
|
self:redrawCanvas()
|
2021-04-23 11:10:52 +02:00
|
|
|
self.scene.assets.sfx["mSelect"]:play()
|
2021-04-23 10:21:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return StatPage
|