2020-08-20 15:39:02 +02:00
|
|
|
local ParentScreen = require "scenes.overworld.screens.parent"
|
|
|
|
local PauseScreen = ParentScreen:extend()
|
|
|
|
|
|
|
|
local menu = require "game.modules.menus.fancy"
|
|
|
|
|
2021-03-12 22:17:33 +01:00
|
|
|
local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu"
|
|
|
|
local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget"
|
|
|
|
local CharacterMenu = baseCharacterMenu:extend()
|
|
|
|
local CharacterWidget = baseCharacterWidget:extend()
|
2020-08-20 15:39:02 +02:00
|
|
|
|
2020-08-23 10:40:06 +02:00
|
|
|
local TeamWidget = menu.BaseWidget:extend()
|
2020-08-26 18:38:40 +02:00
|
|
|
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
|
|
|
|
2021-05-05 08:30:32 +02:00
|
|
|
local defTransitions = require "birb.modules.transitions"
|
2021-04-05 14:20:25 +02:00
|
|
|
local radTransitions = require "game.modules.transitions"
|
2021-04-18 16:36:40 +02:00
|
|
|
local ConfirmDialog = require "game.modules.confirmdialog"
|
2021-04-05 14:20:25 +02:00
|
|
|
|
2020-08-27 19:05:00 +02:00
|
|
|
local const = require "scenes.overworld.screens.mainmenu.const"
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
function PauseScreen:new(scene, menu, widget)
|
|
|
|
self.menuSelected = menu or "main"
|
|
|
|
self.widgetSelected = widget
|
|
|
|
self.widget = widget
|
2020-08-27 19:05:00 +02:00
|
|
|
PauseScreen.super.new(self, scene, "Menu")
|
2020-08-20 15:39:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function PauseScreen:setMenu()
|
2020-08-28 00:26:12 +02:00
|
|
|
menu.FancyMenu(self.scene, "main", const.X, const.Y, 108, 10, false)
|
2020-08-23 10:40:06 +02:00
|
|
|
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", ">")
|
2021-04-05 14:20:25 +02:00
|
|
|
--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
|
|
|
|
2020-08-23 10:40:06 +02:00
|
|
|
CharacterMenu(self.scene)
|
2020-08-26 18:38:40 +02:00
|
|
|
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)
|
2020-10-03 14:36:38 +02:00
|
|
|
self.scene.menusystem.menus["main"].isVisible = true
|
2020-08-26 18:38:40 +02:00
|
|
|
if (self.widgetSelected ~= nil) then
|
|
|
|
self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected
|
2021-03-23 14:07:58 +01:00
|
|
|
self.scene.menusystem.menus[self.menuSelected].cursorTransition = self.widgetSelected - 1
|
2020-08-26 18:38:40 +02:00
|
|
|
end
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.menusystem:setSoundFromSceneAssets("mBeep")
|
2020-08-20 15:39:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function PauseScreen:draw()
|
2020-08-27 19:05:00 +02:00
|
|
|
|
2020-08-20 15:39:02 +02:00
|
|
|
end
|
|
|
|
|
2020-08-23 10:40:06 +02:00
|
|
|
-- Character menu
|
|
|
|
function CharacterMenu:cancelAction()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mBeep")
|
2020-08-27 08:44:21 +02:00
|
|
|
self.scene.menusystem:switchMenu("main")
|
2020-08-23 10:40:06 +02:00
|
|
|
end
|
|
|
|
|
2020-08-20 15:39:02 +02:00
|
|
|
-- Hero custom widget
|
|
|
|
--
|
2020-08-26 18:38:40 +02:00
|
|
|
function CharacterWidget:action()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mSelect")
|
2020-08-26 18:38:40 +02:00
|
|
|
self.scene.screens.mainmenu.character(self.scene, self.charName)
|
|
|
|
end
|
|
|
|
|
2020-08-23 10:40:06 +02:00
|
|
|
-- Team Widget
|
|
|
|
--
|
|
|
|
|
|
|
|
function TeamWidget:new(scene)
|
|
|
|
TeamWidget.super.new(self, scene, "main", "Team", ">")
|
|
|
|
end
|
|
|
|
|
|
|
|
function TeamWidget:action()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mBeep")
|
2020-08-23 10:40:06 +02:00
|
|
|
self.scene.menusystem.menus["character"]:getFocus()
|
|
|
|
end
|
|
|
|
|
2020-08-26 18:38:40 +02:00
|
|
|
-- View Widget
|
|
|
|
function ViewWidget:new(scene, name, view)
|
|
|
|
TeamWidget.super.new(self, scene, "main", name, ">")
|
|
|
|
self.nextView = view
|
|
|
|
end
|
|
|
|
|
|
|
|
function ViewWidget:action()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mSelect")
|
2020-08-26 18:38:40 +02:00
|
|
|
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()
|
2021-04-11 10:32:49 +02:00
|
|
|
if (self.save or self.exit) then
|
|
|
|
self.scene.assets:playSFX("mSelect")
|
|
|
|
else
|
|
|
|
self.scene.assets:playSFX("mBack")
|
|
|
|
end
|
2020-08-27 08:44:21 +02:00
|
|
|
if (self.save) then
|
2021-04-02 23:26:22 +02:00
|
|
|
self.scene.world:savePosition()
|
2020-08-27 08:44:21 +02:00
|
|
|
game:write()
|
|
|
|
end
|
|
|
|
if (self.exit) then
|
2021-04-18 16:36:40 +02:00
|
|
|
if (self.save) then
|
|
|
|
self:exitToMenu()
|
|
|
|
else
|
|
|
|
local confirm = ConfirmDialog(self.scene, "Do you to exit the game ? \nAll unsaved data will be lost.",
|
|
|
|
function() self:exitToMenu() end)
|
|
|
|
confirm:setCancelChoice(2)
|
|
|
|
end
|
2020-08-27 08:44:21 +02:00
|
|
|
else
|
|
|
|
self.scene:unpause()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-18 16:36:40 +02:00
|
|
|
function SaveExitWidget:exitToMenu()
|
2021-08-15 16:26:05 +02:00
|
|
|
core.screen:startTransition(defTransitions.default, defTransitions.circle, function() game:reload() scenes.menus.main() end, 424/2, 240/2)
|
2021-04-18 16:36:40 +02:00
|
|
|
self.scene.tweens:newTween(0, 0.3, {ringBorder=-16}, "inOutQuad")
|
|
|
|
self.scene.tweens:newTween(0, 0.3, {timeBorder=-20}, "inOutQuad")
|
|
|
|
end
|
|
|
|
|
2020-08-20 15:39:02 +02:00
|
|
|
return PauseScreen
|