2020-11-27 17:00:39 +01:00
|
|
|
local ListMenu = require "birb.modules.menusystem.menus.listbox"
|
|
|
|
local Widget = require "birb.modules.menusystem.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()
|
|
|
|
|
|
|
|
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
|
2020-11-13 19:11:09 +01:00
|
|
|
local font = self.scene.assets:getFont("medium")
|
2019-06-16 16:37:22 +02:00
|
|
|
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
|
2020-11-13 19:11:09 +01:00
|
|
|
local font = self.scene.assets:getFont("medium")
|
2019-06-16 16:37:22 +02:00
|
|
|
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
|
2020-11-13 19:11:09 +01:00
|
|
|
local font = self.scene.assets:getFont("medium")
|
2019-06-16 16:37:22 +02:00
|
|
|
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
|