From 44f2bae57499598daa868a3c9e931db68c2f37ff Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 15 Aug 2021 17:41:39 +0200 Subject: [PATCH] improvement: use a confirm dialog for game over Fixes #41 --- .../battlesystem/gui/screens/gameover.lua | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/gui/screens/gameover.lua b/sonic-radiance.love/scenes/battlesystem/gui/screens/gameover.lua index b07b0af..d232395 100644 --- a/sonic-radiance.love/scenes/battlesystem/gui/screens/gameover.lua +++ b/sonic-radiance.love/scenes/battlesystem/gui/screens/gameover.lua @@ -1,9 +1,10 @@ local VictoryScreen = Object:extend() local TweenManager = require "birb.classes.time" +local ConfirmDialog = require "game.modules.confirmdialog" -local BATTLECOMPLETE_START = 2 -local BATTLECOMPLETE_STOP = 4 +local defTransitions = require "birb.modules.transitions" +local radTransitions = require "game.modules.transitions" local gui = require "game.modules.gui" @@ -34,9 +35,6 @@ function VictoryScreen:setVariables() -- Infobox self.tbSize = 0.6 self.tbOpacity = 0 - - self.continue = false - self.continueValue = -1 end function VictoryScreen:prepareAnimation() @@ -50,7 +48,7 @@ function VictoryScreen:prepareAnimation() -- Infobox self.tweens:newTween(1.4, 0.4, {tbSize=1, tbOpacity=1}, 'inExpo') - self.tweens:newSwitch(1.8, {"continue"}) + self.tweens:newTimer(1.8, "continue") end function VictoryScreen:update(dt) @@ -76,8 +74,15 @@ function VictoryScreen:draw() local width, height = core.screen:getDimensions() self:drawVignette(width, height) self:drawLabel(width/2, height/4, self.labelX, self.labelOpacity) +end - self:drawContinueBox(width/2, height/2 + 32, self.continueValue, self.tbSize, self.tbOpacity) +function VictoryScreen:timerResponse(timer) + if (timer == "continue") then + local confirm = ConfirmDialog(self.scene, "Do you want to continue ?", + function() self:toOverworld() end, "Yes", + function() self:toTitleScreen() end, "No") + confirm.darken = false + end end function VictoryScreen:drawVignette(width, height) @@ -86,6 +91,17 @@ function VictoryScreen:drawVignette(width, height) love.graphics.rectangle("fill", 0, 0, width, height) end +function VictoryScreen:toOverworld() + core.screen:startTransition(radTransitions.borders, defTransitions.default, function() + game:reload() + scenes.overworld() + end, 424/2, 240/2) +end + +function VictoryScreen:toTitleScreen() + core.screen:startTransition(radTransitions.borders, radTransitions.borders, function() scenes.menus.title(false) end, 424/2, 240/2) +end + function VictoryScreen:drawLabel(x, y, x2, opacity) love.graphics.setColor(1, 1, 1, opacity) @@ -94,15 +110,4 @@ function VictoryScreen:drawLabel(x, y, x2, opacity) self.assets.images["over"]:draw(x + x2, y, 0, 1, 1, 0, h/2) end -function VictoryScreen:drawContinueBox(x, y, continueValue, size, opacity) - love.graphics.setColor(1, 1, 1, opacity) - love.graphics.draw(self.continueBox, x, y, 0, size, size, tw/2, th/2) - local text = "continue" - if (continueValue == 1) then - text = "quit" - end - self.assets.images["arrow"]:draw(x - continueValue*64, y, math.rad(-90) * continueValue, continueValue, 1, 13, 13) - self.assets.fonts["SA2font"]:print(text, x, y-13, "center") -end - return VictoryScreen