2019-02-11 20:34:25 +01:00
|
|
|
local ListBox = require "core.modules.menusystem.listbox"
|
|
|
|
local PauseMenu = ListBox:extend()
|
2019-02-03 19:54:02 +01:00
|
|
|
|
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()
|
2019-02-03 19:54:02 +01:00
|
|
|
|
|
|
|
function PauseMenu:new(controller)
|
2019-02-11 20:34:25 +01:00
|
|
|
local height, width, x, y
|
|
|
|
height = 72
|
2019-02-15 18:37:03 +01:00
|
|
|
width = 72
|
2019-02-11 20:34:25 +01:00
|
|
|
x = 424/2 - width/2
|
|
|
|
y = 240/2 - height/2
|
2019-02-03 19:54:02 +01:00
|
|
|
|
2019-02-11 20:34:25 +01:00
|
|
|
PauseMenu.super.new(self, controller.menusystem, "pauseMenu", x, y, width, height, 3)
|
|
|
|
self.controller = controller
|
2019-02-03 19:54:02 +01:00
|
|
|
|
2019-02-11 20:34:25 +01:00
|
|
|
self:setSound(self.controller.assets.sfx["select"])
|
|
|
|
self.isActive = false
|
|
|
|
self.isVisible = false
|
2019-02-03 19:54:02 +01:00
|
|
|
|
2019-02-15 18:37:03 +01:00
|
|
|
local font = self.controller.assets.fonts["menu"]
|
2019-02-03 19:54:02 +01:00
|
|
|
|
2019-02-15 18:37:03 +01:00
|
|
|
ResumeWidget(self, font)
|
|
|
|
RestartWidget(self, font)
|
|
|
|
ExitWidget(self, font)
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function PauseMenu:draw()
|
2019-02-11 20:34:25 +01:00
|
|
|
PauseMenu.super.draw(self)
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- MENU WIDGETS
|
|
|
|
|
2019-02-15 18:37:03 +01:00
|
|
|
function ResumeWidget:new(menu, font)
|
|
|
|
ResumeWidget.super.new(self, menu, font, "resume")
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function ResumeWidget:action()
|
2019-02-15 18:37:03 +01:00
|
|
|
self.menu.isActive = false
|
|
|
|
self.menu.isVisible = false
|
2019-02-15 18:38:41 +01:00
|
|
|
self.menu.controller.assets.isActive = true
|
2019-02-15 18:45:48 +01:00
|
|
|
self.menu.controller:flushKeys()
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
2019-02-15 18:37:03 +01:00
|
|
|
function RestartWidget:new(menu, font)
|
|
|
|
ResumeWidget.super.new(self, menu, font, "restart")
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function RestartWidget:action()
|
|
|
|
self.controller:restartLevel()
|
|
|
|
end
|
|
|
|
|
2019-02-15 18:37:03 +01:00
|
|
|
function ExitWidget:new(menu, font)
|
|
|
|
ExitWidget.super.new(self, menu, font, "exit")
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function ExitWidget:action()
|
2019-02-15 18:37:03 +01:00
|
|
|
self.menu.controller:exitLevel()
|
2019-02-03 19:54:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return PauseMenu
|