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

Use enums for music tracks

This adds an anonymous enum for music tracks and replaces all calls to
music.play and music.niceplay that use integer literals. Additionally,
this is also done for integer literals for cl.levmusic (except 0) and
music.currentsong where appropriate, but _not_ the music areamap because
that would not make it look very aesthetically pleasing in the code.

This is not a named enum (that can be used for strict typechecking)
because music track IDs are essentially part of the API of the game -
almost every custom level uses these numbers. This is just to make the
source code more readable without needing a comment to denote what
number is what track.
This commit is contained in:
Misa 2023-05-23 18:37:32 -07:00
parent e9eeaa4186
commit cdeca65be7
8 changed files with 83 additions and 57 deletions

View file

@ -299,49 +299,49 @@ static void editormenurender(int tr, int tg, int tb)
case 0:
songname = loc::gettext("No background music");
break;
case 1:
case Music_PUSHINGONWARDS:
songname = loc::gettext("1: Pushing Onwards");
break;
case 2:
case Music_POSITIVEFORCE:
songname = loc::gettext("2: Positive Force");
break;
case 3:
case Music_POTENTIALFORANYTHING:
songname = loc::gettext("3: Potential for Anything");
break;
case 4:
case Music_PASSIONFOREXPLORING:
songname = loc::gettext("4: Passion for Exploring");
break;
case 5:
case Music_PAUSE:
songname = loc::gettext("N/A: Pause");
break;
case 6:
case Music_PRESENTINGVVVVVV:
songname = loc::gettext("5: Presenting VVVVVV");
break;
case 7:
case Music_PLENARY:
songname = loc::gettext("N/A: Plenary");
break;
case 8:
case Music_PREDESTINEDFATE:
songname = loc::gettext("6: Predestined Fate");
break;
case 9:
case Music_POSITIVEFORCEREVERSED:
songname = loc::gettext("N/A: ecroF evitisoP");
break;
case 10:
case Music_POPULARPOTPOURRI:
songname = loc::gettext("7: Popular Potpourri");
break;
case 11:
case Music_PIPEDREAM:
songname = loc::gettext("8: Pipe Dream");
break;
case 12:
case Music_PRESSURECOOKER:
songname = loc::gettext("9: Pressure Cooker");
break;
case 13:
case Music_PACEDENERGY:
songname = loc::gettext("10: Paced Energy");
break;
case 14:
case Music_PIERCINGTHESKY:
songname = loc::gettext("11: Piercing the Sky");
break;
case 15:
case Music_PREDESTINEDFATEREMIX:
songname = loc::gettext("N/A: Predestined Fate Remix");
break;
default:
@ -1909,7 +1909,7 @@ void editorlogic(void)
graphics.titlebg.colstate = 10;
map.nexttowercolour();
game.quittomenu();
music.play(6); //should be before game.quittomenu()
music.play(Music_PRESENTINGVVVVVV); // should be before game.quittomenu()
}
}

View file

