2021-12-04 14:12:17 +01:00
|
|
|
local ListMenu = require "birb.modules.gui.menus.listbox"
|
|
|
|
local Widget = require "birb.modules.gui.menus.widgets"
|
2019-06-16 16:37:22 +02:00
|
|
|
|
|
|
|
local PauseMenu = ListMenu:extend()
|
|
|
|
|
|
|
|
local ResumeWidget = Widget.Text:extend()
|
|
|
|
local RestartWidget = Widget.Text:extend()
|
|
|
|
local ExitWidget = Widget.Text:extend()
|
|
|
|
|
2021-01-30 09:19:22 +01:00
|
|
|
local MENU_NAME = "PauseMenu"
|
|
|
|
|
2019-06-16 16:37:22 +02:00
|
|
|
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
|
2021-01-30 09:19:22 +01:00
|
|
|
PauseMenu.super.new(self, scene.menusystem, MENU_NAME, x, y, w, h, 3)
|
2019-06-16 16:37:22 +02:00
|
|
|
|
2021-01-30 09:19:22 +01:00
|
|
|
ResumeWidget()
|
|
|
|
RestartWidget()
|
|
|
|
ExitWidget()
|
2019-06-16 16:37:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- WIDGETS
|
|
|
|
-- All widgets used by the pause menu
|
|
|
|
|
2021-01-30 09:19:22 +01:00
|
|
|
function ResumeWidget:new()
|
|
|
|
self.scene = core.scenemanager.currentScene
|
2019-06-16 16:37:22 +02:00
|
|
|
local label = "resume"
|
2021-01-30 09:19:22 +01:00
|
|
|
ResumeWidget.super.new(self, MENU_NAME, "medium", label)
|
2019-06-16 16:37:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ResumeWidget:action()
|
|
|
|
self.scene.assets:playSFX(self.sfx)
|
|
|
|
self.scene.menusystem:deactivate()
|
|
|
|
end
|
|
|
|
|
2021-01-30 09:19:22 +01:00
|
|
|
function RestartWidget:new()
|
|
|
|
self.scene = core.scenemanager.currentScene
|
2019-06-16 16:37:22 +02:00
|
|
|
local label = "restart"
|
2021-01-30 09:19:22 +01:00
|
|
|
RestartWidget.super.new(self, MENU_NAME, "medium", label)
|
2019-06-16 16:37:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function RestartWidget:action()
|
|
|
|
self.scene.assets:playSFX(self.sfx)
|
|
|
|
self.scene:restart()
|
|
|
|
end
|
|
|
|
|
2021-01-30 09:19:22 +01:00
|
|
|
function ExitWidget:new()
|
|
|
|
self.scene = core.scenemanager.currentScene
|
2019-06-16 16:37:22 +02:00
|
|
|
local label = "exit"
|
2021-01-30 09:19:22 +01:00
|
|
|
ExitWidget.super.new(self, MENU_NAME, "medium", label)
|
2019-06-16 16:37:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function ExitWidget:action()
|
|
|
|
self.scene.assets:playSFX(self.sfx)
|
|
|
|
core.scenemanager:setStoredScene("mainmenu")
|
|
|
|
end
|
|
|
|
|
|
|
|
return PauseMenu
|