From e962396ee19de10d798d0caa75b9ba2a5e5cfdd4 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 20 Aug 2020 10:17:46 +0200 Subject: [PATCH] improvement: port the pause menus to the new menu system --- .../game/modules/subgames/pause.lua | 69 +++++++++---------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/sonic-radiance.love/game/modules/subgames/pause.lua b/sonic-radiance.love/game/modules/subgames/pause.lua index 17ee0c8..4adc782 100644 --- a/sonic-radiance.love/game/modules/subgames/pause.lua +++ b/sonic-radiance.love/game/modules/subgames/pause.lua @@ -1,75 +1,68 @@ local ListBox = require "core.modules.menusystem.listbox" -local PauseMenu = ListBox:extend() +local RadianceListMenu = require "game.modules.menus.list" +local PauseMenu = RadianceListMenu.ListMenu:extend() local Widget = require "core.modules.menusystem.widgets" -local ResumeWidget = Widget.Text:extend() -local RestartWidget = Widget.Text:extend() -local ExitWidget = Widget.Text:extend() +local ResumeWidget = RadianceListMenu.DualTextWidget:extend() +local RestartWidget = RadianceListMenu.DualTextWidget:extend() +local ExitWidget = RadianceListMenu.DualTextWidget:extend() local gui = require "game.modules.gui" +local WIDTH = 80 +local HEIGHT = 72 + function PauseMenu:new(subgame) - local height, width, x, y - height = 72 - width = 128 - x = 424/2 - width/2 - y = 240/2 - height/2 + local x, y + x = 424/2 - WIDTH/2 + y = 240/2 - (3*17)/2 - PauseMenu.super.new(self, subgame.menusystem, "pauseMenu", x, y, width, height, 3) - self.subgame = subgame + PauseMenu.super.new(self, subgame, "pauseMenu", x, y, WIDTH, 3, true) - self:setSound(self.subgame.assets.sfx["navigate"]) + self:setSound(self.scene.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) + ResumeWidget(subgame) + self:setCancelWidget() + RestartWidget(subgame) + ExitWidget(subgame) end --- MENU WIDGETS -function ResumeWidget:new(menu, font) - ResumeWidget.super.new(self, menu, font, "resume") +function ResumeWidget:new(scene) + ResumeWidget.super.new(self, scene, "pauseMenu", "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() + self.scene.world.isActive = true + self.scene.assets.isActive = true + self.scene:flushKeys() end -function RestartWidget:new(menu, font) - ResumeWidget.super.new(self, menu, font, "restart") +function RestartWidget:new(scene) + ResumeWidget.super.new(self, scene, "pauseMenu", "Restart", "") end function RestartWidget:action() - self.menu.subgame:restartLevel() + self.scene: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() + self.scene.world.isActive = true + self.scene.assets.isActive = true + self.scene:flushKeys() end -function ExitWidget:new(menu, font) - ExitWidget.super.new(self, menu, font, "exit") +function ExitWidget:new(scene) + ExitWidget.super.new(self, scene, "pauseMenu", "Exit", "") end function ExitWidget:action() - self.menu.subgame:exitLevel() + self.scene:exitLevel() end