@ -1501,7 +1501,7 @@ void Game::updatestate(void)
if (!obj.flags[71])
{
obj.flags[71] = true;
music.niceplay(15); //Final level remix
music.niceplay(Music_PREDESTINEDFATEREMIX);
setstate(0);
}
obj.removetrigger(49);
@ -1575,7 +1575,7 @@ void Game::updatestate(void)
break;
case 81:
quittomenu();
music.play(6); //should be after quittomenu()
music.play(Music_PRESENTINGVVVVVV); //should be after quittomenu()
setstate(0);
break;
@ -1669,7 +1669,7 @@ void Game::updatestate(void)
//Init final stretch
incstate();
music.playef(9);
music.play(2);
music.play(Music_POSITIVEFORCE);
obj.flags[72] = true;
screenshake = 10;
@ -2210,7 +2210,7 @@ void Game::updatestate(void)
}
#endif
quittomenu();
music.play(6); //should be after quittomenu()
music.play(Music_PRESENTINGVVVVVV); //should be after quittomenu()
setstate(0);
break;
@ -2223,7 +2223,7 @@ void Game::updatestate(void)
case 2500:
music.play(5);
music.play(Music_PAUSE);
//Activating a teleporter (appear)
incstate();
setstatedelay(15);
@ -2364,7 +2364,7 @@ void Game::updatestate(void)
advancetext = false;
setstate(0);
music.play(3);
music.play(Music_POTENTIALFORANYTHING);
break;
@ -2464,7 +2464,7 @@ void Game::updatestate(void)
//Level complete! (warp zone)
unlocknum(4);
lastsaved = 4;
music.play(0);
music.play(Music_PATHCOMPLETE);
incstate();
setstatedelay(75);
@ -2505,7 +2505,7 @@ void Game::updatestate(void)
//Level complete! (Space Station 2)
unlocknum(3);
lastsaved = 2;
music.play(0);
music.play(Music_PATHCOMPLETE);
incstate();
setstatedelay(75);
@ -2547,7 +2547,7 @@ void Game::updatestate(void)
//Level complete! (Lab)
unlocknum(1);
lastsaved = 5;
music.play(0);
music.play(Music_PATHCOMPLETE);
incstate();
setstatedelay(75);
@ -2588,7 +2588,7 @@ void Game::updatestate(void)
//Level complete! (Space Station 1)
unlocknum(0);
lastsaved = 1;
music.play(0);
music.play(Music_PATHCOMPLETE);
incstate();
setstatedelay(75);
@ -2655,7 +2655,7 @@ void Game::updatestate(void)
//Level complete! (Tower)
unlocknum(2);
lastsaved = 3;
music.play(0);
music.play(Music_PATHCOMPLETE);
incstate();
setstatedelay(75);
@ -2863,7 +2863,7 @@ void Game::updatestate(void)
break;
case 3101:
quittomenu();
music.play(6); //should be after quittomenu();
music.play(Music_PRESENTINGVVVVVV); //should be after quittomenu();
setstate(0);
break;
@ -2879,7 +2879,7 @@ void Game::updatestate(void)
crewstats[0] = true;
incstate();
setstatedelay(75);
music.play(7);
music.play(Music_PLENARY);
graphics.createtextboxflipme("", -1, 12, 164, 165, 255);
graphics.addline(" ");
@ -5006,7 +5006,10 @@ void Game::start(void)
deathseq = -1;
lifeseq = 0;
if (!nocutscenes) music.play(5);
if (!nocutscenes)
{
music.play(Music_PAUSE);
}
}
void Game::deathsequence(void)
@ -7290,7 +7293,7 @@ void Game::returntolab(void)
savedir = obj.entities[player].dir;
}
music.play(11);
music.play(Music_PIPEDREAM);
}
#if !defined(NO_CUSTOM_LEVELS) && !defined(NO_EDITOR)

View file

@ -954,11 +954,11 @@ static void menuactionpress(void)
{
if (graphics.setflipmode)
{
music.play(9); // ecroF evitisoP
music.play(Music_POSITIVEFORCEREVERSED);
}
else
{
music.play(2); // Positive Force
music.play(Music_POSITIVEFORCE);
}
}
}
@ -2045,7 +2045,7 @@ static void menuactionpress(void)
case Menu::gameover2:
//back
music.playef(11);
music.play(6);
music.play(Music_PRESENTINGVVVVVV);
game.returntomenu(Menu::playmodes);
map.nexttowercolour();
break;
@ -2109,7 +2109,7 @@ static void menuactionpress(void)
case 0:
//back
music.playef(11);
music.play(6);
music.play(Music_PRESENTINGVVVVVV);
game.returntomenu(Menu::timetrials);
map.nexttowercolour();
break;
@ -2122,7 +2122,7 @@ static void menuactionpress(void)
break;
case Menu::gamecompletecontinue:
case Menu::nodeathmodecomplete2:
music.play(6);
music.play(Music_PRESENTINGVVVVVV);
music.playef(11);
game.returnmenu();
map.nexttowercolour();
@ -2363,7 +2363,7 @@ void titleinput(void)
if (!game.menustart)
{
game.menustart = true;
music.play(6);
music.play(Music_PRESENTINGVVVVVV);
music.playef(18);
game.screenshake = 10;
game.flashlight = 5;
@ -2886,7 +2886,7 @@ void mapinput(void)
else
{
game.quittomenu();
music.play(6); //should be after game.quittomenu()
music.play(Music_PRESENTINGVVVVVV); // should be after game.quittomenu()
game.fadetomenu = false;
}
}

View file

