sonic-radiance/sonic-radiance.love/game/modules/subgames/pause.lua
Kazhnuz 70ed18202d feat: backport code from bluestreak
It'll give us the following features
- Support for autorun in shoot-style maps
- Pause menu in subgames
- Chunk in shoot maps
- Rings
2020-08-16 10:52:00 +02:00

76 lines
1.8 KiB
Lua

local ListBox = require "core.modules.menusystem.listbox"
local PauseMenu = ListBox:extend()
local Widget = require "core.modules.menusystem.widgets"
local ResumeWidget = Widget.Text:extend()
local RestartWidget = Widget.Text:extend()
local ExitWidget = Widget.Text:extend()
local gui = require "game.modules.gui"
function PauseMenu:new(subgame)
local height, width, x, y
height = 72
width = 128
x = 424/2 - width/2
y = 240/2 - height/2
PauseMenu.super.new(self, subgame.menusystem, "pauseMenu", x, y, width, height, 3)
self.subgame = subgame
self:setSound(self.subgame.assets.sfx["navigate"])
self.isActive = false
self.isVisible = false
local font = self.subgame.assets.fonts["menu"]
self.textbox = gui.newTextBox("assets/gui/dialogbox.png", width+16, height+16)
ResumeWidget(self, font)
RestartWidget(self, font)
ExitWidget(self, font)
end
function PauseMenu:draw()
love.graphics.draw(self.textbox, self.x-8, self.y-8)
PauseMenu.super.draw(self)
end
--- MENU WIDGETS
function ResumeWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "resume")
end
function ResumeWidget:action()
self.menu.isActive = false
self.menu.isVisible = false
self.menu.subgame.world.isActive = true
self.menu.subgame.assets.isActive = true
self.menu.subgame:flushKeys()
end
function RestartWidget:new(menu, font)
ResumeWidget.super.new(self, menu, font, "restart")
end
function RestartWidget:action()
self.menu.subgame:restartLevel()
self.menu.isActive = false
self.menu.isVisible = false
self.menu.subgame.world.isActive = true
self.menu.subgame.assets.isActive = true
self.menu.subgame:flushKeys()
end
function ExitWidget:new(menu, font)
ExitWidget.super.new(self, menu, font, "exit")
end
function ExitWidget:action()
self.menu.subgame:exitLevel()
end
return PauseMenu