1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Add function Game::returntomenu()

When exiting from a game-gamestate which may have been entered through a
varying amount of menus, the solution is to not use Game::returnmenu(),
and to instead have a way to go back to a certain given menu.
This commit is contained in:
Misa 2020-04-25 17:36:36 -07:00 committed by Ethan Lee
parent a60cdb3ab7
commit 536184f394
2 changed files with 27 additions and 0 deletions

View file

@ -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*/ ) void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
{ {
if (t == Menu::mainmenu) if (t == Menu::mainmenu)

View file

@ -106,6 +106,7 @@ public:
std::string timetstring(int t); std::string timetstring(int t);
void returnmenu(); void returnmenu();
void returntomenu(enum Menu::MenuName t);
void createmenu(enum Menu::MenuName t, bool samemenu = false); void createmenu(enum Menu::MenuName t, bool samemenu = false);
void lifesequence(); void lifesequence();