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:
@@ -224,16 +224,14 @@ void Game::init(void)
|
||||
|
||||
currentmenuoption = 0;
|
||||
menuselection = "null";
|
||||
currentmenuname = "null";
|
||||
current_credits_list_index = 0;
|
||||
menuxoff = 0;
|
||||
menuyoff = 0;
|
||||
menucountdown = 0;
|
||||
menudest="null";
|
||||
levelpage=0;
|
||||
playcustomlevel=0;
|
||||
customleveltitle="";
|
||||
createmenu("mainmenu");
|
||||
createmenu(Menu::mainmenu);
|
||||
|
||||
deathcounts = 0;
|
||||
gameoverdelay = 0;
|
||||
@@ -1341,7 +1339,7 @@ void Game::updatestate()
|
||||
graphics.backgrounddrawn = false;
|
||||
map.tdrawback = true;
|
||||
graphics.flipmode = false;
|
||||
createmenu("mainmenu");
|
||||
createmenu(Menu::mainmenu);
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -1396,7 +1394,7 @@ void Game::updatestate()
|
||||
graphics.fademode = 4;
|
||||
graphics.backgrounddrawn = true;
|
||||
map.tdrawback = true;
|
||||
createmenu("timetrialcomplete");
|
||||
createmenu(Menu::timetrialcomplete);
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -2101,7 +2099,7 @@ void Game::updatestate()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
createmenu("levellist");
|
||||
createmenu(Menu::levellist);
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -3046,7 +3044,7 @@ void Game::updatestate()
|
||||
graphics.fademode = 4;
|
||||
graphics.backgrounddrawn = true;
|
||||
map.tdrawback = true;
|
||||
createmenu("play");
|
||||
createmenu(Menu::play);
|
||||
music.play(6);
|
||||
state = 0;
|
||||
break;
|
||||
@@ -3373,7 +3371,7 @@ void Game::updatestate()
|
||||
graphics.fademode = 4;
|
||||
graphics.backgrounddrawn = true;
|
||||
map.tdrawback = true;
|
||||
createmenu("nodeathmodecomplete");
|
||||
createmenu(Menu::nodeathmodecomplete);
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -6545,7 +6543,7 @@ std::string Game::timetstring( int t )
|
||||
return tempstring;
|
||||
}
|
||||
|
||||
void Game::createmenu( std::string t )
|
||||
void Game::createmenu( enum Menu::MenuName t )
|
||||
{
|
||||
currentmenuoption = 0;
|
||||
menuselection = "null";
|
||||
@@ -6553,10 +6551,9 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = 0;
|
||||
menuyoff = 0;
|
||||
menucountdown = 0;
|
||||
menudest="null";
|
||||
menuoptions.clear();
|
||||
|
||||
if (t == "mainmenu")
|
||||
if (t == Menu::mainmenu)
|
||||
{
|
||||
#if !defined(MAKEANDPLAY)
|
||||
option("start game");
|
||||
@@ -6574,7 +6571,7 @@ void Game::createmenu( std::string t )
|
||||
menuyoff = -10;
|
||||
}
|
||||
#if !defined(NO_CUSTOM_LEVELS)
|
||||
else if (t == "playerworlds")
|
||||
else if (t == Menu::playerworlds)
|
||||
{
|
||||
option("play a level");
|
||||
#if !defined(NO_EDITOR)
|
||||
@@ -6585,7 +6582,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -30;
|
||||
menuyoff = -40;
|
||||
}
|
||||
else if (t == "levellist")
|
||||
else if (t == Menu::levellist)
|
||||
{
|
||||
if(ed.ListOfMetaData.size()==0)
|
||||
{
|
||||
@@ -6648,7 +6645,7 @@ void Game::createmenu( std::string t )
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (t == "quickloadlevel")
|
||||
else if (t == Menu::quickloadlevel)
|
||||
{
|
||||
option("continue from save");
|
||||
option("start from beginning");
|
||||
@@ -6656,20 +6653,20 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -40;
|
||||
menuyoff = -30;
|
||||
}
|
||||
else if (t == "youwannaquit")
|
||||
else if (t == Menu::youwannaquit)
|
||||
{
|
||||
option("yes, quit");
|
||||
option("no, return");
|
||||
menuxoff = 0;
|
||||
menuyoff = -20;
|
||||
}
|
||||
else if (t == "errornostart")
|
||||
else if (t == Menu::errornostart)
|
||||
{
|
||||
option("ok");
|
||||
menuxoff = 0;
|
||||
menuyoff = -20;
|
||||
}
|
||||
else if (t == "graphicoptions")
|
||||
else if (t == Menu::graphicoptions)
|
||||
{
|
||||
option("toggle fullscreen");
|
||||
option("toggle letterbox");
|
||||
@@ -6680,7 +6677,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -50;
|
||||
menuyoff = 8;
|
||||
}
|
||||
else if (t == "ed_settings")
|
||||
else if (t == Menu::ed_settings)
|
||||
{
|
||||
option("change description");
|
||||
option("edit scripts");
|
||||
@@ -6692,7 +6689,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -50;
|
||||
menuyoff = -20;
|
||||
}
|
||||
else if (t == "ed_desc")
|
||||
else if (t == Menu::ed_desc)
|
||||
{
|
||||
option("change name");
|
||||
option("change author");
|
||||
@@ -6703,14 +6700,14 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -40;
|
||||
menuyoff = 6;
|
||||
}
|
||||
else if (t == "ed_music")
|
||||
else if (t == Menu::ed_music)
|
||||
{
|
||||
option("next song");
|
||||
option("back");
|
||||
menuxoff = -10;
|
||||
menuyoff = 16;
|
||||
}
|
||||
else if (t == "ed_quit")
|
||||
else if (t == Menu::ed_quit)
|
||||
{
|
||||
option("yes, save and quit");
|
||||
option("no, quit without saving");
|
||||
@@ -6718,7 +6715,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -50;
|
||||
menuyoff = 8;
|
||||
}
|
||||
else if (t == "options")
|
||||
else if (t == Menu::options)
|
||||
{
|
||||
option("accessibility options");
|
||||
#if !defined(MAKEANDPLAY)
|
||||
@@ -6735,7 +6732,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -40;
|
||||
menuyoff = 0;
|
||||
}
|
||||
else if (t == "accessibility")
|
||||
else if (t == Menu::accessibility)
|
||||
{
|
||||
option("animated backgrounds");
|
||||
option("screen effects");
|
||||
@@ -6748,7 +6745,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -85;
|
||||
menuyoff = -10;
|
||||
}
|
||||
else if(t == "controller")
|
||||
else if(t == Menu::controller)
|
||||
{
|
||||
option("analog stick sensitivity");
|
||||
option("bind flip");
|
||||
@@ -6758,28 +6755,28 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -40;
|
||||
menuyoff = 10;
|
||||
}
|
||||
else if (t == "cleardatamenu")
|
||||
else if (t == Menu::cleardatamenu)
|
||||
{
|
||||
option("no! don't delete");
|
||||
option("yes, delete everything");
|
||||
menuxoff = -30;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "setinvincibility")
|
||||
else if (t == Menu::setinvincibility)
|
||||
{
|
||||
option("no, return to options");
|
||||
option("yes, enable");
|
||||
menuxoff = -30;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "setslowdown1")
|
||||
else if (t == Menu::setslowdown1)
|
||||
{
|
||||
option("no, return to options");
|
||||
option("yes, delete saves");
|
||||
menuxoff = -30;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "setslowdown2")
|
||||
else if (t == Menu::setslowdown2)
|
||||
{
|
||||
option("normal speed");
|
||||
option("80% speed");
|
||||
@@ -6788,7 +6785,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -40;
|
||||
menuyoff = 16;
|
||||
}
|
||||
else if (t == "unlockmenu")
|
||||
else if (t == Menu::unlockmenu)
|
||||
{
|
||||
option("unlock time trials");
|
||||
option("unlock intermissions", !unlock[16]);
|
||||
@@ -6800,56 +6797,56 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -70;
|
||||
menuyoff = -20;
|
||||
}
|
||||
else if (t == "credits")
|
||||
else if (t == Menu::credits)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits2")
|
||||
else if (t == Menu::credits2)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits25")
|
||||
else if (t == Menu::credits25)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits3")
|
||||
else if (t == Menu::credits3)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits4")
|
||||
else if (t == Menu::credits4)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits5")
|
||||
else if (t == Menu::credits5)
|
||||
{
|
||||
option("next page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "credits6")
|
||||
else if (t == Menu::credits6)
|
||||
{
|
||||
option("first page");
|
||||
option("return");
|
||||
menuxoff = 20;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "play")
|
||||
else if (t == Menu::play)
|
||||
{
|
||||
//Ok, here's where the unlock stuff comes into it:
|
||||
//First up, time trials:
|
||||
@@ -6896,12 +6893,12 @@ void Game::createmenu( std::string t )
|
||||
|
||||
if (temp == 1)
|
||||
{
|
||||
createmenu("unlocktimetrial");
|
||||
createmenu(Menu::unlocktimetrial);
|
||||
savemystats = true;
|
||||
}
|
||||
else if (temp > 1)
|
||||
{
|
||||
createmenu("unlocktimetrials");
|
||||
createmenu(Menu::unlocktimetrials);
|
||||
savemystats = true;
|
||||
}
|
||||
}
|
||||
@@ -6920,7 +6917,7 @@ void Game::createmenu( std::string t )
|
||||
//Unlock No Death Mode
|
||||
unlocknotify[17] = true;
|
||||
unlock[17] = true;
|
||||
createmenu("unlocknodeathmode");
|
||||
createmenu(Menu::unlocknodeathmode);
|
||||
savemystats = true;
|
||||
}
|
||||
//Alright then! Flip mode?
|
||||
@@ -6928,7 +6925,7 @@ void Game::createmenu( std::string t )
|
||||
{
|
||||
unlock[18] = true;
|
||||
unlocknotify[18] = true;
|
||||
createmenu("unlockflipmode");
|
||||
createmenu(Menu::unlockflipmode);
|
||||
savemystats = true;
|
||||
}
|
||||
//What about the intermission levels?
|
||||
@@ -6936,7 +6933,7 @@ void Game::createmenu( std::string t )
|
||||
{
|
||||
unlock[16] = true;
|
||||
unlocknotify[16] = true;
|
||||
createmenu("unlockintermission");
|
||||
createmenu(Menu::unlockintermission);
|
||||
savemystats = true;
|
||||
}
|
||||
else
|
||||
@@ -6963,24 +6960,24 @@ void Game::createmenu( std::string t )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t == "unlocktimetrial"
|
||||
|| t == "unlocktimetrials"
|
||||
|| t == "unlocknodeathmode"
|
||||
|| t == "unlockintermission"
|
||||
|| t == "unlockflipmode")
|
||||
else if (t == Menu::unlocktimetrial
|
||||
|| t == Menu::unlocktimetrials
|
||||
|| t == Menu::unlocknodeathmode
|
||||
|| t == Menu::unlockintermission
|
||||
|| t == Menu::unlockflipmode)
|
||||
{
|
||||
option("continue");
|
||||
menuxoff = 20;
|
||||
menuyoff = 70;
|
||||
}
|
||||
else if (t == "newgamewarning")
|
||||
else if (t == Menu::newgamewarning)
|
||||
{
|
||||
option("start new game");
|
||||
option("return to menu");
|
||||
menuxoff = -30;
|
||||
menuyoff = 64;
|
||||
}
|
||||
else if (t == "playmodes")
|
||||
else if (t == Menu::playmodes)
|
||||
{
|
||||
option("time trials", !map.invincibility && game.slowdown == 30);
|
||||
option("intermissions", unlock[16]);
|
||||
@@ -6990,7 +6987,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -70;
|
||||
menuyoff = 8;
|
||||
}
|
||||
else if (t == "intermissionmenu")
|
||||
else if (t == Menu::intermissionmenu)
|
||||
{
|
||||
option("play intermission 1");
|
||||
option("play intermission 2");
|
||||
@@ -6998,7 +6995,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -50;
|
||||
menuyoff = -35;
|
||||
}
|
||||
else if (t == "playint1")
|
||||
else if (t == Menu::playint1)
|
||||
{
|
||||
option("Vitellary");
|
||||
option("Vermilion");
|
||||
@@ -7008,7 +7005,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -60;
|
||||
menuyoff = 10;
|
||||
}
|
||||
else if (t == "playint2")
|
||||
else if (t == Menu::playint2)
|
||||
{
|
||||
option("Vitellary");
|
||||
option("Vermilion");
|
||||
@@ -7018,7 +7015,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -60;
|
||||
menuyoff = 10;
|
||||
}
|
||||
else if (t == "continue")
|
||||
else if (t == Menu::continuemenu)
|
||||
{
|
||||
option("continue from teleporter");
|
||||
option("continue from quicksave");
|
||||
@@ -7026,7 +7023,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -60;
|
||||
menuyoff = 20;
|
||||
}
|
||||
else if (t == "startnodeathmode")
|
||||
else if (t == Menu::startnodeathmode)
|
||||
{
|
||||
option("disable cutscenes");
|
||||
option("enable cutscenes");
|
||||
@@ -7034,18 +7031,18 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -60;
|
||||
menuyoff = 40;
|
||||
}
|
||||
else if (t == "gameover")
|
||||
else if (t == Menu::gameover)
|
||||
{
|
||||
menucountdown = 120;
|
||||
menudest="gameover2";
|
||||
menudest=Menu::gameover2;
|
||||
}
|
||||
else if (t == "gameover2")
|
||||
else if (t == Menu::gameover2)
|
||||
{
|
||||
option("return to play menu");
|
||||
menuxoff = -25;
|
||||
menuyoff = 80;
|
||||
}
|
||||
else if (t == "unlockmenutrials")
|
||||
else if (t == Menu::unlockmenutrials)
|
||||
{
|
||||
option("space station 1", !unlock[9]);
|
||||
option("the laboratory", !unlock[10]);
|
||||
@@ -7058,7 +7055,7 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -80;
|
||||
menuyoff = 0;
|
||||
}
|
||||
else if (t == "timetrials")
|
||||
else if (t == Menu::timetrials)
|
||||
{
|
||||
option(unlock[9] ? "space station 1" : "???", unlock[9]);
|
||||
option(unlock[10] ? "the laboratory" : "???", unlock[10]);
|
||||
@@ -7071,35 +7068,35 @@ void Game::createmenu( std::string t )
|
||||
menuxoff = -80;
|
||||
menuyoff = 0;
|
||||
}
|
||||
else if (t == "nodeathmodecomplete")
|
||||
else if (t == Menu::nodeathmodecomplete)
|
||||
{
|
||||
menucountdown = 90;
|
||||
menudest = "nodeathmodecomplete2";
|
||||
menudest = Menu::nodeathmodecomplete2;
|
||||
}
|
||||
else if (t == "nodeathmodecomplete2")
|
||||
else if (t == Menu::nodeathmodecomplete2)
|
||||
{
|
||||
option("return to play menu");
|
||||
menuxoff = -25;
|
||||
menuyoff = 70;
|
||||
}
|
||||
else if (t == "timetrialcomplete")
|
||||
else if (t == Menu::timetrialcomplete)
|
||||
{
|
||||
menucountdown = 90;
|
||||
menudest="timetrialcomplete2";
|
||||
menudest=Menu::timetrialcomplete2;
|
||||
}
|
||||
else if (t == "timetrialcomplete2")
|
||||
else if (t == Menu::timetrialcomplete2)
|
||||
{
|
||||
menucountdown = 60;
|
||||
menudest="timetrialcomplete3";
|
||||
menudest=Menu::timetrialcomplete3;
|
||||
}
|
||||
else if (t == "timetrialcomplete3")
|
||||
else if (t == Menu::timetrialcomplete3)
|
||||
{
|
||||
option("return to play menu");
|
||||
option("try again");
|
||||
menuxoff = -25;
|
||||
menuyoff = 70;
|
||||
}
|
||||
else if (t == "gamecompletecontinue")
|
||||
else if (t == Menu::gamecompletecontinue)
|
||||
{
|
||||
option("return to play menu");
|
||||
menuxoff = -25;
|
||||
|
||||
Reference in New Issue
Block a user