fix: port to the new menusystem the pause menu

This commit is contained in:
Kazhnuz 2021-01-30 09:19:22 +01:00
parent 150aad86f1
commit e8b796f978

View file

@ -7,26 +7,27 @@ local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend() local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend() local ExitWidget = Widget.Text:extend()
local MENU_NAME = "PauseMenu"
function PauseMenu:new(scene) function PauseMenu:new(scene)
self.scene = scene self.scene = scene
local screenHeight, screenWidth = core.screen:getDimensions() local screenHeight, screenWidth = core.screen:getDimensions()
local w, h = 424/4, 240 - 48*4 local w, h = 424/4, 240 - 48*4
local x, y = 3*w/2, 24*4 local x, y = 3*w/2, 24*4
PauseMenu.super.new(self, scene.menusystem, "PauseMenu", x, y, w, h, 3) PauseMenu.super.new(self, scene.menusystem, MENU_NAME, x, y, w, h, 3)
ResumeWidget(self) ResumeWidget()
RestartWidget(self) RestartWidget()
ExitWidget(self) ExitWidget()
end end
-- WIDGETS -- WIDGETS
-- All widgets used by the pause menu -- All widgets used by the pause menu
function ResumeWidget:new(menu) function ResumeWidget:new()
self.scene = menu.scene self.scene = core.scenemanager.currentScene
local font = self.scene.assets:getFont("medium")
local label = "resume" local label = "resume"
ResumeWidget.super.new(self, menu, font, label) ResumeWidget.super.new(self, MENU_NAME, "medium", label)
end end
function ResumeWidget:action() function ResumeWidget:action()
@ -34,11 +35,10 @@ function ResumeWidget:action()
self.scene.menusystem:deactivate() self.scene.menusystem:deactivate()
end end
function RestartWidget:new(menu) function RestartWidget:new()
self.scene = menu.scene self.scene = core.scenemanager.currentScene
local font = self.scene.assets:getFont("medium")
local label = "restart" local label = "restart"
RestartWidget.super.new(self, menu, font, label) RestartWidget.super.new(self, MENU_NAME, "medium", label)
end end
function RestartWidget:action() function RestartWidget:action()
@ -46,11 +46,10 @@ function RestartWidget:action()
self.scene:restart() self.scene:restart()
end end
function ExitWidget:new(menu) function ExitWidget:new()
self.scene = menu.scene self.scene = core.scenemanager.currentScene
local font = self.scene.assets:getFont("medium")
local label = "exit" local label = "exit"
ExitWidget.super.new(self, menu, font, label) ExitWidget.super.new(self, MENU_NAME, "medium", label)
end end
function ExitWidget:action() function ExitWidget:action()