From 9e99246e02340b85e9d1c4acb4f4c7988d55e8d3 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 16 Apr 2020 15:19:17 -0700 Subject: [PATCH] Turn game.currentmenuname "else-if"s into case-switches Much more stylistic, you don't need to repeat "game.currentmenuname" for each case, and you don't need to deal with the dangling first "if" that doesn't have an "else". --- desktop_version/src/Game.cpp | 232 ++++++++++++++------------------- desktop_version/src/Input.cpp | 185 ++++++++++++-------------- desktop_version/src/Render.cpp | 177 ++++++++++++------------- desktop_version/src/editor.cpp | 42 +++--- 4 files changed, 280 insertions(+), 356 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index f677ee85..26e30aef 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6551,8 +6551,9 @@ void Game::createmenu( enum Menu::MenuName t ) menucountdown = 0; menuoptions.clear(); - if (t == Menu::mainmenu) + switch (t) { + case Menu::mainmenu: #if !defined(MAKEANDPLAY) option("start game"); #endif @@ -6567,10 +6568,9 @@ void Game::createmenu( enum Menu::MenuName t ) option("quit game"); menuxoff = -16; menuyoff = -10; - } + break; #if !defined(NO_CUSTOM_LEVELS) - else if (t == Menu::playerworlds) - { + case Menu::playerworlds: option("play a level"); #if !defined(NO_EDITOR) option("level editor"); @@ -6579,9 +6579,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("back to menu"); menuxoff = -30; menuyoff = -40; - } - else if (t == Menu::levellist) - { + break; + case Menu::levellist: if(ed.ListOfMetaData.size()==0) { option("ok"); @@ -6641,31 +6640,27 @@ void Game::createmenu( enum Menu::MenuName t ) menuxoff = -90; menuyoff = 70-(menuoptions.size()*10); } - } + break; #endif - else if (t == Menu::quickloadlevel) - { + case Menu::quickloadlevel: option("continue from save"); option("start from beginning"); option("back to levels"); menuxoff = -40; menuyoff = -30; - } - else if (t == Menu::youwannaquit) - { + break; + case Menu::youwannaquit: option("yes, quit"); option("no, return"); menuxoff = 0; menuyoff = -20; - } - else if (t == Menu::errornostart) - { + break; + case Menu::errornostart: option("ok"); menuxoff = 0; menuyoff = -20; - } - else if (t == Menu::graphicoptions) - { + break; + case Menu::graphicoptions: option("toggle fullscreen"); option("toggle letterbox"); option("toggle filter"); @@ -6674,9 +6669,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -50; menuyoff = 8; - } - else if (t == Menu::ed_settings) - { + break; + case Menu::ed_settings: option("change description"); option("edit scripts"); option("change music"); @@ -6686,9 +6680,8 @@ void Game::createmenu( enum Menu::MenuName t ) menuxoff = -50; menuyoff = -20; - } - else if (t == Menu::ed_desc) - { + break; + case Menu::ed_desc: option("change name"); option("change author"); option("change description"); @@ -6697,24 +6690,21 @@ void Game::createmenu( enum Menu::MenuName t ) menuxoff = -40; menuyoff = 6; - } - else if (t == Menu::ed_music) - { + break; + case Menu::ed_music: option("next song"); option("back"); menuxoff = -10; menuyoff = 16; - } - else if (t == Menu::ed_quit) - { + break; + case Menu::ed_quit: option("yes, save and quit"); option("no, quit without saving"); option("return to editor"); menuxoff = -50; menuyoff = 8; - } - else if (t == Menu::options) - { + break; + case Menu::options: option("accessibility options"); #if !defined(MAKEANDPLAY) option("unlock play modes"); @@ -6729,9 +6719,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -40; menuyoff = 0; - } - else if (t == Menu::accessibility) - { + break; + case Menu::accessibility: option("animated backgrounds"); option("screen effects"); option("text outline"); @@ -6742,9 +6731,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -85; menuyoff = -10; - } - else if(t == Menu::controller) - { + break; + case Menu::controller: option("analog stick sensitivity"); option("bind flip"); option("bind enter"); @@ -6752,39 +6740,34 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -40; menuyoff = 10; - } - else if (t == Menu::cleardatamenu) - { + break; + case Menu::cleardatamenu: option("no! don't delete"); option("yes, delete everything"); menuxoff = -30; menuyoff = 64; - } - else if (t == Menu::setinvincibility) - { + break; + case Menu::setinvincibility: option("no, return to options"); option("yes, enable"); menuxoff = -30; menuyoff = 64; - } - else if (t == Menu::setslowdown1) - { + break; + case Menu::setslowdown1: option("no, return to options"); option("yes, delete saves"); menuxoff = -30; menuyoff = 64; - } - else if (t == Menu::setslowdown2) - { + break; + case Menu::setslowdown2: option("normal speed"); option("80% speed"); option("60% speed"); option("40% speed"); menuxoff = -40; menuyoff = 16; - } - else if (t == Menu::unlockmenu) - { + break; + case Menu::unlockmenu: option("unlock time trials"); option("unlock intermissions", !unlock[16]); option("unlock no death mode", !unlock[17]); @@ -6794,58 +6777,50 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -70; menuyoff = -20; - } - else if (t == Menu::credits) - { + break; + case Menu::credits: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits2) - { + break; + case Menu::credits2: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits25) - { + break; + case Menu::credits25: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits3) - { + break; + case Menu::credits3: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits4) - { + break; + case Menu::credits4: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits5) - { + break; + case Menu::credits5: option("next page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::credits6) - { + break; + case Menu::credits6: option("first page"); option("return"); menuxoff = 20; menuyoff = 64; - } - else if (t == Menu::play) - { + break; + case Menu::play: //Ok, here's where the unlock stuff comes into it: //First up, time trials: temp = 0; @@ -6957,26 +6932,23 @@ void Game::createmenu( enum Menu::MenuName t ) } } } - } - else if (t == Menu::unlocktimetrial - || t == Menu::unlocktimetrials - || t == Menu::unlocknodeathmode - || t == Menu::unlockintermission - || t == Menu::unlockflipmode) - { + break; + case Menu::unlocktimetrial: + case Menu::unlocktimetrials: + case Menu::unlocknodeathmode: + case Menu::unlockintermission: + case Menu::unlockflipmode: option("continue"); menuxoff = 20; menuyoff = 70; - } - else if (t == Menu::newgamewarning) - { + break; + case Menu::newgamewarning: option("start new game"); option("return to menu"); menuxoff = -30; menuyoff = 64; - } - else if (t == Menu::playmodes) - { + break; + case Menu::playmodes: option("time trials", !map.invincibility && game.slowdown == 30); option("intermissions", unlock[16]); option("no death mode", unlock[17] && !map.invincibility && game.slowdown == 30); @@ -6984,17 +6956,15 @@ void Game::createmenu( enum Menu::MenuName t ) option("return to play menu"); menuxoff = -70; menuyoff = 8; - } - else if (t == Menu::intermissionmenu) - { + break; + case Menu::intermissionmenu: option("play intermission 1"); option("play intermission 2"); option("return to play menu"); menuxoff = -50; menuyoff = -35; - } - else if (t == Menu::playint1) - { + break; + case Menu::playint1: option("Vitellary"); option("Vermilion"); option("Verdigris"); @@ -7002,9 +6972,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -60; menuyoff = 10; - } - else if (t == Menu::playint2) - { + break; + case Menu::playint2: option("Vitellary"); option("Vermilion"); option("Verdigris"); @@ -7012,36 +6981,31 @@ void Game::createmenu( enum Menu::MenuName t ) option("return"); menuxoff = -60; menuyoff = 10; - } - else if (t == Menu::continuemenu) - { + break; + case Menu::continuemenu: option("continue from teleporter"); option("continue from quicksave"); option("return to play menu"); menuxoff = -60; menuyoff = 20; - } - else if (t == Menu::startnodeathmode) - { + break; + case Menu::startnodeathmode: option("disable cutscenes"); option("enable cutscenes"); option("return to play menu"); menuxoff = -60; menuyoff = 40; - } - else if (t == Menu::gameover) - { + break; + case Menu::gameover: menucountdown = 120; menudest=Menu::gameover2; - } - else if (t == Menu::gameover2) - { + break; + case Menu::gameover2: option("return to play menu"); menuxoff = -25; menuyoff = 80; - } - else if (t == Menu::unlockmenutrials) - { + break; + case Menu::unlockmenutrials: option("space station 1", !unlock[9]); option("the laboratory", !unlock[10]); option("the tower", !unlock[11]); @@ -7052,9 +7016,8 @@ void Game::createmenu( enum Menu::MenuName t ) option("return to unlock menu"); menuxoff = -80; menuyoff = 0; - } - else if (t == Menu::timetrials) - { + break; + case Menu::timetrials: option(unlock[9] ? "space station 1" : "???", unlock[9]); option(unlock[10] ? "the laboratory" : "???", unlock[10]); option(unlock[11] ? "the tower" : "???", unlock[11]); @@ -7065,40 +7028,35 @@ void Game::createmenu( enum Menu::MenuName t ) option("return to play menu"); menuxoff = -80; menuyoff = 0; - } - else if (t == Menu::nodeathmodecomplete) - { + break; + case Menu::nodeathmodecomplete: menucountdown = 90; menudest = Menu::nodeathmodecomplete2; - } - else if (t == Menu::nodeathmodecomplete2) - { + break; + case Menu::nodeathmodecomplete2: option("return to play menu"); menuxoff = -25; menuyoff = 70; - } - else if (t == Menu::timetrialcomplete) - { + break; + case Menu::timetrialcomplete: menucountdown = 90; menudest=Menu::timetrialcomplete2; - } - else if (t == Menu::timetrialcomplete2) - { + break; + case Menu::timetrialcomplete2: menucountdown = 60; menudest=Menu::timetrialcomplete3; - } - else if (t == Menu::timetrialcomplete3) - { + break; + case Menu::timetrialcomplete3: option("return to play menu"); option("try again"); menuxoff = -25; menuyoff = 70; - } - else if (t == Menu::gamecompletecontinue) - { + break; + case Menu::gamecompletecontinue: option("return to play menu"); menuxoff = -25; menuyoff = 70; + break; } } diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 1c07e56e..b417e161 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -112,8 +112,9 @@ void updatebuttonmappings(int bind) void menuactionpress() { - if (game.currentmenuname == Menu::mainmenu) + switch (game.currentmenuname) { + case Menu::mainmenu: #if defined(MAKEANDPLAY) #define MPOFFSET -1 #else @@ -189,10 +190,9 @@ void menuactionpress() #undef NOCUSTOMSOFFSET #undef MPOFFSET } - } + break; #if !defined(NO_CUSTOM_LEVELS) - else if(game.currentmenuname==Menu::levellist) - { + case Menu::levellist: if(game.currentmenuoption==(int)game.menuoptions.size()-1){ //go back to menu music.playef(11); @@ -227,10 +227,9 @@ void menuactionpress() map.nexttowercolour(); } } - } + break; #endif - else if(game.currentmenuname==Menu::quickloadlevel) - { + case Menu::quickloadlevel: switch (game.currentmenuoption) { case 0: //continue save @@ -248,10 +247,9 @@ void menuactionpress() map.nexttowercolour(); break; } - } + break; #if !defined(NO_CUSTOM_LEVELS) - else if(game.currentmenuname==Menu::playerworlds) - { + case Menu::playerworlds: #if defined(NO_EDITOR) #define OFFSET -1 #else @@ -295,15 +293,14 @@ void menuactionpress() break; } #undef OFFSET - } + break; #endif - else if(game.currentmenuname==Menu::errornostart){ + case Menu::errornostart: music.playef(11); game.createmenu(Menu::mainmenu); map.nexttowercolour(); - } - else if (game.currentmenuname == Menu::graphicoptions) - { + break; + case Menu::graphicoptions: switch (game.currentmenuoption) { case 0: @@ -359,9 +356,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::youwannaquit) - { + break; + case Menu::youwannaquit: switch (game.currentmenuoption) { case 0: @@ -375,9 +371,8 @@ void menuactionpress() game.createmenu(game.previousmenuname); map.nexttowercolour(); } - } - else if (game.currentmenuname == Menu::setinvincibility) - { + break; + case Menu::setinvincibility: switch (game.currentmenuoption) { case 0: @@ -396,9 +391,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::setslowdown1) - { + break; + case Menu::setslowdown1: switch (game.currentmenuoption) { case 0: @@ -417,9 +411,8 @@ void menuactionpress() music.playef(11); break; } - } - else if (game.currentmenuname == Menu::setslowdown2) - { + break; + case Menu::setslowdown2: switch (game.currentmenuoption) { case 0: @@ -460,9 +453,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::accessibility) - { + break; + case Menu::accessibility: switch (game.currentmenuoption) { case 0: @@ -531,8 +523,8 @@ void menuactionpress() music.playef(2); break; } - } - else if (game.currentmenuname == Menu::options) + break; + case Menu::options: { #if defined(MAKEANDPLAY) #define OFFSET -1 @@ -592,9 +584,9 @@ void menuactionpress() map.nexttowercolour(); } #undef OFFSET + break; } - else if (game.currentmenuname == Menu::unlockmenutrials) - { + case Menu::unlockmenutrials: switch (game.currentmenuoption) { case 0: //unlock 1 @@ -652,9 +644,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::unlockmenu) - { + break; + case Menu::unlockmenu: switch (game.currentmenuoption) { case 0: @@ -716,9 +707,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits) - { + break; + case Menu::credits: switch (game.currentmenuoption) { case 0: @@ -734,9 +724,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits2) - { + break; + case Menu::credits2: switch (game.currentmenuoption) { case 0: @@ -752,9 +741,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits25) - { + break; + case Menu::credits25: switch (game.currentmenuoption) { case 0: @@ -770,9 +758,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits3) - { + break; + case Menu::credits3: switch (game.currentmenuoption) { case 0: @@ -802,9 +789,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits4) - { + break; + case Menu::credits4: switch (game.currentmenuoption) { case 0: @@ -834,9 +820,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits5) - { + break; + case Menu::credits5: switch (game.currentmenuoption) { case 0: @@ -866,9 +851,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::credits6) - { + break; + case Menu::credits6: switch (game.currentmenuoption) { case 0: @@ -885,8 +869,8 @@ void menuactionpress() music.niceplay(6); break; } - } - else if (game.currentmenuname == Menu::play) + break; + case Menu::play: { //Do we have the Secret Lab option? int offset = game.unlock[8] ? 0 : -1; @@ -946,9 +930,9 @@ void menuactionpress() game.createmenu(Menu::mainmenu); map.nexttowercolour(); } + break; } - else if (game.currentmenuname == Menu::newgamewarning) - { + case Menu::newgamewarning: switch (game.currentmenuoption) { case 0: @@ -965,10 +949,9 @@ void menuactionpress() map.nexttowercolour(); break; } - } + break; - else if (game.currentmenuname == Menu::controller) - { + case Menu::controller: switch (game.currentmenuoption) { case 0: @@ -985,9 +968,8 @@ void menuactionpress() game.createmenu(Menu::options); break; } - } - else if (game.currentmenuname == Menu::cleardatamenu) - { + break; + case Menu::cleardatamenu: switch (game.currentmenuoption) { case 0: @@ -1008,9 +990,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::playmodes) - { + break; + case Menu::playmodes: if (game.currentmenuoption == 0 && game.slowdown == 30 && !map.invincibility) //go to the time trial menu { music.playef(11); @@ -1050,9 +1031,8 @@ void menuactionpress() //Can't do yet! play sad sound music.playef(2); } - } - else if (game.currentmenuname == Menu::startnodeathmode) - { + break; + case Menu::startnodeathmode: switch (game.currentmenuoption) { case 0: //start no death mode, disabling cutscenes @@ -1070,9 +1050,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::continuemenu) - { + break; + case Menu::continuemenu: switch (game.currentmenuoption) { case 0: @@ -1090,9 +1069,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::intermissionmenu) - { + break; + case Menu::intermissionmenu: switch (game.currentmenuoption) { case 0: @@ -1114,9 +1092,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::playint1) - { + break; + case Menu::playint1: switch (game.currentmenuoption) { case 0: @@ -1142,9 +1119,8 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::playint2) - { + break; + case Menu::playint2: switch (game.currentmenuoption) { case 0: @@ -1170,28 +1146,25 @@ void menuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::gameover2) - { + break; + case Menu::gameover2: //back music.playef(11); music.play(6); game.createmenu(Menu::mainmenu); map.nexttowercolour(); - } - else if (game.currentmenuname == Menu::unlocktimetrials - || game.currentmenuname == Menu::unlocktimetrial - || game.currentmenuname == Menu::unlocknodeathmode - || game.currentmenuname == Menu::unlockintermission - || game.currentmenuname == Menu::unlockflipmode) - { + break; + case Menu::unlocktimetrials: + case Menu::unlocktimetrial: + case Menu::unlocknodeathmode: + case Menu::unlockintermission: + case Menu::unlockflipmode: //back music.playef(11); game.createmenu(Menu::play); map.nexttowercolour(); - } - else if (game.currentmenuname == Menu::timetrials) - { + break; + case Menu::timetrials: if (game.currentmenuoption == 0 && game.unlock[9]) //space station 1 { game.mainmenu = 3; @@ -1234,9 +1207,8 @@ void menuactionpress() //Can't do yet! play sad sound music.playef(2); } - } - else if (game.currentmenuname == Menu::timetrialcomplete3) - { + break; + case Menu::timetrialcomplete3: switch (game.currentmenuoption) { case 0: @@ -1280,13 +1252,16 @@ void menuactionpress() } break; } - } - else if (game.currentmenuname == Menu::gamecompletecontinue || game.currentmenuname == Menu::nodeathmodecomplete2) - { + break; + case Menu::gamecompletecontinue: + case Menu::nodeathmodecomplete2: music.play(6); music.playef(11); game.createmenu(Menu::play); map.nexttowercolour(); + break; + default: + break; } } diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index dc1de47a..7534a179 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -20,8 +20,9 @@ void menurender() { int temp = 50; - if(game.currentmenuname==Menu::mainmenu) + switch (game.currentmenuname) { + case Menu::mainmenu: graphics.drawsprite((160 - 96) + 0 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 1 * 32, temp, 23, tr, tg, tb); graphics.drawsprite((160 - 96) + 2 * 32, temp, 23, tr, tg, tb); @@ -36,9 +37,9 @@ void menurender() if(music.mmmmmm){ graphics.Print( 10, 230, "[MMMMMM Mod Installed]", tr/2, tg/2, tb/2); } - } + break; #if !defined(NO_CUSTOM_LEVELS) - else if (game.currentmenuname == Menu::levellist) + case Menu::levellist: { if(ed.ListOfMetaData.size()==0){ graphics.Print( -1, 100, "ERROR: No levels found.", tr, tg, tb, true); @@ -57,15 +58,14 @@ void menurender() graphics.Print( -1, 90, ed.ListOfMetaData[tmp].Desc3, tr, tg, tb, true); } } + break; } #endif - else if (game.currentmenuname == Menu::errornostart) - { + case Menu::errornostart: graphics.Print( -1, 65, "ERROR: This level has", tr, tg, tb, true); graphics.Print( -1, 75, "no start point!", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::options) - { + break; + case Menu::options: #if defined(MAKEANDPLAY) #define OFFSET -1 #else @@ -109,9 +109,8 @@ void menurender() break; } #undef OFFSET - } - else if (game.currentmenuname == Menu::graphicoptions) - { + break; + case Menu::graphicoptions: switch (game.currentmenuoption) { case 0: @@ -166,9 +165,8 @@ void menurender() } break; } - } - else if (game.currentmenuname == Menu::credits) - { + break; + case Menu::credits: graphics.Print( -1, 50, "VVVVVV is a game by", tr, tg, tb, true); graphics.bigprint( 40, 65, "Terry Cavanagh", tr, tg, tb, true, 2); @@ -177,25 +175,23 @@ void menurender() graphics.Print( -1, 120, "and features music by", tr, tg, tb, true); graphics.bigprint( 40, 135, "Magnus P~lsson", tr, tg, tb, true, 2); graphics.drawimagecol(8, -1, 156, tr *0.75, tg *0.75, tb *0.75, true); - } - else if (game.currentmenuname == Menu::credits2) - { + break; + case Menu::credits2: graphics.Print( -1, 50, "Roomnames are by", tr, tg, tb, true); graphics.bigprint( 40, 65, "Bennett Foddy", tr, tg, tb, true); graphics.drawimagecol(9, -1, 86, tr*0.75, tg *0.75, tb *0.75, true); graphics.Print( -1, 110, "C++ version by", tr, tg, tb, true); graphics.bigprint( 40, 125, "Simon Roth", tr, tg, tb, true); graphics.bigprint( 40, 145, "Ethan Lee", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::credits25) - { + break; + case Menu::credits25: graphics.Print( -1, 40, "Beta Testing by", tr, tg, tb, true); graphics.bigprint( 40, 55, "Sam Kaplan", tr, tg, tb, true); graphics.bigprint( 40, 75, "Pauli Kohberger", tr, tg, tb, true); graphics.Print( -1, 130, "Ending Picture by", tr, tg, tb, true); graphics.bigprint( 40, 145, "Pauli Kohberger", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::credits3) + break; + case Menu::credits3: { graphics.Print( -1, 20, "VVVVVV is supported by", tr, tg, tb, true); graphics.Print( 40, 30, "the following patrons", tr, tg, tb, true); @@ -212,8 +208,9 @@ void menurender() xofs += 4; yofs += 14; } + break; } - else if (game.currentmenuname == Menu::credits4) + case Menu::credits4: { graphics.Print( -1, 20, "and also by", tr, tg, tb, true); @@ -231,8 +228,9 @@ void menurender() graphics.Print(80, yofs, game.patrons[i], tr, tg, tb); yofs += 10; } + break; } - else if (game.currentmenuname == Menu::credits5) + case Menu::credits5: { graphics.Print( -1, 20, "With contributions on", tr, tg, tb, true); graphics.Print( 40, 30, "GitHub from", tr, tg, tb, true); @@ -253,9 +251,9 @@ void menurender() xofs += 4; yofs += 14; } + break; } - else if (game.currentmenuname == Menu::credits6) - { + case Menu::credits6: graphics.Print( -1, 20, "and thanks also to:", tr, tg, tb, true); graphics.bigprint(80, 60, "You!", tr, tg, tb, true); @@ -266,21 +264,18 @@ void menurender() graphics.Print( 80, 130, "and into the future.", tr, tg, tb, true); graphics.Print( 80, 150,"Thank you!", tr, tg, tb,true); - } - else if (game.currentmenuname == Menu::setinvincibility) - { + break; + case Menu::setinvincibility: graphics.Print( -1, 100, "Are you sure you want to ", tr, tg, tb, true); graphics.Print( -1, 110, "enable invincibility?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::setslowdown1) - { + break; + case Menu::setslowdown1: graphics.Print( -1, 90, "Warning! Changing the game speed", tr, tg, tb, true); graphics.Print( -1, 100, "requires a game restart, and will", tr, tg, tb, true); graphics.Print( -1, 110, "delete your current saves.", tr, tg, tb, true); graphics.Print( -1, 120, "Is this ok?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::setslowdown2) - { + break; + case Menu::setslowdown2: graphics.bigprint( -1, 40, "Game Speed", tr, tg, tb, true); graphics.Print( -1, 75, "Select a new game speed below.", tr, tg, tb, true); switch (game.gameframerate) @@ -298,26 +293,22 @@ void menurender() graphics.Print( -1, 105, "Game speed is at 40%", tr, tg, tb, true); break; } - } - else if (game.currentmenuname == Menu::newgamewarning) - { + break; + case Menu::newgamewarning: graphics.Print( -1, 100, "Are you sure? This will", tr, tg, tb, true); graphics.Print( -1, 110, "delete your current saves...", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::cleardatamenu) - { + break; + case Menu::cleardatamenu: graphics.Print( -1, 100, "Are you sure you want to", tr, tg, tb, true); graphics.Print( -1, 110, "delete all your saved data?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::startnodeathmode) - { + break; + case Menu::startnodeathmode: graphics.Print( -1, 45, "Good luck!", tr, tg, tb, true); graphics.Print( -1, 80, "You cannot save in this mode.", tr, tg, tb, true); graphics.Print( -1, 100, "Would you like to disable the", tr, tg, tb, true); graphics.Print( -1, 112, "cutscenes during the game?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::controller) - { + break; + case Menu::controller: graphics.bigprint( -1, 30, "Game Pad", tr, tg, tb, true); graphics.Print( -1, 55, "Change controller options.", tr, tg, tb, true); switch (game.currentmenuoption) @@ -357,9 +348,8 @@ void menurender() } - } - else if (game.currentmenuname == Menu::accessibility) - { + break; + case Menu::accessibility: switch (game.currentmenuoption) { case 0: @@ -449,14 +439,13 @@ void menurender() graphics.Print(-1, 105, "Room name background is OPAQUE", tr, tg, tb, true); break; } - } - else if (game.currentmenuname == Menu::playint1 || game.currentmenuname == Menu::playint2) - { + break; + case Menu::playint1: + case Menu::playint2: graphics.Print( -1, 65, "Who do you want to play", tr, tg, tb, true); graphics.Print( -1, 75, "the level with?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::playmodes) - { + break; + case Menu::playmodes: switch (game.currentmenuoption) { case 0: @@ -518,13 +507,11 @@ void menurender() } break; } - } - else if (game.currentmenuname == Menu::youwannaquit) - { + break; + case Menu::youwannaquit: graphics.Print( -1, 75, "Are you sure you want to quit?", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::continuemenu) - { + break; + case Menu::continuemenu: graphics.crewframedelay--; if (graphics.crewframedelay <= 0) { @@ -566,8 +553,9 @@ void menurender() graphics.drawspritesetcol(175, 126-20, 22, 18); break; } - } - else if (game.currentmenuname == Menu::gameover || game.currentmenuname == Menu::gameover2) + break; + case Menu::gameover: + case Menu::gameover2: { graphics.bigprint( -1, 25, "GAME OVER", tr, tg, tb, true, 3); @@ -615,8 +603,10 @@ void menurender() } graphics.Print(0, 190, tempstring, tr, tg, tb, true); + break; } - else if (game.currentmenuname == Menu::nodeathmodecomplete || game.currentmenuname == Menu::nodeathmodecomplete2) + case Menu::nodeathmodecomplete: + case Menu::nodeathmodecomplete2: { graphics.bigprint( -1, 8, "WOW", tr, tg, tb, true, 4); @@ -639,9 +629,11 @@ void menurender() graphics.Print(0, 160, "A new trophy has been awarded and", tr, tg, tb, true); graphics.Print(0, 170, "placed in the secret lab to", tr, tg, tb, true); graphics.Print(0, 180, "acknowledge your achievement!", tr, tg, tb, true); + break; } - else if (game.currentmenuname == Menu::timetrialcomplete || game.currentmenuname == Menu::timetrialcomplete2 - || game.currentmenuname == Menu::timetrialcomplete3) + case Menu::timetrialcomplete: + case Menu::timetrialcomplete2: + case Menu::timetrialcomplete3: { graphics.bigprint( -1, 20, "Results", tr, tg, tb, true, 3); @@ -696,15 +688,14 @@ void menurender() break; } } + break; } - else if (game.currentmenuname == Menu::unlockmenutrials) - { + case Menu::unlockmenutrials: graphics.bigprint( -1, 30, "Unlock Time Trials", tr, tg, tb, true); graphics.Print( -1, 65, "You can unlock each time", tr, tg, tb, true); graphics.Print( -1, 75, "trial separately.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::timetrials) - { + break; + case Menu::timetrials: switch (game.currentmenuoption) { case 0: @@ -984,9 +975,8 @@ void menurender() } break; } - } - else if (game.currentmenuname == Menu::gamecompletecontinue) - { + break; + case Menu::gamecompletecontinue: graphics.bigprint( -1, 25, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 45, "Your save files have been updated.", tr, tg, tb, true); @@ -994,50 +984,45 @@ void menurender() graphics.Print( -1, 110, "If you want to keep exploring", tr, tg, tb, true); graphics.Print( -1, 120, "the game, select CONTINUE", tr, tg, tb, true); graphics.Print( -1, 130, "from the play menu.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlockmenu) - { + break; + case Menu::unlockmenu: graphics.bigprint( -1, 25, "Unlock Play Modes", tr, tg, tb, true, 2); graphics.Print( -1, 55, "From here, you may unlock parts", tr, tg, tb, true); graphics.Print( -1, 65, "of the game that are normally", tr, tg, tb, true); graphics.Print( -1, 75, "unlocked as you play.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlocktimetrial) - { + break; + case Menu::unlocktimetrial: graphics.bigprint( -1, 45, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 125, "You have unlocked", tr, tg, tb, true); graphics.Print( -1, 135, "a new Time Trial.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlocktimetrials) - { + break; + case Menu::unlocktimetrials: graphics.bigprint( -1, 45, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 125, "You have unlocked some", tr, tg, tb, true); graphics.Print( -1, 135, "new Time Trials.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlocknodeathmode) - { + break; + case Menu::unlocknodeathmode: graphics.bigprint( -1, 45, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 125, "You have unlocked", tr, tg, tb, true); graphics.Print( -1, 135, "No Death Mode.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlockflipmode) - { + break; + case Menu::unlockflipmode: graphics.bigprint( -1, 45, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 125, "You have unlocked", tr, tg, tb, true); graphics.Print( -1, 135, "Flip Mode.", tr, tg, tb, true); - } - else if (game.currentmenuname == Menu::unlockintermission) - { + break; + case Menu::unlockintermission: graphics.bigprint( -1, 45, "Congratulations!", tr, tg, tb, true, 2); graphics.Print( -1, 125, "You have unlocked", tr, tg, tb, true); graphics.Print( -1, 135, "the intermission levels.", tr, tg, tb, true); - }else if (game.currentmenuname == Menu::playerworlds) + break; + case Menu::playerworlds: { std::string tempstring = FILESYSTEM_getUserLevelDirectory(); if(tempstring.length()>80){ @@ -1056,6 +1041,10 @@ void menurender() graphics.Print( -1, 190, "the .vvvvvv files to this folder:", tr, tg, tb, true); graphics.Print( 320-(tempstring.length()*8), 210, tempstring, tr, tg, tb); } + break; + } + default: + break; } } diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 0f995c90..aa4c46c6 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -2183,12 +2183,12 @@ void editorclass::generatecustomminimap() void editormenurender(int tr, int tg, int tb) { - if (game.currentmenuname == Menu::ed_settings) + switch (game.currentmenuname) { + case Menu::ed_settings: graphics.bigprint( -1, 75, "Map Settings", tr, tg, tb, true); - } - else if (game.currentmenuname==Menu::ed_desc) - { + break; + case Menu::ed_desc: if(ed.titlemod) { if(ed.entframe<2) @@ -2279,9 +2279,8 @@ void editormenurender(int tr, int tg, int tb) { graphics.Print( -1, 110, ed.Desc3, tr, tg, tb, true); } - } - else if (game.currentmenuname == Menu::ed_music) - { + break; + case Menu::ed_music: graphics.bigprint( -1, 65, "Map Music", tr, tg, tb, true); graphics.Print( -1, 85, "Current map music:", tr, tg, tb, true); @@ -2327,11 +2326,13 @@ void editormenurender(int tr, int tg, int tb) graphics.Print( -1, 120, "?: something else", tr, tg, tb, true); break; } - } - else if (game.currentmenuname == Menu::ed_quit) - { + break; + case Menu::ed_quit: graphics.bigprint( -1, 90, "Save before", tr, tg, tb, true); graphics.bigprint( -1, 110, "quitting?", tr, tg, tb, true); + break; + default: + break; } } @@ -3461,8 +3462,9 @@ void editorlogic() void editormenuactionpress() { - if (game.currentmenuname == Menu::ed_desc) + switch (game.currentmenuname) { + case Menu::ed_desc: switch (game.currentmenuoption) { case 0: @@ -3495,9 +3497,8 @@ void editormenuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::ed_settings) - { + break; + case Menu::ed_settings: switch (game.currentmenuoption) { case 0: @@ -3560,9 +3561,8 @@ void editormenuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::ed_music) - { + break; + case Menu::ed_music: switch (game.currentmenuoption) { case 0: @@ -3588,9 +3588,8 @@ void editormenuactionpress() map.nexttowercolour(); break; } - } - else if (game.currentmenuname == Menu::ed_quit) - { + break; + case Menu::ed_quit: switch (game.currentmenuoption) { case 0: @@ -3622,6 +3621,9 @@ void editormenuactionpress() map.nexttowercolour(); break; } + break; + default: + break; } }