sonic-bluestreak/sonic-bluestreak.love/scenes/subgame/sonic-boost/controller/pause.lua

67 lines
1.5 KiB
Lua
Raw Normal View History

local ListBox = require "core.modules.menusystem.listbox"
local PauseMenu = ListBox:extend()
2019-02-10 20:00:37 +01:00
local Widget = require "core.modules.menusystem.widgets"
2019-02-15 18:37:03 +01:00
local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend()
function PauseMenu:new(controller)
local height, width, x, y
height = 72
2019-02-15 18:37:03 +01:00
width = 72
x = 424/2 - width/2
y = 240/2 - height/2
PauseMenu.super.new(self, controller.menusystem, "pauseMenu", x, y, width, height, 3)
self.controller = controller
self:setSound(self.controller.assets.sfx["select"])
self.isActive = false
self.isVisible = false
2019-02-15 18:37:03 +01:00
local font = self.controller.assets.fonts["menu"]
2019-02-15 18:37:03 +01:00
ResumeWidget(self, font)
RestartWidget(self, font)
ExitWidget(self, font)
end
function PauseMenu:draw()
PauseMenu.super.draw(self)
end
--- MENU WIDGETS
2019-02-15 18:37:03 +01:00
function ResumeWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "resume")
end
function ResumeWidget:action()
2019-02-15 18:37:03 +01:00
self.menu.isActive = false
self.menu.isVisible = false
self.menu.controller.assets.isActive = true
self.menu.controller:lockInputs()
end
2019-02-15 18:37:03 +01:00
function RestartWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "restart")
end
function RestartWidget:action()
self.menu.controller:lockInputs()
self.menu.controller:restartLevel()
end
2019-02-15 18:37:03 +01:00
function ExitWidget:new(menu, font)
ExitWidget.super.new(self, menu, font, "exit")
end
function ExitWidget:action()
2019-02-15 18:37:03 +01:00
self.menu.controller:exitLevel()
end
return PauseMenu