62 lines
1.5 KiB
Lua
62 lines
1.5 KiB
Lua
|
local ListMenu = require "gamecore.modules.menusystem.listbox"
|
||
|
local Widget = require "gamecore.modules.menusystem.widgets"
|
||
|
|
||
|
local PauseMenu = ListMenu:extend()
|
||
|
|
||
|
local ResumeWidget = Widget.Text:extend()
|
||
|
local RestartWidget = Widget.Text:extend()
|
||
|
local ExitWidget = Widget.Text:extend()
|
||
|
|
||
|
function PauseMenu:new(scene)
|
||
|
self.scene = scene
|
||
|
local screenHeight, screenWidth = core.screen:getDimensions()
|
||
|
local w, h = 424/4, 240 - 48*4
|
||
|
local x, y = 3*w/2, 24*4
|
||
|
PauseMenu.super.new(self, scene.menusystem, "PauseMenu", x, y, w, h, 3)
|
||
|
|
||
|
ResumeWidget(self)
|
||
|
RestartWidget(self)
|
||
|
ExitWidget(self)
|
||
|
end
|
||
|
|
||
|
-- WIDGETS
|
||
|
-- All widgets used by the pause menu
|
||
|
|
||
|
function ResumeWidget:new(menu)
|
||
|
self.scene = menu.scene
|
||
|
local font = self.scene.assets.fonts["medium"]
|
||
|
local label = "resume"
|
||
|
ResumeWidget.super.new(self, menu, font, label)
|
||
|
end
|
||
|
|
||
|
function ResumeWidget:action()
|
||
|
self.scene.assets:playSFX(self.sfx)
|
||
|
self.scene.menusystem:deactivate()
|
||
|
end
|
||
|
|
||
|
function RestartWidget:new(menu)
|
||
|
self.scene = menu.scene
|
||
|
local font = self.scene.assets.fonts["medium"]
|
||
|
local label = "restart"
|
||
|
RestartWidget.super.new(self, menu, font, label)
|
||
|
end
|
||
|
|
||
|
function RestartWidget:action()
|
||
|
self.scene.assets:playSFX(self.sfx)
|
||
|
self.scene:restart()
|
||
|
end
|
||
|
|
||
|
function ExitWidget:new(menu)
|
||
|
self.scene = menu.scene
|
||
|
local font = self.scene.assets.fonts["medium"]
|
||
|
local label = "exit"
|
||
|
ExitWidget.super.new(self, menu, font, label)
|
||
|
end
|
||
|
|
||
|
function ExitWidget:action()
|
||
|
self.scene.assets:playSFX(self.sfx)
|
||
|
core.scenemanager:setStoredScene("mainmenu")
|
||
|
end
|
||
|
|
||
|
return PauseMenu
|