2020-08-26 18:38:40 +02:00
|
|
|
local ParentScreen = require "scenes.overworld.screens.parent"
|
|
|
|
local CharacterScreen = ParentScreen:extend()
|
|
|
|
|
|
|
|
local menu = require "game.modules.menus.fancy"
|
|
|
|
local gui = require "game.modules.gui"
|
2020-08-27 19:05:00 +02:00
|
|
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
2020-08-26 18:38:40 +02:00
|
|
|
|
2020-08-29 17:26:38 +02:00
|
|
|
local BasicPage = require "scenes.overworld.screens.mainmenu.character.basicpage"
|
|
|
|
local pageList = {BasicPage}
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
local ReturnWidget = menu.BaseWidget:extend()
|
|
|
|
|
|
|
|
function CharacterScreen:new(scene, character)
|
|
|
|
self.character = game.characters.list[character]
|
|
|
|
self.charName = character
|
|
|
|
|
2020-08-29 17:26:38 +02:00
|
|
|
self.page = BasicPage(self, character)
|
|
|
|
self.pageIndex = 1
|
2020-08-26 18:38:40 +02:00
|
|
|
|
|
|
|
self.artwork = love.graphics.newImage("datas/gamedata/characters/" .. character .. "/artwork.png")
|
|
|
|
self.artworkOrigin = require("datas.gamedata.characters." .. character .. ".artwork")
|
2020-08-27 19:05:00 +02:00
|
|
|
CharacterScreen.super.new(self, scene, self.character.name)
|
2020-08-26 18:38:40 +02:00
|
|
|
end
|
|
|
|
|
2020-08-29 17:26:38 +02:00
|
|
|
function CharacterScreen:update(dt)
|
|
|
|
local keys = self.scene:getKeys(1)
|
|
|
|
if (keys["left"].isPressed) then
|
|
|
|
self:setPage(self.pageIndex - 1)
|
|
|
|
end
|
|
|
|
if (keys["right"].isPressed) then
|
|
|
|
self:setPage(self.pageIndex + 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function CharacterScreen:setPage(newPageIndex)
|
|
|
|
local newPageIndex = newPageIndex or 1
|
|
|
|
if (newPageIndex > #pageList) then
|
|
|
|
newPageIndex = 1
|
|
|
|
end
|
|
|
|
if (newPageIndex < 1) then
|
|
|
|
newPageIndex = #pageList
|
|
|
|
end
|
|
|
|
|
|
|
|
self.pageIndex = newPageIndex
|
|
|
|
self.page = pageList[self.pageIndex](self, self.charName)
|
|
|
|
self.scene.menusystem:reset()
|
|
|
|
self:setMenu()
|
|
|
|
end
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
function CharacterScreen:setMenu()
|
2020-08-27 19:05:00 +02:00
|
|
|
local itemNumber = 1
|
2020-08-28 00:26:12 +02:00
|
|
|
local y = const.Y2 - (16*itemNumber) + 2
|
|
|
|
menu.FancyMenu(self.scene, "menu", const.X2 - 128 - 14, y, 128, 1, false)
|
2020-08-29 17:26:38 +02:00
|
|
|
self.page:getMenuWidgets()
|
2020-08-26 18:38:40 +02:00
|
|
|
--menu.BaseWidget(self.scene, "equip", "Change talent", ">")
|
|
|
|
--menu.BaseWidget(self.scene, "equip", "Battle skills", ">")
|
|
|
|
--menu.BaseWidget(self.scene, "equip", "Equipement", ">")
|
|
|
|
ReturnWidget(self.scene, self.charName)
|
|
|
|
|
|
|
|
self.scene.menusystem:switchMenu("menu")
|
|
|
|
self.scene.menusystem.menus["menu"]:getFocus()
|
|
|
|
self.scene.menusystem.menus["menu"]:setCancelWidget()
|
|
|
|
end
|
|
|
|
|
|
|
|
function CharacterScreen:draw()
|
2020-08-28 00:26:12 +02:00
|
|
|
self.scene.assets.fonts["small"]:setLineHeight(16/18)
|
2020-08-29 17:26:38 +02:00
|
|
|
if (self.page ~= nil) then
|
|
|
|
self.page:draw()
|
|
|
|
end
|
2020-08-26 18:38:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function CharacterScreen:drawBackground()
|
|
|
|
love.graphics.draw(self.artwork, self.artworkOrigin.x, self.artworkOrigin.y)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Widgets
|
|
|
|
|
|
|
|
function ReturnWidget:new(scene, charName)
|
|
|
|
self.charName = charName
|
|
|
|
ReturnWidget.super.new(self, scene, "menu", "Back", "")
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReturnWidget:action()
|
|
|
|
for i, name in ipairs(game.characters.team) do
|
|
|
|
if (name == self.charName) then
|
|
|
|
self.widgetSelected = i
|
|
|
|
end
|
|
|
|
end
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mBack")
|
2020-08-26 18:38:40 +02:00
|
|
|
|
|
|
|
self.scene.screens.mainmenu["pause"](self.scene, "character", self.widgetSelected)
|
|
|
|
end
|
|
|
|
|
|
|
|
return CharacterScreen
|