sonic-radiance/sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua

164 lines
4.8 KiB
Lua
Raw Normal View History

2020-08-20 15:39:02 +02:00
local ParentScreen = require "scenes.overworld.screens.parent"
local PauseScreen = ParentScreen:extend()
local ComplexHPBar = require "game.modules.gui.complexhpbar"
2020-08-20 15:39:02 +02:00
local Emblem = require "game.modules.gui.emblem"
local menu = require "game.modules.menus.fancy"
local baseMenu = require "game.modules.menus.parents.menu"
local baseWidget = require "game.modules.menus.parents.widget"
local CharacterMenu = baseMenu:extend()
2020-08-20 15:39:02 +02:00
local CharacterWidget = baseWidget:extend()
local TeamWidget = menu.BaseWidget:extend()
local ViewWidget = menu.BaseWidget:extend()
2020-08-27 08:44:21 +02:00
local SaveExitWidget = menu.BaseWidget:extend()
2020-08-20 15:39:02 +02:00
local const = require "scenes.overworld.screens.mainmenu.const"
function PauseScreen:new(scene, menu, widget)
self.menuSelected = menu or "main"
self.widgetSelected = widget
self.widget = widget
PauseScreen.super.new(self, scene, "Menu")
2020-08-20 15:39:02 +02:00
end
function PauseScreen:setMenu()
menu.FancyMenu(self.scene, "main", const.X, const.Y, 108, 10, false)
TeamWidget(self.scene)
2020-08-23 10:19:27 +02:00
menu.BaseWidget(self.scene, "main", "Quest", ">")
2020-08-29 11:36:59 +02:00
ViewWidget(self.scene, "Items", "items")
2020-08-20 15:39:02 +02:00
menu.BaseWidget(self.scene, "main", "Chao", ">")
menu.BaseWidget(self.scene, "main", "Encylopedia", ">")
menu.BaseWidget(self.scene, "main", "Options", ">")
2020-08-27 08:44:21 +02:00
self.scene.menusystem.menus["main"]:addSubMenu("save", "Save / Exit")
SaveExitWidget(self.scene, "main", "Resume", false, false)
SaveExitWidget(self.scene, "save", "Save game", true, false)
SaveExitWidget(self.scene, "save", "Save and exit", true, true)
SaveExitWidget(self.scene, "save", "Exit game", false, true)
self.scene.menusystem.menus["main"]:finalize()
2020-10-04 09:31:06 +02:00
self.scene.menusystem.menus["main"]:setCancelWidget()
2020-08-20 15:39:02 +02:00
CharacterMenu(self.scene)
for i, name in ipairs(game.characters.team) do
CharacterWidget(self.scene, name)
end
2020-08-27 08:44:21 +02:00
self.scene.menusystem.menus["character"].isLocked = true
2020-08-23 10:19:27 +02:00
2020-08-27 08:44:21 +02:00
self.scene.menusystem:switchMenu(self.menuSelected)
self.scene.menusystem.menus["main"].isVisible = true
if (self.widgetSelected ~= nil) then
self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected
end
2020-08-20 15:39:02 +02:00
end
function PauseScreen:draw()
2020-08-20 15:39:02 +02:00
end
-- Character menu
function CharacterMenu:new(scene)
local x = const.X + 136
local w = const.WIDTH - x + 28
CharacterMenu.super.new(self, scene, "character", x, const.Y, w, const.HEIGHT, 4)
end
function CharacterMenu:cancelAction()
2020-08-27 08:44:21 +02:00
self.scene.menusystem:switchMenu("main")
end
2020-08-20 15:39:02 +02:00
-- Hero custom widget
--
function CharacterWidget:new(scene, name)
self.charName = name
self.emblem = Emblem(game.characters.list[name], scene)
self.font2 = scene.assets.fonts["hudnbrs_small"]
CharacterWidget.super.new(self, scene, "character")
self.hpbar = ComplexHPBar(88)
self.ppbar = ComplexHPBar(88)
self.hpbar:setColorForeground(248/255, 160/255, 0, 1)
self.hpbar:setColorBackground(112/255, 0, 0)
self.ppbar:setColorForeground(0, 248/255, 248/255, 1)
self.ppbar:setColorBackground(0, 54/255, 229/255)
2020-08-20 15:39:02 +02:00
end
function CharacterWidget:drawCanvas()
local character = game.characters.list[self.charName]
self.font:setFilter("shadow")
local debut = 0
local xDebut = 32
self.font:draw(character.fullname, xDebut, debut, -1, "left")
local yLvl = debut + 16
local xLvl = xDebut
self.scene.assets.images["lvl"]:draw(xLvl, yLvl)
self.scene.assets.images["exp"]:draw(xLvl, yLvl + 10)
self.font2:print(character.level, xLvl + 19, yLvl, "left")
local expString = character.exp .. "/" .. character.exp_next
self.font2:print(expString, xLvl + 19, yLvl + 10, "left")
end
function CharacterWidget:draw(x, y)
local character = game.characters.list[self.charName]
2020-08-20 15:39:02 +02:00
self.emblem:draw(x, y+6)
local xDebut = x + 52
local yDebut = y + 15
self.scene.assets.fonts["hudnbrs_small"]:set()
self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, character.stats.hpmax)
self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, character.stats.ppmax)
2020-08-20 15:39:02 +02:00
if self.canvas.texture ~= nil then
love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy)
end
end
function CharacterWidget:action()
self.scene.screens.mainmenu.character(self.scene, self.charName)
end
-- Team Widget
--
function TeamWidget:new(scene)
TeamWidget.super.new(self, scene, "main", "Team", ">")
end
function TeamWidget:action()
self.scene.menusystem.menus["character"]:getFocus()
end
-- View Widget
function ViewWidget:new(scene, name, view)
TeamWidget.super.new(self, scene, "main", name, ">")
self.nextView = view
end
function ViewWidget:action()
self.scene.screens.mainmenu[self.nextView](self.scene)
end
2020-08-27 08:44:21 +02:00
-- Save & Exit Widget
function SaveExitWidget:new(scene, menu, name, save, exit)
SaveExitWidget.super.new(self, scene, menu, name, "")
self.exit = exit
self.save = save
end
function SaveExitWidget:action()
if (self.save) then
game:write()
end
if (self.exit) then
scenes.debug.menu()
else
self.scene:unpause()
end
end
2020-08-20 15:39:02 +02:00
return PauseScreen