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"
|
2021-04-23 10:21:54 +02:00
|
|
|
local StatPage = require "scenes.overworld.screens.mainmenu.character.statpage"
|
|
|
|
local SkillPage = require "scenes.overworld.screens.mainmenu.character.skillpage"
|
|
|
|
local pageList = {BasicPage, StatPage, SkillPage}
|
2020-08-29 17:26:38 +02:00
|
|
|
|
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)
|
2021-04-23 11:10:52 +02:00
|
|
|
self.scene.assets.sfx["mBeep"]:play()
|
2020-08-29 17:26:38 +02:00
|
|
|
end
|
|
|
|
if (keys["right"].isPressed) then
|
|
|
|
self:setPage(self.pageIndex + 1)
|
2021-04-23 11:10:52 +02:00
|
|
|
self.scene.assets.sfx["mBeep"]:play()
|
2020-08-29 17:26:38 +02:00
|
|
|
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()
|
2021-04-23 10:21:54 +02:00
|
|
|
local itemNumber = self.page:getMenuSize()
|
2020-08-28 00:26:12 +02:00
|
|
|
local y = const.Y2 - (16*itemNumber) + 2
|
2021-04-23 10:21:54 +02:00
|
|
|
menu.FancyMenu(self.scene, "menu", const.X2 - 128 - 14, y, 128, itemNumber, false)
|
2020-08-29 17:26:38 +02:00
|
|
|
self.page:getMenuWidgets()
|
2020-08-26 18:38:40 +02:00
|
|
|
ReturnWidget(self.scene, self.charName)
|
|
|
|
|
2021-04-23 10:21:54 +02:00
|
|
|
local customMenu = self.page:getCustomMenus()
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
self.scene.menusystem:switchMenu("menu")
|
|
|
|
self.scene.menusystem.menus["menu"]:getFocus()
|
|
|
|
self.scene.menusystem.menus["menu"]:setCancelWidget()
|
2021-04-23 10:21:54 +02:00
|
|
|
self.scene.menusystem.menus["menu"].isLocked = true
|
|
|
|
if (customMenu ~= nil) then
|
|
|
|
customMenu.isLocked = true
|
|
|
|
customMenu.isVisible = true
|
|
|
|
end
|
2021-04-23 11:10:52 +02:00
|
|
|
self.scene.menusystem:setSoundFromSceneAssets("mBeep")
|
2020-08-26 18:38:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function CharacterScreen:draw()
|
2020-08-29 17:26:38 +02:00
|
|
|
if (self.page ~= nil) then
|
|
|
|
self.page:draw()
|
|
|
|
end
|
2021-04-23 10:21:54 +02:00
|
|
|
|
|
|
|
for i = 1, #pageList, 1 do
|
|
|
|
local radius = 2
|
|
|
|
if (i == self.pageIndex) then
|
|
|
|
radius = 3
|
|
|
|
end
|
|
|
|
local x = (16*i) + 240 + 64
|
|
|
|
local y = 17
|
|
|
|
local outlineLight = 0.15
|
|
|
|
love.graphics.circle("fill", x + 8, y + 8, radius, 8)
|
|
|
|
love.graphics.setColor(outlineLight, outlineLight, outlineLight, 1)
|
|
|
|
love.graphics.circle("line", x + 8, y + 8, radius, 8)
|
|
|
|
utils.graphics.resetColor()
|
|
|
|
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
|
|
|
|
|
2021-04-23 10:21:54 +02:00
|
|
|
function CharacterScreen:drawOverEverything()
|
|
|
|
if (self.page ~= nil) then
|
|
|
|
self.page:drawOverEverything()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
-- 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
|