From 6ac41e112c64f744e20fd1e99a5f29d29828c527 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 7 May 2020 14:38:19 -0700 Subject: [PATCH] Move quit to menu to Game::quittomenu() I don't want the quit code to only be in the state machine, but I'll keep the gamestate around for compatibility reasons (there are custom levels that directly use gamestate 80 to quit to the menu). --- desktop_version/src/Game.cpp | 81 +++++++++++++++++++----------------- desktop_version/src/Game.h | 2 + 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 5bb21223..08423e56 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -1336,44 +1336,7 @@ void Game::updatestate() if(graphics.fademode == 1) state++; break; case 81: - gamestate = TITLEMODE; - graphics.fademode = 4; - music.play(6); - graphics.backgrounddrawn = false; - map.tdrawback = true; - graphics.flipmode = false; - //Don't be stuck on the summary screen, - //or "who do you want to play the level with?" - //or "do you want cutscenes?" - //or the confirm-load-quicksave menu - if (wasintimetrial) - { - returntomenu(Menu::timetrials); - } - else if (wasinintermission) - { - returntomenu(Menu::intermissionmenu); - } - else if (wasinnodeathmode) - { - returntomenu(Menu::playmodes); - } - else if (wasincustommode) - { - returntomenu(Menu::levellist); - } - else if (save_exists() || anything_unlocked()) - { - returntomenu(Menu::play); - } - else - { - createmenu(Menu::mainmenu); - } - wasintimetrial = false; - wasinintermission = false; - wasinnodeathmode = false; - wasincustommode = false; + quittomenu(); state = 0; break; @@ -7358,3 +7321,45 @@ bool Game::save_exists() { return telesummary != "" || quicksummary != ""; } + +void Game::quittomenu() +{ + gamestate = TITLEMODE; + graphics.fademode = 4; + music.play(6); + graphics.backgrounddrawn = false; + map.tdrawback = true; + graphics.flipmode = false; + //Don't be stuck on the summary screen, + //or "who do you want to play the level with?" + //or "do you want cutscenes?" + //or the confirm-load-quicksave menu + if (wasintimetrial) + { + returntomenu(Menu::timetrials); + } + else if (wasinintermission) + { + returntomenu(Menu::intermissionmenu); + } + else if (wasinnodeathmode) + { + returntomenu(Menu::playmodes); + } + else if (wasincustommode) + { + returntomenu(Menu::levellist); + } + else if (save_exists() || anything_unlocked()) + { + returntomenu(Menu::play); + } + else + { + createmenu(Menu::mainmenu); + } + wasintimetrial = false; + wasinintermission = false; + wasinnodeathmode = false; + wasincustommode = false; +} diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 24ac3043..52bda2e5 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -385,6 +385,8 @@ public: int playrx; int playry; int playgc; + + void quittomenu(); }; extern Game game;