From de0205e09b48dd1b2ce1014a4a1711b3e458e584 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 16 Apr 2020 19:04:36 -0700 Subject: [PATCH] Push a stack frame when Game::createmenu() is called Unless it's the main menu, or unless it's not the same menu. Whether or not the menu is the same is left up to the caller, because some menus could be the same but use different names, so we can't simply automatically check that the names are different and assume that they aren't the same menu. --- desktop_version/src/Game.cpp | 17 ++++++++++++++++- desktop_version/src/Game.h | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 3ab6ee70..87c21260 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6552,8 +6552,23 @@ std::string Game::timetstring( int t ) return tempstring; } -void Game::createmenu( enum Menu::MenuName t ) +void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) { + if (t == Menu::mainmenu) + { + //Either we've just booted up the game or returned from gamemode + //Whichever it is, we shouldn't have a stack, + //and most likely don't have a current stackframe + menustack.clear(); + } + else if (!samemenu) + { + MenuStackFrame frame; + frame.option = currentmenuoption; + frame.name = currentmenuname; + menustack.push_back(frame); + } + currentmenuoption = 0; currentmenuname = t; menuxoff = 0; diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 5a372991..7a604339 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -115,7 +115,7 @@ public: std::string timetstring(int t); - void createmenu(enum Menu::MenuName t); + void createmenu(enum Menu::MenuName t, bool samemenu = false); void lifesequence();