@ -27,7 +27,7 @@ void titlelogic(void)
{
if (game.menudest == Menu::mainmenu)
{
music.play(6);
music.play(Music_PRESENTINGVVVVVV);
}
else if (game.menudest == Menu::gameover2)
{
@ -110,7 +110,7 @@ void gamecompletelogic2(void)
//Fix the save thingy
game.deletequick();
int tmp=music.currentsong;
music.currentsong=4;
music.currentsong = Music_PASSIONFOREXPLORING;
obj.flags[67] = true;
game.savetele();
music.currentsong=tmp;
@ -562,7 +562,7 @@ void gamelogic(void)
game.swntimer -= 1;
if (game.swntimer <= 0)
{
music.niceplay(8);
music.niceplay(Music_PREDESTINEDFATE);
game.swngame = 5;
}
else
@ -690,7 +690,7 @@ void gamelogic(void)
{
game.swngame = 3;
obj.createentity(-8, 84 - 32, 11, 8); // (horizontal gravity line)
music.niceplay(2);
music.niceplay(Music_POSITIVEFORCE);
game.swndeaths = game.deathcounts;
}
else if (game.swngame == 5) //remove line
@ -709,7 +709,7 @@ void gamelogic(void)
else if (game.swngame == 6) //Init the super gravitron
{
game.swngame = 7;
music.niceplay(3);
music.niceplay(Music_POTENTIALFORANYTHING);
}
else if (game.swngame == 7) //introduce game b
{
@ -761,22 +761,22 @@ void gamelogic(void)
switch(game.timetriallevel)
{
case 0:
music.play(1);
music.play(Music_PUSHINGONWARDS);
break;
case 1:
music.play(3);
music.play(Music_POTENTIALFORANYTHING);
break;
case 2:
music.play(2);
music.play(Music_POSITIVEFORCE);
break;
case 3:
music.play(1);
music.play(Music_PUSHINGONWARDS);
break;
case 4:
music.play(12);
music.play(Music_PRESSURECOOKER);
break;
case 5:
music.play(15);
music.play(Music_PREDESTINEDFATEREMIX);
break;
}
music.playef(22);

View file

@ -953,9 +953,9 @@ void mapclass::gotoroom(int rx, int ry)
}
//Final level for time trial
if (game.intimetrial)
if (game.intimetrial && game.roomx == 46 && game.roomy == 54)
{
if (game.roomx == 46 && game.roomy == 54) music.niceplay(15); //Final level remix
music.niceplay(Music_PREDESTINEDFATEREMIX);
}
}
#if !defined(NO_CUSTOM_LEVELS)

View file

@ -966,9 +966,12 @@ void musicclass::play(int t)
return;
}
if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks)))
if (currentsong == Music_PATHCOMPLETE ||
currentsong == Music_PLENARY ||
(!map.custommode && (currentsong == Music_PATHCOMPLETE + num_mmmmmm_tracks
|| currentsong == Music_PLENARY + num_mmmmmm_tracks)))
{
// Level Complete theme, no fade in or repeat
// No fade in or repeat
if (musicTracks[t].Play(false))
{
m_doFadeInVol = false;

View file

@ -11,6 +11,26 @@
/* It is advised that USER_VOLUME_MAX be divisible by this. */
#define USER_VOLUME_STEP 32
enum
{
Music_PATHCOMPLETE = 0,
Music_PUSHINGONWARDS = 1,
Music_POSITIVEFORCE = 2,
Music_POTENTIALFORANYTHING = 3,
Music_PASSIONFOREXPLORING = 4,
Music_PAUSE = 5,
Music_PRESENTINGVVVVVV = 6,
Music_PLENARY = 7,
Music_PREDESTINEDFATE = 8,
Music_POSITIVEFORCEREVERSED = 9,
Music_POPULARPOTPOURRI = 10,
Music_PIPEDREAM = 11,
Music_PRESSURECOOKER = 12,
Music_PACEDENERGY = 13,
Music_PIERCINGTHESKY = 14,
Music_PREDESTINEDFATEREMIX = 15
};
class musicclass
{
public:

View file

@ -409,7 +409,7 @@ void scriptclass::run(void)
}
if (words[0] == "trinketscriptmusic")
{
music.play(4);
music.play(Music_PASSIONFOREXPLORING);
}
if (words[0] == "gotoposition")
{
@ -2527,7 +2527,7 @@ static void gotoerrorloadinglevel(void)
game.quittomenu();
game.createmenu(Menu::errorloadinglevel);
music.currentsong = -1; /* otherwise music.play won't work */
music.play(6); /* title screen music */
music.play(Music_PRESENTINGVVVVVV);
}
#define DECLARE_MODE_FUNC(funcname, modename) \
@ -2721,7 +2721,7 @@ void scriptclass::startgamemode(const enum StartMode mode)
game.insecretlab = true;
map.showteleporters = true;
music.play(11);
music.play(Music_PIPEDREAM);
graphics.fademode = FADE_START_FADEIN;
break;
@ -3044,7 +3044,7 @@ void scriptclass::teleport(void)
{
/* Special case: Ship music needs to be set here;
* ship teleporter on music map is -1 for jukebox. */
music.niceplay(4);
music.niceplay(Music_PASSIONFOREXPLORING);
}
game.savetele_textbox();
}