mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Convert menu names to be an enum instead of being stringly-typed
Stringly-typed things are bad, because if you make a typo when typing out a string, it's not caught at compile-time. And in the case of this menu system, you'd have to do an excessive amount of testing to uncover any bugs caused by a typo. Why do that when you can just use an enum and catch compile-time errors instead? Also, you can't use switch-case statements on stringly-typed variables. So every menu name is now in the enum Menu::MenuName, but you can simply refer to a menu name by just prefixing it with Menu::. Unfortunately, I've had to change the "continue" menu name to be "continuemenu", because "continue" is a keyword in C and C++. Also, it looks like "timetrialcomplete4" is an unused menu name, even though it was referenced in Render.cpp.
This commit is contained in:
@@ -18,15 +18,15 @@ void titlelogic()
|
||||
game.menucountdown--;
|
||||
if (game.menucountdown == 0)
|
||||
{
|
||||
if (game.menudest == "mainmenu")
|
||||
if (game.menudest == Menu::mainmenu)
|
||||
{
|
||||
music.play(6);
|
||||
}
|
||||
else if (game.menudest == "gameover2")
|
||||
else if (game.menudest == Menu::gameover2)
|
||||
{
|
||||
music.playef(11);
|
||||
}
|
||||
else if (game.menudest == "timetrialcomplete3")
|
||||
else if (game.menudest == Menu::timetrialcomplete3)
|
||||
{
|
||||
music.playef(3);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void gamecompletelogic2()
|
||||
game.gamestate = 1;
|
||||
graphics.fademode = 4;
|
||||
music.playef(18);
|
||||
game.createmenu("gamecompletecontinue");
|
||||
game.createmenu(Menu::gamecompletecontinue);
|
||||
map.nexttowercolour();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user