diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 99b3b445..0053a2a5 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6588,6 +6588,32 @@ void Game::returnmenu() } } +void Game::returntomenu(enum Menu::MenuName t) +{ + if (currentmenuname == t) + { + //Why are you calling this function then? + return; + } + + //Unwind the menu stack until we reach our desired menu + int i = menustack.size() - 1; + while (i >= 0) + { + //If we pop it off we can't reference it anymore, so check for it now + bool is_the_menu_we_want = menustack[i].name == t; + + returnmenu(); + + if (is_the_menu_we_want) + { + break; + } + + i--; + } +} + void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) { if (t == Menu::mainmenu) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index f16ea6db..1dbe1582 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -106,6 +106,7 @@ public: std::string timetstring(int t); void returnmenu(); + void returntomenu(enum Menu::MenuName t); void createmenu(enum Menu::MenuName t, bool samemenu = false); void lifesequence();