From e909515f3d3d47854023c0eeb0c0d9946ee5faeb Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 16 Apr 2020 21:25:30 -0700 Subject: [PATCH] Don't go to main menu when exiting to menu This also replaces some createmenu()s with returnmenu()s as needed even when said createmenu()s already didn't go to the main menu. Now when you exit the level editor, you'll be selecting the "level editor" option in "play levels", and if you exit from a level you'll still be selecting that level in the levels list. Furthermore, regardless of what you're exiting, your cursor position will be remembered. --- desktop_version/src/Game.cpp | 12 +++++++++--- desktop_version/src/Input.cpp | 11 ++++++++++- desktop_version/src/Logic.cpp | 2 +- desktop_version/src/editor.cpp | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index ba939024..02d8f996 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -1338,7 +1338,13 @@ void Game::updatestate() graphics.backgrounddrawn = false; map.tdrawback = true; graphics.flipmode = false; - createmenu(Menu::mainmenu); + //Don't be stuck on the summary screen, + //or "who do you want to play the level with?" + //or "do you want cutscenes?" + if (!intimetrial) + { + returnmenu(); + } state = 0; break; @@ -2098,7 +2104,6 @@ void Game::updatestate() } } #endif - createmenu(Menu::levellist); state = 0; break; @@ -2993,6 +2998,7 @@ void Game::updatestate() { graphics.fademode = 2; companion = 0; + returnmenu(); state=3100; } else @@ -3023,6 +3029,7 @@ void Game::updatestate() state++; graphics.fademode = 2; music.fadeout(); + returnmenu(); state=3100; } else @@ -3053,7 +3060,6 @@ void Game::updatestate() graphics.fademode = 4; graphics.backgrounddrawn = true; map.tdrawback = true; - createmenu(Menu::play); music.play(6); state = 0; break; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 92f10b9a..3853ab5a 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1191,6 +1191,15 @@ void menuactionpress() map.nexttowercolour(); break; case 1: + //Ok but first quickly remove the last stack frame to prevent piling up timetrialcomplete stack frames + if (game.menustack.empty()) + { + puts("Error: menu stack is empty!"); + } + else + { + game.menustack.pop_back(); + } //duplicate the above based on given time trial level! if (game.timetriallevel == 0) //space station 1 { @@ -1229,7 +1238,7 @@ void menuactionpress() case Menu::nodeathmodecomplete2: music.play(6); music.playef(11); - game.createmenu(Menu::play); + game.returnmenu(); map.nexttowercolour(); break; default: diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 7aa05ab4..a4111174 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -30,7 +30,7 @@ void titlelogic() { music.playef(3); } - game.createmenu(game.menudest); + game.createmenu(game.menudest, true); } } } diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index d43e4b34..3c5da840 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -3455,7 +3455,10 @@ void editorlogic() map.nexttowercolour(); ed.settingsmod=false; graphics.backgrounddrawn=false; - game.createmenu(Menu::mainmenu); + //Do returnmenu twice because we have two menus: + //the main editor menu and the confirm save&quit menu + game.returnmenu(); + game.returnmenu(); } }