1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-11-14 15:09:42 +01:00

De-duplicate setting mainmenu and fademode

This makes my work easier later.
This commit is contained in:
Misa 2021-03-25 20:10:36 -07:00 committed by Ethan Lee
parent 6a6c09f69d
commit cd0c9ccb31

View file

@ -188,6 +188,12 @@ static void toggleflipmode(void)
} }
} }
static void startmode(const int mode)
{
game.mainmenu = mode;
graphics.fademode = 2; /* fading out */
}
static void menuactionpress(void) static void menuactionpress(void)
{ {
switch (game.currentmenuname) switch (game.currentmenuname)
@ -216,8 +222,7 @@ static void menuactionpress(void)
{ {
//No saves exist, just start a new game //No saves exist, just start a new game
music.playef(11); music.playef(11);
game.mainmenu = 0; startmode(0);
graphics.fademode = 2;
} }
else else
{ {
@ -309,8 +314,7 @@ static void menuactionpress(void)
std::string name = "saves/" + ed.ListOfMetaData[game.playcustomlevel].filename.substr(7) + ".vvv"; std::string name = "saves/" + ed.ListOfMetaData[game.playcustomlevel].filename.substr(7) + ".vvv";
tinyxml2::XMLDocument doc; tinyxml2::XMLDocument doc;
if (!FILESYSTEM_loadTiXml2Document(name.c_str(), doc)){ if (!FILESYSTEM_loadTiXml2Document(name.c_str(), doc)){
game.mainmenu = 22; startmode(22);
graphics.fademode = 2;
}else{ }else{
game.createmenu(Menu::quickloadlevel); game.createmenu(Menu::quickloadlevel);
map.nexttowercolour(); map.nexttowercolour();
@ -323,13 +327,11 @@ static void menuactionpress(void)
{ {
case 0: //continue save case 0: //continue save
music.playef(11); music.playef(11);
game.mainmenu = 23; startmode(23);
graphics.fademode = 2;
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
game.mainmenu = 22; startmode(22);
graphics.fademode = 2;
break; break;
case 2: case 2:
music.playef(11); music.playef(11);
@ -360,8 +362,7 @@ static void menuactionpress(void)
case 1: case 1:
//LEVEL EDITOR HOOK //LEVEL EDITOR HOOK
music.playef(11); music.playef(11);
game.mainmenu = 20; startmode(20);
graphics.fademode = 2;
ed.filename=""; ed.filename="";
break; break;
#endif #endif
@ -470,8 +471,7 @@ static void menuactionpress(void)
case 0: case 0:
//bye! //bye!
music.playef(2); music.playef(2);
game.mainmenu = 100; startmode(100);
graphics.fademode = 2;
break; break;
default: default:
music.playef(11); music.playef(11);
@ -1143,22 +1143,19 @@ static void menuactionpress(void)
{ {
//You have no saves but have something unlocked, or you couldn't have gotten here //You have no saves but have something unlocked, or you couldn't have gotten here
music.playef(11); music.playef(11);
game.mainmenu = 0; startmode(0);
graphics.fademode = 2;
} }
else if (game.telesummary == "") else if (game.telesummary == "")
{ {
//You at least have a quicksave, or you couldn't have gotten here //You at least have a quicksave, or you couldn't have gotten here
music.playef(11); music.playef(11);
game.mainmenu = 2; startmode(2);
graphics.fademode = 2;
} }
else if (game.quicksummary == "") else if (game.quicksummary == "")
{ {
//You at least have a telesave, or you couldn't have gotten here //You at least have a telesave, or you couldn't have gotten here
music.playef(11); music.playef(11);
game.mainmenu = 1; startmode(1);
graphics.fademode = 2;
} }
else else
{ {
@ -1172,8 +1169,7 @@ static void menuactionpress(void)
{ {
if(!map.invincibility && game.slowdown == 30){ if(!map.invincibility && game.slowdown == 30){
music.playef(11); music.playef(11);
game.mainmenu = 11; startmode(11);
graphics.fademode = 2;
}else{ }else{
//Can't do yet! play sad sound //Can't do yet! play sad sound
music.playef(2); music.playef(2);
@ -1208,8 +1204,7 @@ static void menuactionpress(void)
case 0: case 0:
//yep //yep
music.playef(11); music.playef(11);
game.mainmenu = 0; startmode(0);
graphics.fademode = 2;
game.deletequick(); game.deletequick();
game.deletetele(); game.deletetele();
break; break;
@ -1307,13 +1302,11 @@ static void menuactionpress(void)
{ {
case 0: //start no death mode, disabling cutscenes case 0: //start no death mode, disabling cutscenes
music.playef(11); music.playef(11);
game.mainmenu = 10; startmode(10);
graphics.fademode = 2;
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
game.mainmenu = 9; startmode(9);
graphics.fademode = 2;
break; break;
case 2: case 2:
//back //back
@ -1328,13 +1321,11 @@ static void menuactionpress(void)
{ {
case 0: case 0:
music.playef(11); music.playef(11);
game.mainmenu = 1; startmode(1);
graphics.fademode = 2;
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
game.mainmenu = 2; startmode(2);
graphics.fademode = 2;
break; break;
case 2: case 2:
//back //back
@ -1372,23 +1363,19 @@ static void menuactionpress(void)
{ {
case 0: case 0:
music.playef(11); music.playef(11);
game.mainmenu = 12; startmode(12);
graphics.fademode = 2;
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
game.mainmenu = 13; startmode(13);
graphics.fademode = 2;
break; break;
case 2: case 2:
music.playef(11); music.playef(11);
game.mainmenu = 14; startmode(14);
graphics.fademode = 2;
break; break;
case 3: case 3:
music.playef(11); music.playef(11);
game.mainmenu = 15; startmode(15);
graphics.fademode = 2;
break; break;
case 4: case 4:
//back //back
@ -1403,23 +1390,19 @@ static void menuactionpress(void)
{ {
case 0: case 0:
music.playef(11); music.playef(11);
game.mainmenu = 16; startmode(16);
graphics.fademode = 2;
break; break;
case 1: case 1:
music.playef(11); music.playef(11);
game.mainmenu = 17; startmode(17);
graphics.fademode = 2;
break; break;
case 2: case 2:
music.playef(11); music.playef(11);
game.mainmenu = 18; startmode(18);
graphics.fademode = 2;
break; break;
case 3: case 3:
music.playef(11); music.playef(11);
game.mainmenu = 19; startmode(19);
graphics.fademode = 2;
break; break;
case 4: case 4:
//back //back
@ -1450,38 +1433,32 @@ static void menuactionpress(void)
if (game.currentmenuoption == 0 && game.unlock[9]) //space station 1 if (game.currentmenuoption == 0 && game.unlock[9]) //space station 1
{ {
music.playef(11); music.playef(11);
game.mainmenu = 3; startmode(3);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 1 && game.unlock[10]) //lab else if (game.currentmenuoption == 1 && game.unlock[10]) //lab
{ {
music.playef(11); music.playef(11);
game.mainmenu = 4; startmode(4);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 2 && game.unlock[11]) //tower else if (game.currentmenuoption == 2 && game.unlock[11]) //tower
{ {
music.playef(11); music.playef(11);
game.mainmenu = 5; startmode(5);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 3 && game.unlock[12]) //station 2 else if (game.currentmenuoption == 3 && game.unlock[12]) //station 2
{ {
music.playef(11); music.playef(11);
game.mainmenu = 6; startmode(6);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 4 && game.unlock[13]) //warp else if (game.currentmenuoption == 4 && game.unlock[13]) //warp
{ {
music.playef(11); music.playef(11);
game.mainmenu = 7; startmode(7);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 5 && game.unlock[14]) //final else if (game.currentmenuoption == 5 && game.unlock[14]) //final
{ {
music.playef(11); music.playef(11);
game.mainmenu = 8; startmode(8);
graphics.fademode = 2;
} }
else if (game.currentmenuoption == 6) //go to the time trial menu else if (game.currentmenuoption == 6) //go to the time trial menu
{ {
@ -1520,38 +1497,32 @@ static void menuactionpress(void)
if (game.timetriallevel == 0) //space station 1 if (game.timetriallevel == 0) //space station 1
{ {
music.playef(11); music.playef(11);
game.mainmenu = 3; startmode(3);
graphics.fademode = 2;
} }
else if (game.timetriallevel == 1) //lab else if (game.timetriallevel == 1) //lab
{ {
music.playef(11); music.playef(11);
game.mainmenu = 4; startmode(4);
graphics.fademode = 2;
} }
else if (game.timetriallevel == 2) //tower else if (game.timetriallevel == 2) //tower
{ {
music.playef(11); music.playef(11);
game.mainmenu = 5; startmode(5);
graphics.fademode = 2;
} }
else if (game.timetriallevel == 3) //station 2 else if (game.timetriallevel == 3) //station 2
{ {
music.playef(11); music.playef(11);
game.mainmenu = 6; startmode(6);
graphics.fademode = 2;
} }
else if (game.timetriallevel == 4) //warp else if (game.timetriallevel == 4) //warp
{ {
music.playef(11); music.playef(11);
game.mainmenu = 7; startmode(7);
graphics.fademode = 2;
} }
else if (game.timetriallevel == 5) //final else if (game.timetriallevel == 5) //final
{ {
music.playef(11); music.playef(11);
game.mainmenu = 8; startmode(8);
graphics.fademode = 2;
} }
break; break;
} }