From 9fca3e111f187cd5fcefa46f1ccc1f389f216db9 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 25 Apr 2020 19:21:23 -0700 Subject: [PATCH] Improve quit-to-menu menu handling This stabilizes the code that handles the menu that you land on if you press Esc and quit to the menu. Instead of using Game::returnmenu(), we now use the new function Game::returntomenu() to clearly express intent that we want to return to a specific menu. So I've added another kludge variable Game::wasinintermission for the was-in-intermission case. Also, I made it so that if you didn't have a main game telesave or quicksave, you just get brought back to the main menu. Because you shouldn't be able to go to the play menu without a quicksave or telesave. --- desktop_version/src/Game.cpp | 21 +++++++++++++++++++-- desktop_version/src/Game.h | 1 + desktop_version/src/Input.cpp | 1 + desktop_version/src/editor.cpp | 5 +---- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 0053a2a5..47810dd1 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -1345,11 +1345,28 @@ void Game::updatestate() //or "who do you want to play the level with?" //or "do you want cutscenes?" //or the confirm-load-quicksave menu - if ((!wasintimetrial && !wasincustommode) || currentmenuname == Menu::quickloadlevel) + if (wasintimetrial) { - returnmenu(); + returntomenu(Menu::timetrials); + } + else if (wasinintermission) + { + returntomenu(Menu::intermissionmenu); + } + else if (wasincustommode) + { + returntomenu(Menu::levellist); + } + else if (game.telesummary != "" || game.quicksummary != "") + { + returntomenu(Menu::play); + } + else + { + createmenu(Menu::mainmenu); } wasintimetrial = false; + wasinintermission = false; wasincustommode = false; state = 0; break; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 1dbe1582..d69a813c 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -236,6 +236,7 @@ public: //Menu kludge... bool wasintimetrial; + bool wasinintermission; bool wasincustommode; diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 39c00b8e..7b79c583 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1961,6 +1961,7 @@ void mapinput() FillRect(graphics.tempBuffer, 0x000000); if (game.intimetrial || game.insecretlab || game.nodeathmode) game.menukludge = true; game.wasintimetrial = game.intimetrial; + game.wasinintermission = game.inintermission; game.wasincustommode = map.custommode; script.hardreset(); if(graphics.setflipmode) graphics.flipmode = true; diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 92c92f67..4dcbb2ac 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -3471,10 +3471,7 @@ void editorlogic() map.nexttowercolour(); ed.settingsmod=false; graphics.backgrounddrawn=false; - //Do returnmenu twice because we have two menus: - //the main editor menu and the confirm save&quit menu - game.returnmenu(); - game.returnmenu(); + game.returntomenu(Menu::playerworlds); } }