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

Refactor menu creation code

Firstly, menu options are no longer ad-hoc objects, and are added by
using Game::option() (this is the biggest change). This removes the
vector Game::menuoptionsactive, and Game::menuoptions is now a vector of
MenuOption instead of std::string.

Secondly, the manual tracker variable of the amount of menu options,
Game::nummenuoptions, has been removed, in favor of using vectors
properly and using Game::menuoptions::size().

As a result, a lot of copy-pasted code has been removed from
Game::createmenu(), mostly due to having to have different versions of
menus depending on whether or not we have certain defines, or having an
mmmmmm.vvv file inside the VVVVVV directory. In the old days, you
couldn't just add or remove a menu option conveniently, you had to
shuffle around the position of every other menu option too, which
resulted in lots of copy-pasted code. But now this copy-pasted code has
been de-duplicated, at least in Game::createmenu().
This commit is contained in:
Misa 2020-04-14 21:50:17 -07:00 committed by Ethan Lee
parent a0d2be6362
commit 511de0c5c1
6 changed files with 209 additions and 630 deletions

View file

@ -219,12 +219,9 @@ void Game::init(void)
quick_currentarea = "Error! Error!"; quick_currentarea = "Error! Error!";
//Menu stuff initiliased here: //Menu stuff initiliased here:
menuoptions.resize(25);
menuoptionsactive.resize(25);
unlock.resize(25); unlock.resize(25);
unlocknotify.resize(25); unlocknotify.resize(25);
nummenuoptions = 0;
currentmenuoption = 0; currentmenuoption = 0;
menuselection = "null"; menuselection = "null";
currentmenuname = "null"; currentmenuname = "null";
@ -6557,93 +6554,47 @@ void Game::createmenu( std::string t )
menuyoff = 0; menuyoff = 0;
menucountdown = 0; menucountdown = 0;
menudest="null"; menudest="null";
menuoptions.clear();
if (t == "mainmenu") if (t == "mainmenu")
{ {
#if defined(MAKEANDPLAY) #if !defined(MAKEANDPLAY)
menuoptions[0] = "player levels"; option("start game");
menuoptionsactive[0] = true;
menuoptions[1] = "graphic options";
menuoptionsactive[1] = true;
menuoptions[2] = "game options";
menuoptionsactive[2] = true;
menuoptions[3] = "quit game";
menuoptionsactive[3] = true;
nummenuoptions = 4;
menuxoff = -16;
menuyoff = -10;
#elif !defined(MAKEANDPLAY)
#if defined(NO_CUSTOM_LEVELS)
menuoptions[0] = "start game";
menuoptionsactive[0] = true;
menuoptions[1] = "graphic options";
menuoptionsactive[1] = true;
menuoptions[2] = "game options";
menuoptionsactive[2] = true;
menuoptions[3] = "view credits";
menuoptionsactive[3] = true;
menuoptions[4] = "quit game";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -16;
menuyoff = -10;
#else
menuoptions[0] = "start game";
menuoptionsactive[0] = true;
menuoptions[1] = "player levels";
menuoptionsactive[1] = true;
menuoptions[2] = "graphic options";
menuoptionsactive[2] = true;
menuoptions[3] = "game options";
menuoptionsactive[3] = true;
menuoptions[4] = "view credits";
menuoptionsactive[4] = true;
menuoptions[5] = "quit game";
menuoptionsactive[5] = true;
nummenuoptions = 6;
menuxoff = -16;
menuyoff = -10;
#endif
#endif #endif
#if !defined(NO_CUSTOM_LEVELS)
option("player levels");
#endif
option("graphic options");
option("game options");
#if !defined(MAKEANDPLAY)
option("view credits");
#endif
option("quit game");
menuxoff = -16;
menuyoff = -10;
} }
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
else if (t == "playerworlds") else if (t == "playerworlds")
{ {
option("play a level");
#if !defined(NO_EDITOR) #if !defined(NO_EDITOR)
menuoptions[0] = "play a level"; option("level editor");
menuoptionsactive[0] = true;
menuoptions[1] = "level editor";
menuoptionsactive[1] = true;
//menuoptions[2] = "open level folder";
//menuoptionsactive[2] = true;
menuoptions[2] = "back to menu";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -30;
menuyoff = -40;
#else
menuoptions[0] = "play a level";
menuoptionsactive[0] = true;
menuoptions[1] = "back to menu";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -30;
menuyoff = -40;
#endif #endif
//option("open level folder");
option("back to menu");
menuxoff = -30;
menuyoff = -40;
} }
else if (t == "levellist") else if (t == "levellist")
{ {
if(ed.ListOfMetaData.size()==0) if(ed.ListOfMetaData.size()==0)
{ {
menuoptions[0] = "ok"; option("ok");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 0; menuxoff = 0;
menuyoff = -20; menuyoff = -20;
} }
else else
{ {
int tcount=0;
for(int i=0; i<(int) ed.ListOfMetaData.size(); i++) // FIXME: int/size_t! -flibit for(int i=0; i<(int) ed.ListOfMetaData.size(); i++) // FIXME: int/size_t! -flibit
{ {
if(i>=levelpage*8 && i< (levelpage*8)+8) if(i>=levelpage*8 && i< (levelpage*8)+8)
@ -6658,97 +6609,74 @@ void Game::createmenu( std::string t )
j=numcustomlevelstats+1; j=numcustomlevelstats+1;
} }
} }
std::string text;
if(tvar>=0) if(tvar>=0)
{ {
if(customlevelscore[tvar]==0) if(customlevelscore[tvar]==0)
{ {
menuoptions[tcount] = " " + ed.ListOfMetaData[i].title; text = " " + ed.ListOfMetaData[i].title;
} }
else if(customlevelscore[tvar]==1) else if(customlevelscore[tvar]==1)
{ {
menuoptions[tcount] = " * " + ed.ListOfMetaData[i].title; text = " * " + ed.ListOfMetaData[i].title;
} }
else if(customlevelscore[tvar]==3) else if(customlevelscore[tvar]==3)
{ {
menuoptions[tcount] = "** " + ed.ListOfMetaData[i].title; text = "** " + ed.ListOfMetaData[i].title;
} }
} }
else else
{ {
menuoptions[tcount] = " " + ed.ListOfMetaData[i].title; text = " " + ed.ListOfMetaData[i].title;
} }
menuoptionsactive[tcount] = true; std::transform(text.begin(), text.end(), text.begin(), ::tolower);
std::transform(menuoptions[tcount].begin(), menuoptions[tcount].end(), menuoptions[tcount].begin(), ::tolower); option(text);
tcount++;
} }
} }
if((size_t) ((levelpage*8)+8) <ed.ListOfMetaData.size()) if((size_t) ((levelpage*8)+8) <ed.ListOfMetaData.size())
{ {
menuoptions[tcount] = "next page"; option("next page");
menuoptionsactive[tcount] = true;
tcount++;
} }
else else
{ {
menuoptions[tcount] = "first page"; option("first page");
menuoptionsactive[tcount] = true;
tcount++;
} }
menuoptions[tcount] = "return to menu"; option("return to menu");
menuoptionsactive[tcount] = true;
tcount++;
nummenuoptions = tcount;
menuxoff = -90; menuxoff = -90;
menuyoff = 70-(tcount*10); menuyoff = 70-(menuoptions.size()*10);
} }
} }
#endif #endif
else if (t == "quickloadlevel") else if (t == "quickloadlevel")
{ {
menuoptions[0] = "continue from save"; option("continue from save");
menuoptionsactive[0] = true; option("start from beginning");
menuoptions[1] = "start from beginning"; option("back to levels");
menuoptionsactive[1] = true;
menuoptions[2] = "back to levels";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -40; menuxoff = -40;
menuyoff = -30; menuyoff = -30;
} }
else if (t == "youwannaquit") else if (t == "youwannaquit")
{ {
menuoptions[0] = "yes, quit"; option("yes, quit");
menuoptionsactive[0] = true; option("no, return");
menuoptions[1] = "no, return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 0; menuxoff = 0;
menuyoff = -20; menuyoff = -20;
} }
else if (t == "errornostart") else if (t == "errornostart")
{ {
menuoptions[0] = "ok"; option("ok");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 0; menuxoff = 0;
menuyoff = -20; menuyoff = -20;
} }
else if (t == "graphicoptions") else if (t == "graphicoptions")
{ {
menuoptions[0] = "toggle fullscreen"; option("toggle fullscreen");
menuoptionsactive[0] = true; option("toggle letterbox");
menuoptions[1] = "toggle letterbox"; option("toggle filter");
menuoptionsactive[1] = true; option("toggle analogue");
menuoptions[2] = "toggle filter"; option("toggle mouse");
menuoptionsactive[2] = true; option("return");
menuoptions[3] = "toggle analogue";
menuoptionsactive[3] = true;
menuoptions[4] = "toggle mouse";
menuoptionsactive[4] = true;
menuoptions[5] = "return";
menuoptionsactive[5] = true;
nummenuoptions = 6;
menuxoff = -50; menuxoff = -50;
menuyoff = 8; menuyoff = 8;
/* Old stuff, not used anymore /* Old stuff, not used anymore
@ -6808,262 +6736,170 @@ void Game::createmenu( std::string t )
} }
else if (t == "ed_settings") else if (t == "ed_settings")
{ {
menuoptions[0] = "change description"; option("change description");
menuoptionsactive[0] = true; option("edit scripts");
menuoptions[1] = "edit scripts"; option("change music");
menuoptionsactive[1] = true; option("load level");
menuoptions[2] = "change music"; option("save level");
menuoptionsactive[2] = true; option("quit to main menu");
menuoptions[3] = "load level";
menuoptionsactive[3] = true;
menuoptions[4] = "save level";
menuoptionsactive[4] = true;
menuoptions[5] = "quit to main menu";
menuoptionsactive[5] = true;
nummenuoptions = 6;
menuxoff = -50; menuxoff = -50;
menuyoff = -20; menuyoff = -20;
} }
else if (t == "ed_desc") else if (t == "ed_desc")
{ {
menuoptions[0] = "change name"; option("change name");
menuoptionsactive[0] = true; option("change author");
menuoptions[1] = "change author"; option("change description");
menuoptionsactive[1] = true; option("change website");
menuoptions[2] = "change description"; option("back to settings");
menuoptionsactive[2] = true;
menuoptions[3] = "change website";
menuoptionsactive[3] = true;
menuoptions[4] = "back to settings";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -40; menuxoff = -40;
menuyoff = 6; menuyoff = 6;
} }
else if (t == "ed_music") else if (t == "ed_music")
{ {
menuoptions[0] = "next song"; option("next song");
menuoptionsactive[0] = true; option("back");
menuoptions[1] = "back";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -10; menuxoff = -10;
menuyoff = 16; menuyoff = 16;
} }
else if (t == "ed_quit") else if (t == "ed_quit")
{ {
menuoptions[0] = "yes, save and quit"; option("yes, save and quit");
menuoptionsactive[0] = true; option("no, quit without saving");
menuoptions[1] = "no, quit without saving"; option("return to editor");
menuoptionsactive[1] = true;
menuoptions[2] = "return to editor";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -50; menuxoff = -50;
menuyoff = 8; menuyoff = 8;
} }
else if (t == "options") else if (t == "options")
{ {
#if defined(MAKEANDPLAY) option("accessibility options");
menuoptions[0] = "accessibility options"; #if !defined(MAKEANDPLAY)
menuoptionsactive[0] = true; option("unlock play modes");
menuoptions[1] = "game pad options";
menuoptionsactive[1] = true;
menuoptions[2] = "clear data";
menuoptionsactive[2] = true;
menuoptions[3] = "return";
menuoptionsactive[3] = true;
nummenuoptions = 4;
menuxoff = -40;
menuyoff = 0;
#elif !defined(MAKEANDPLAY)
menuoptions[0] = "accessibility options";
menuoptionsactive[0] = true;
menuoptions[1] = "unlock play modes";
menuoptionsactive[1] = true;
menuoptions[2] = "game pad options";
menuoptionsactive[2] = true;
menuoptions[3] = "clear data";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -40;
menuyoff = 0;
#endif #endif
option("game pad options");
option("clear data");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
option("soundtrack");
}
option("return");
menuxoff = -40;
menuyoff = 0;
} }
else if (t == "accessibility") else if (t == "accessibility")
{ {
menuoptions[0] = "animated backgrounds"; option("animated backgrounds");
menuoptionsactive[0] = true; option("screen effects");
menuoptions[1] = "screen effects"; option("text outline");
menuoptionsactive[1] = true; option("invincibility");
menuoptions[2] = "text outline"; option("slowdown");
menuoptionsactive[2] = true; option("load screen");
menuoptions[3] = "invincibility"; option("room name bg");
menuoptionsactive[3] = true; option("return");
menuoptions[4] = "slowdown";
menuoptionsactive[4] = true;
menuoptions[5] = "load screen";
menuoptionsactive[5] = true;
menuoptions[6] = "room name bg";
menuoptionsactive[6] = true;
menuoptions[7] = "return";
menuoptionsactive[7] = true;
nummenuoptions = 8;
menuxoff = -85; menuxoff = -85;
menuyoff = -10; menuyoff = -10;
} }
else if(t == "controller") else if(t == "controller")
{ {
menuoptions[0] = "analog stick sensitivity"; option("analog stick sensitivity");
menuoptionsactive[0] = true; option("bind flip");
menuoptions[1] = "bind flip"; option("bind enter");
menuoptionsactive[1] = true; option("bind menu");
menuoptions[2] = "bind enter"; option("return");
menuoptionsactive[2] = true;
menuoptions[3] = "bind menu";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -40; menuxoff = -40;
menuyoff = 10; menuyoff = 10;
} }
else if (t == "cleardatamenu") else if (t == "cleardatamenu")
{ {
menuoptions[0] = "no! don't delete"; option("no! don't delete");
menuoptionsactive[0] = true; option("yes, delete everything");
menuoptions[1] = "yes, delete everything";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -30; menuxoff = -30;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "setinvincibility") else if (t == "setinvincibility")
{ {
menuoptions[0] = "no, return to options"; option("no, return to options");
menuoptionsactive[0] = true; option("yes, enable");
menuoptions[1] = "yes, enable";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -30; menuxoff = -30;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "setslowdown1") else if (t == "setslowdown1")
{ {
menuoptions[0] = "no, return to options"; option("no, return to options");
menuoptionsactive[0] = true; option("yes, delete saves");
menuoptions[1] = "yes, delete saves";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -30; menuxoff = -30;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "setslowdown2") else if (t == "setslowdown2")
{ {
menuoptions[0] = "normal speed"; option("normal speed");
menuoptionsactive[0] = true; option("80% speed");
menuoptions[1] = "80% speed"; option("60% speed");
menuoptionsactive[1] = true; option("40% speed");
menuoptions[2] = "60% speed";
menuoptionsactive[2] = true;
menuoptions[3] = "40% speed";
menuoptionsactive[3] = true;
nummenuoptions = 4;
menuxoff = -40; menuxoff = -40;
menuyoff = 16; menuyoff = 16;
} }
else if (t == "unlockmenu") else if (t == "unlockmenu")
{ {
menuoptions[0] = "unlock time trials"; option("unlock time trials");
menuoptionsactive[0] = true; option("unlock intermissions", !unlock[16]);
menuoptions[1] = "unlock intermissions"; option("unlock no death mode", !unlock[17]);
menuoptionsactive[1] = !unlock[16]; option("unlock flip mode", !unlock[18]);
menuoptions[2] = "unlock no death mode"; option("unlock ship jukebox", (stat_trinkets<20));
menuoptionsactive[2] = !unlock[17]; option("unlock secret lab", !unlock[8]);
menuoptions[3] = "unlock flip mode"; option("return");
menuoptionsactive[3] = !unlock[18];
menuoptions[4] = "unlock ship jukebox";
menuoptionsactive[4] = (stat_trinkets<20);
menuoptions[5] = "unlock secret lab";
menuoptionsactive[5] = !unlock[8];
menuoptions[6] = "return";
menuoptionsactive[6] = true;
nummenuoptions = 7;
menuxoff = -70; menuxoff = -70;
menuyoff = -20; menuyoff = -20;
} }
else if (t == "credits") else if (t == "credits")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits2") else if (t == "credits2")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits25") else if (t == "credits25")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits3") else if (t == "credits3")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits4") else if (t == "credits4")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits5") else if (t == "credits5")
{ {
menuoptions[0] = "next page"; option("next page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "credits6") else if (t == "credits6")
{ {
menuoptions[0] = "first page"; option("first page");
menuoptionsactive[0] = true; option("return");
menuoptions[1] = "return";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = 20; menuxoff = 20;
menuyoff = 64; menuyoff = 64;
} }
@ -7170,15 +7006,10 @@ void Game::createmenu( std::string t )
} }
else else
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true; option("play modes");
menuoptions[1] = "play modes"; option("new game");
menuoptionsactive[1] = true; option("return");
menuoptions[2] = "new game";
menuoptionsactive[2] = true;
menuoptions[3] = "return";
menuoptionsactive[3] = true;
nummenuoptions = 4;
menuxoff = -20; menuxoff = -20;
menuyoff = -40; menuyoff = -40;
} }
@ -7189,339 +7020,167 @@ void Game::createmenu( std::string t )
} }
else if (t == "unlocktimetrial" || t == "unlocktimetrials") else if (t == "unlocktimetrial" || t == "unlocktimetrials")
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 20; menuxoff = 20;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "unlocknodeathmode") else if (t == "unlocknodeathmode")
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 20; menuxoff = 20;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "unlockintermission") else if (t == "unlockintermission")
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 20; menuxoff = 20;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "unlockflipmode") else if (t == "unlockflipmode")
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = 20; menuxoff = 20;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "playsecretlab") else if (t == "playsecretlab")
{ {
menuoptions[0] = "continue"; option("continue");
menuoptionsactive[0] = true; option("secret lab");
menuoptions[1] = "secret lab"; option("play modes");
menuoptionsactive[1] = true; option("new game");
menuoptions[2] = "play modes"; option("return");
menuoptionsactive[2] = true;
menuoptions[3] = "new game";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -40; menuxoff = -40;
menuyoff = -30; menuyoff = -30;
} }
else if (t == "newgamewarning") else if (t == "newgamewarning")
{ {
menuoptions[0] = "start new game"; option("start new game");
menuoptionsactive[0] = true; option("return to menu");
menuoptions[1] = "return to menu";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -30; menuxoff = -30;
menuyoff = 64; menuyoff = 64;
} }
else if (t == "playmodes") else if (t == "playmodes")
{ {
menuoptions[0] = "time trials"; option("time trials");
menuoptionsactive[0] = true; option("intermissions", unlock[16]);
menuoptions[1] = "intermissions"; option("no death mode", unlock[17]);
menuoptionsactive[1] = unlock[16]; option("flip mode", unlock[18]);
menuoptions[2] = "no death mode"; option("return to play menu");
menuoptionsactive[2] = unlock[17];
menuoptions[3] = "flip mode";
menuoptionsactive[3] = unlock[18];
menuoptions[4] = "return to play menu";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -70; menuxoff = -70;
menuyoff = 8; menuyoff = 8;
} }
else if (t == "intermissionmenu") else if (t == "intermissionmenu")
{ {
menuoptions[0] = "play intermission 1"; option("play intermission 1");
menuoptionsactive[0] = true; option("play intermission 2");
menuoptions[1] = "play intermission 2"; option("return to play menu");
menuoptionsactive[1] = true;
menuoptions[2] = "return to play menu";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -50; menuxoff = -50;
menuyoff = -35; menuyoff = -35;
} }
else if (t == "playint1") else if (t == "playint1")
{ {
menuoptions[0] = "Vitellary"; option("Vitellary");
menuoptionsactive[0] = true; option("Vermilion");
menuoptions[1] = "Vermilion"; option("Verdigris");
menuoptionsactive[1] = true; option("Victoria");
menuoptions[2] = "Verdigris"; option("return");
menuoptionsactive[2] = true;
menuoptions[3] = "Victoria";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -60; menuxoff = -60;
menuyoff = 10; menuyoff = 10;
} }
else if (t == "playint2") else if (t == "playint2")
{ {
menuoptions[0] = "Vitellary"; option("Vitellary");
menuoptionsactive[0] = true; option("Vermilion");
menuoptions[1] = "Vermilion"; option("Verdigris");
menuoptionsactive[1] = true; option("Victoria");
menuoptions[2] = "Verdigris"; option("return");
menuoptionsactive[2] = true;
menuoptions[3] = "Victoria";
menuoptionsactive[3] = true;
menuoptions[4] = "return";
menuoptionsactive[4] = true;
nummenuoptions = 5;
menuxoff = -60; menuxoff = -60;
menuyoff = 10; menuyoff = 10;
} }
else if (t == "continue") else if (t == "continue")
{ {
menuoptions[0] = "continue from teleporter"; option("continue from teleporter");
menuoptionsactive[0] = true; option("continue from quicksave");
menuoptions[1] = "continue from quicksave"; option("return to play menu");
menuoptionsactive[1] = true;
menuoptions[2] = "return to play menu";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -60; menuxoff = -60;
menuyoff = 20; menuyoff = 20;
} }
else if (t == "startnodeathmode") else if (t == "startnodeathmode")
{ {
menuoptions[0] = "disable cutscenes"; option("disable cutscenes");
menuoptionsactive[0] = true; option("enable cutscenes");
menuoptions[1] = "enable cutscenes"; option("return to play menu");
menuoptionsactive[1] = true;
menuoptions[2] = "return to play menu";
menuoptionsactive[2] = true;
nummenuoptions = 3;
menuxoff = -60; menuxoff = -60;
menuyoff = 40; menuyoff = 40;
} }
else if (t == "gameover") else if (t == "gameover")
{ {
nummenuoptions = 0;
menucountdown = 120; menucountdown = 120;
menudest="gameover2"; menudest="gameover2";
} }
else if (t == "gameover2") else if (t == "gameover2")
{ {
menuoptions[0] = "return to play menu"; option("return to play menu");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = -25; menuxoff = -25;
menuyoff = 80; menuyoff = 80;
} }
else if (t == "unlockmenutrials") else if (t == "unlockmenutrials")
{ {
if (unlock[9]) option("space station 1", !unlock[9]);
{ option("the laboratory", !unlock[10]);
menuoptions[0] = "space station 1"; option("the tower", !unlock[11]);
menuoptionsactive[0] = false; option("space station 2", !unlock[12]);
} option("the warp zone", !unlock[13]);
else option("the final level", !unlock[14]);
{
menuoptions[0] = "space station 1";
menuoptionsactive[0] = true;
}
if (unlock[10])
{
menuoptions[1] = "the laboratory";
menuoptionsactive[1] = false;
}
else
{
menuoptions[1] = "the laboratory";
menuoptionsactive[1] = true;
}
if (unlock[11])
{
menuoptions[2] = "the tower";
menuoptionsactive[2] = false;
}
else
{
menuoptions[2] = "the tower";
menuoptionsactive[2] = true;
}
if (unlock[12])
{
menuoptions[3] = "space station 2";
menuoptionsactive[3] = false;
}
else
{
menuoptions[3] = "space station 2";
menuoptionsactive[3] = true;
}
if (unlock[13])
{
menuoptions[4] = "the warp zone";
menuoptionsactive[4] = false;
}
else
{
menuoptions[4] = "the warp zone";
menuoptionsactive[4] = true;
}
if (unlock[14])
{
menuoptions[5] = "the final level";
menuoptionsactive[5] = false;
}
else
{
menuoptions[5] = "the final level";
menuoptionsactive[5] = true;
}
menuoptions[6] = "return to unlock menu"; option("return to unlock menu");
menuoptionsactive[6] = true;
nummenuoptions = 7;
menuxoff = -80; menuxoff = -80;
menuyoff = 0; menuyoff = 0;
} }
else if (t == "timetrials") else if (t == "timetrials")
{ {
if (!unlock[9]) option(unlock[9] ? "space station 1" : "???", unlock[9]);
{ option(unlock[10] ? "the laboratory" : "???", unlock[10]);
menuoptions[0] = "???"; option(unlock[11] ? "the tower" : "???", unlock[11]);
menuoptionsactive[0] = false; option(unlock[12] ? "space station 2" : "???", unlock[12]);
} option(unlock[13] ? "the warp zone" : "???", unlock[13]);
else option(unlock[14] ? "the final level" : "???", unlock[14]);
{
menuoptions[0] = "space station 1";
menuoptionsactive[0] = true;
}
if (!unlock[10])
{
menuoptions[1] = "???";
menuoptionsactive[1] = false;
}
else
{
menuoptions[1] = "the laboratory";
menuoptionsactive[1] = true;
}
if (!unlock[11])
{
menuoptions[2] = "???";
menuoptionsactive[2] = false;
}
else
{
menuoptions[2] = "the tower";
menuoptionsactive[2] = true;
}
if (!unlock[12])
{
menuoptions[3] = "???";
menuoptionsactive[3] = false;
}
else
{
menuoptions[3] = "space station 2";
menuoptionsactive[3] = true;
}
if (!unlock[13])
{
menuoptions[4] = "???";
menuoptionsactive[4] = false;
}
else
{
menuoptions[4] = "the warp zone";
menuoptionsactive[4] = true;
}
if (!unlock[14])
{
menuoptions[5] = "???";
menuoptionsactive[5] = false;
}
else
{
menuoptions[5] = "the final level";
menuoptionsactive[5] = true;
}
menuoptions[6] = "return to play menu"; option("return to play menu");
menuoptionsactive[6] = true;
nummenuoptions = 7;
menuxoff = -80; menuxoff = -80;
menuyoff = 0; menuyoff = 0;
} }
else if (t == "nodeathmodecomplete") else if (t == "nodeathmodecomplete")
{ {
nummenuoptions = 0;
menucountdown = 90; menucountdown = 90;
menudest = "nodeathmodecomplete2"; menudest = "nodeathmodecomplete2";
} }
else if (t == "nodeathmodecomplete2") else if (t == "nodeathmodecomplete2")
{ {
menuoptions[0] = "return to play menu"; option("return to play menu");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = -25; menuxoff = -25;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "timetrialcomplete") else if (t == "timetrialcomplete")
{ {
nummenuoptions = 0;
menucountdown = 90; menucountdown = 90;
menudest="timetrialcomplete2"; menudest="timetrialcomplete2";
} }
else if (t == "timetrialcomplete2") else if (t == "timetrialcomplete2")
{ {
nummenuoptions = 0;
menucountdown = 60; menucountdown = 60;
menudest="timetrialcomplete3"; menudest="timetrialcomplete3";
} }
else if (t == "timetrialcomplete3") else if (t == "timetrialcomplete3")
{ {
menuoptions[0] = "return to play menu"; option("return to play menu");
menuoptionsactive[0] = true; option("try again");
menuoptions[1] = "try again";
menuoptionsactive[1] = true;
nummenuoptions = 2;
menuxoff = -25; menuxoff = -25;
menuyoff = 70; menuyoff = 70;
} }
else if (t == "gamecompletecontinue") else if (t == "gamecompletecontinue")
{ {
menuoptions[0] = "return to play menu"; option("return to play menu");
menuoptionsactive[0] = true;
nummenuoptions = 1;
menuxoff = -25; menuxoff = -25;
menuyoff = 70; menuyoff = 70;
} }

View file

@ -162,9 +162,8 @@ public:
int teleport_to_teleporter; int teleport_to_teleporter;
//Main Menu Variables //Main Menu Variables
std::vector<std::string> menuoptions; std::vector<MenuOption> menuoptions;
std::vector<bool> menuoptionsactive; int currentmenuoption ;
int nummenuoptions, currentmenuoption ;
std::string menuselection, currentmenuname, previousmenuname; std::string menuselection, currentmenuname, previousmenuname;
int current_credits_list_index; int current_credits_list_index;
int menuxoff, menuyoff; int menuxoff, menuyoff;

View file

@ -1087,21 +1087,21 @@ void Graphics::processfade()
void Graphics::drawmenu( int cr, int cg, int cb, int division /*= 30*/ ) void Graphics::drawmenu( int cr, int cg, int cb, int division /*= 30*/ )
{ {
for (int i = 0; i < game.nummenuoptions; i++) for (size_t i = 0; i < game.menuoptions.size(); i++)
{ {
if (i == game.currentmenuoption) if ((int) i == game.currentmenuoption)
{ {
//Draw it highlighted //Draw it highlighted
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper); std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper);
tempstring = std::string("[ ") + tempstring + std::string(" ]"); tempstring = std::string("[ ") + tempstring + std::string(" ]");
Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb); Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb);
} }
else else
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
tempstring = "[ " + tempstring + " ]"; tempstring = "[ " + tempstring + " ]";
//Draw it in gray //Draw it in gray
Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128); Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128);
@ -1110,14 +1110,14 @@ void Graphics::drawmenu( int cr, int cg, int cb, int division /*= 30*/ )
else else
{ {
//Draw it normally //Draw it normally
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i], cr, cg, cb); Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, cr, cg, cb);
} }
else else
{ {
//Draw it in gray //Draw it in gray
Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i], 128, 128, 128); Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, 128, 128, 128);
} }
} }
} }
@ -1125,38 +1125,38 @@ void Graphics::drawmenu( int cr, int cg, int cb, int division /*= 30*/ )
void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ ) void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ )
{ {
for (int i = 0; i < game.nummenuoptions; i++) for (size_t i = 0; i < game.menuoptions.size(); i++)
{ {
if (i == game.currentmenuoption) if ((int) i == game.currentmenuoption)
{ {
if(game.nummenuoptions-i<=2){ if(game.menuoptions.size()-i<=2){
//Draw it highlighted //Draw it highlighted
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper); std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper);
tempstring = std::string("[ ") + tempstring + std::string(" ]"); tempstring = std::string("[ ") + tempstring + std::string(" ]");
Print(110 + (i * division) - 16 +game.menuxoff, 140+8 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb); Print(110 + (i * division) - 16 +game.menuxoff, 140+8 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb);
} }
else else
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
tempstring = "[ " + tempstring + " ]"; tempstring = "[ " + tempstring + " ]";
//Draw it in gray //Draw it in gray
Print(110 + (i * division) - 16 +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128); Print(110 + (i * division) - 16 +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128);
} }
}else{ }else{
//Draw it highlighted //Draw it highlighted
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper); std::transform(tempstring.begin(), tempstring.end(),tempstring.begin(), ::toupper);
tempstring = std::string("[ ") + tempstring + std::string(" ]"); tempstring = std::string("[ ") + tempstring + std::string(" ]");
Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb); Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12) +game.menuyoff, tempstring, cr, cg, cb);
} }
else else
{ {
std::string tempstring = game.menuoptions[i]; std::string tempstring = game.menuoptions[i].text;
tempstring = "[ " + tempstring + " ]"; tempstring = "[ " + tempstring + " ]";
//Draw it in gray //Draw it in gray
Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128); Print(110 + (i * division) - 16 +game.menuxoff, 140 + (i * 12)+game.menuyoff, tempstring, 128, 128, 128);
@ -1165,27 +1165,27 @@ void Graphics::drawlevelmenu( int cr, int cg, int cb, int division /*= 30*/ )
} }
else else
{ {
if(game.nummenuoptions-i<=2){ if(game.menuoptions.size()-i<=2){
//Draw it normally //Draw it normally
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
Print(110 + (i * division) +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, game.menuoptions[i], cr, cg, cb); Print(110 + (i * division) +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, game.menuoptions[i].text, cr, cg, cb);
} }
else else
{ {
//Draw it in gray //Draw it in gray
Print(110 + (i * division) +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, game.menuoptions[i], 128, 128, 128); Print(110 + (i * division) +game.menuxoff, 140+8 + (i * 12)+game.menuyoff, game.menuoptions[i].text, 128, 128, 128);
} }
}else{ }else{
//Draw it normally //Draw it normally
if (game.menuoptionsactive[i]) if (game.menuoptions[i].active)
{ {
Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i], cr, cg, cb); Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, cr, cg, cb);
} }
else else
{ {
//Draw it in gray //Draw it in gray
Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i], 128, 128, 128); Print(110 + (i * division) +game.menuxoff, 140 + (i * 12)+game.menuyoff, game.menuoptions[i].text, 128, 128, 128);
} }
} }
} }

