From 0bfed0ffa011bae98be9fbfd0ae27bb8e9e399c3 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Sun, 23 Jul 2023 19:23:09 +0530 Subject: [PATCH] fix replay exit bug --- src/MarbleGame.hx | 8 +++++++- src/gui/ExitGameDlg.hx | 2 +- src/gui/MainMenuGui.hx | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 23311b46..cc4ef0db 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -52,6 +52,7 @@ class MarbleGame { var consoleShown:Bool = false; var console:ConsoleDlg; + var _exitingToMenu:Bool = false; public function new(scene2d:h2d.Scene, scene:h3d.scene.Scene) { Console.log("Initializing the game..."); @@ -284,7 +285,12 @@ class MarbleGame { #end } else { var pmg = new LevelSelectGui(LevelSelectGui.currentDifficultyStatic); - canvas.setContent(pmg); + if (_exitingToMenu) { + _exitingToMenu = false; + canvas.setContent(new MainMenuGui()); + } else { + canvas.setContent(pmg); + } } Settings.save(); diff --git a/src/gui/ExitGameDlg.hx b/src/gui/ExitGameDlg.hx index d3341e02..7e5ebe10 100644 --- a/src/gui/ExitGameDlg.hx +++ b/src/gui/ExitGameDlg.hx @@ -94,8 +94,8 @@ class ExitGameDlg extends GuiImage { btnList.addButton(4, "Main Menu", (evt) -> { MarbleGame.canvas.pushDialog(new MessageBoxYesNoDlg("Are you sure you want to exit this level? You will lose your current level progress.", () -> { + MarbleGame.instance._exitingToMenu = true; yesFunc(btnList); - MarbleGame.canvas.setContent(new MainMenuGui()); }, () -> {})); }); } diff --git a/src/gui/MainMenuGui.hx b/src/gui/MainMenuGui.hx index 711c4285..d81151b3 100644 --- a/src/gui/MainMenuGui.hx +++ b/src/gui/MainMenuGui.hx @@ -32,6 +32,8 @@ class MainMenuGui extends GuiImage { var scene2d = MarbleGame.canvas.scene2d; + MarbleGame.instance.toRecord = false; + var offsetX = (scene2d.width - 1280) / 2; var offsetY = (scene2d.height - 720) / 2;