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

Clean up don't-quick-fade signaling

First, the variable has been inverted, because it's bad practice to have
booleans with negative names. Secondly, instead of magically setting a
signaling variable when calling fadeout(), fadeout() now has a parameter
to set the quick_fade attribute, which is much cleaner than doing the
magical assignment that could potentially look unrelated.
This commit is contained in:
Misa 2020-11-06 00:51:04 -08:00 committed by Ethan Lee
parent 87af9bba04
commit 05b7a38f76
3 changed files with 9 additions and 10 deletions

View file

@ -139,7 +139,7 @@ void musicclass::init()
nicechange = -1; nicechange = -1;
nicefade = false; nicefade = false;
resumesong = 0; resumesong = 0;
dontquickfade = false; quick_fade = true;
songStart = 0; songStart = 0;
songEnd = 0; songEnd = 0;
@ -204,13 +204,13 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade
nicechange = t; nicechange = t;
nicefade = true; nicefade = true;
currentsong = -1; currentsong = -1;
if (!dontquickfade) if (quick_fade)
{ {
Mix_FadeOutMusic(500); // fade out quicker Mix_FadeOutMusic(500); // fade out quicker
} }
else else
{ {
dontquickfade = false; quick_fade = true;
} }
} }
else if(Mix_FadeInMusicPos(musicTracks[t].m_music, -1, fadein_ms, position_sec)==-1) else if(Mix_FadeInMusicPos(musicTracks[t].m_music, -1, fadein_ms, position_sec)==-1)
@ -260,10 +260,11 @@ void musicclass::fadeMusicVolumeIn(int ms)
FadeVolAmountPerFrame = MIX_MAX_VOLUME / (ms / 33); FadeVolAmountPerFrame = MIX_MAX_VOLUME / (ms / 33);
} }
void musicclass::fadeout() void musicclass::fadeout(const bool quick_fade_ /*= true*/)
{ {
Mix_FadeOutMusic(2000); Mix_FadeOutMusic(2000);
resumesong = currentsong; resumesong = currentsong;
quick_fade = quick_fade_;
} }
void musicclass::processmusicfadein() void musicclass::processmusicfadein()
@ -303,8 +304,7 @@ void musicclass::niceplay(int t)
{ {
if(currentsong!=-1) if(currentsong!=-1)
{ {
dontquickfade = true; fadeout(false);
fadeout();
} }
nicefade = true; nicefade = true;
nicechange = t; nicechange = t;

View file

@ -18,7 +18,7 @@ public:
void haltdasmusik(); void haltdasmusik();
void silencedasmusik(); void silencedasmusik();
void fadeMusicVolumeIn(int ms); void fadeMusicVolumeIn(int ms);
void fadeout(); void fadeout(const bool quick_fade_ = true);
void fadein(); void fadein();
void processmusicfadein(); void processmusicfadein();
void processmusic(); void processmusic();
@ -43,7 +43,7 @@ public:
int FadeVolAmountPerFrame; int FadeVolAmountPerFrame;
int musicVolume; int musicVolume;
bool dontquickfade; bool quick_fade;
// MMMMMM mod settings // MMMMMM mod settings
bool mmmmmm; bool mmmmmm;

View file

@ -284,8 +284,7 @@ void scriptclass::run()
} }
if (words[0] == "musicfadeout") if (words[0] == "musicfadeout")
{ {
music.fadeout(); music.fadeout(false);
music.dontquickfade = true;
} }
if (words[0] == "musicfadein") if (words[0] == "musicfadein")
{ {