View file

@ -174,8 +174,8 @@ void titleinput()
} }
} }
if (game.currentmenuoption < 0) game.currentmenuoption = game.nummenuoptions-1; if (game.currentmenuoption < 0) game.currentmenuoption = game.menuoptions.size()-1;
if (game.currentmenuoption >= game.nummenuoptions ) game.currentmenuoption = 0; if (game.currentmenuoption >= (int) game.menuoptions.size() ) game.currentmenuoption = 0;
if (game.press_action) if (game.press_action)
{ {
@ -214,15 +214,6 @@ void titleinput()
//Options //Options
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
game.menuoptions[3] = "soundtrack";
game.menuoptionsactive[3] = true;
game.menuoptions[4] = "return";
game.menuoptionsactive[4] = true;
game.nummenuoptions = 5;
}
map.nexttowercolour(); map.nexttowercolour();
} }
else if (game.currentmenuoption == 3) else if (game.currentmenuoption == 3)
@ -264,15 +255,6 @@ void titleinput()
//Options //Options
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
}
map.nexttowercolour(); map.nexttowercolour();
} }
else if (game.currentmenuoption == 3) else if (game.currentmenuoption == 3)
@ -326,15 +308,6 @@ void titleinput()
//Options //Options
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
}
map.nexttowercolour(); map.nexttowercolour();
} }
else if (game.currentmenuoption == 4) else if (game.currentmenuoption == 4)
@ -357,12 +330,12 @@ void titleinput()
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
else if(game.currentmenuname=="levellist") else if(game.currentmenuname=="levellist")
{ {
if(game.currentmenuoption==game.nummenuoptions-1){ if(game.currentmenuoption==(int)game.menuoptions.size()-1){
//go back to menu //go back to menu
music.playef(11); music.playef(11);
game.createmenu("mainmenu"); game.createmenu("mainmenu");
map.nexttowercolour(); map.nexttowercolour();
}else if(game.currentmenuoption==game.nummenuoptions-2){ }else if(game.currentmenuoption==(int)game.menuoptions.size()-2){
//next page //next page
music.playef(11); music.playef(11);
if((size_t) ((game.levelpage*8)+8) >= ed.ListOfMetaData.size()){ if((size_t) ((game.levelpage*8)+8) >= ed.ListOfMetaData.size()){
@ -371,7 +344,7 @@ void titleinput()
game.levelpage++; game.levelpage++;
} }
game.createmenu("levellist"); game.createmenu("levellist");
game.currentmenuoption=game.nummenuoptions-2; game.currentmenuoption=game.menuoptions.size()-2;
map.nexttowercolour(); map.nexttowercolour();
}else{ }else{
//Ok, launch the level! //Ok, launch the level!
@ -685,24 +658,6 @@ void titleinput()
//back //back
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
#if defined(MAKEANDPLAY)
game.menuoptions[3] = "soundtrack";
game.menuoptionsactive[3] = true;
game.menuoptions[4] = "return";
game.menuoptionsactive[4] = true;
game.nummenuoptions = 5;
#elif !defined(MAKEANDPLAY)
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
#endif
}
map.nexttowercolour(); map.nexttowercolour();
} }
else else
@ -1269,23 +1224,6 @@ void titleinput()
{ {
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
#if defined(MAKEANDPLAY)
game.menuoptions[3] = "soundtrack";
game.menuoptionsactive[3] = true;
game.menuoptions[4] = "return";
game.menuoptionsactive[4] = true;
game.nummenuoptions = 5;
#elif !defined(MAKEANDPLAY)
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
#endif
}
} }
} }
else if (game.currentmenuname == "cleardatamenu") else if (game.currentmenuname == "cleardatamenu")
@ -1295,23 +1233,6 @@ void titleinput()
//back //back
music.playef(11); music.playef(11);
game.createmenu("options"); game.createmenu("options");
//Add extra menu for mmmmmm mod
if(music.mmmmmm){
#if defined(MAKEANDPLAY)
game.menuoptions[3] = "soundtrack";
game.menuoptionsactive[3] = true;
game.menuoptions[4] = "return";
game.menuoptionsactive[4] = true;
game.nummenuoptions = 5;
#elif !defined(MAKEANDPLAY)
game.menuoptions[4] = "soundtrack";
game.menuoptionsactive[4] = true;
game.menuoptions[5] = "return";
game.menuoptionsactive[5] = true;
game.nummenuoptions = 6;
#endif
}
map.nexttowercolour(); map.nexttowercolour();
} }
else else

View file

@ -83,7 +83,7 @@ void titlerender()
int tmp=game.currentmenuoption+(game.levelpage*8); int tmp=game.currentmenuoption+(game.levelpage*8);
if(tmp>=0 && tmp < (int) ed.ListOfMetaData.size()){ // FIXME: size_t/int! -flibit if(tmp>=0 && tmp < (int) ed.ListOfMetaData.size()){ // FIXME: size_t/int! -flibit
//Don't show next page or return to menu options here! //Don't show next page or return to menu options here!
if(game.nummenuoptions - game.currentmenuoption<=2){ if(game.menuoptions.size() - game.currentmenuoption<=2){
}else{ }else{
graphics.bigprint( -1, 15, ed.ListOfMetaData[tmp].title, tr, tg, tb, true); graphics.bigprint( -1, 15, ed.ListOfMetaData[tmp].title, tr, tg, tb, true);

View file

@ -3918,8 +3918,8 @@ void editorinput()
} }
} }
if (game.currentmenuoption < 0) game.currentmenuoption = game.nummenuoptions-1; if (game.currentmenuoption < 0) game.currentmenuoption = game.menuoptions.size()-1;
if (game.currentmenuoption >= game.nummenuoptions ) game.currentmenuoption = 0; if (game.currentmenuoption >= (int) game.menuoptions.size() ) game.currentmenuoption = 0;
if (game.press_action) if (game.press_action)
{ {