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

Stop the game from freezing if we play a song during a fadeout (#61)

This commit is contained in:
Info Teddy 2020-01-12 19:33:58 -08:00 committed by Ethan Lee
parent c2ac1dc7d2
commit 5419e822d8
3 changed files with 21 additions and 1 deletions

View file

@ -214,6 +214,8 @@ musicclass::musicclass()
nicefade = 0; nicefade = 0;
resumesong = 0; resumesong = 0;
volume = 0.0f; volume = 0.0f;
fadeoutqueuesong = -1;
dontquickfade = false;
} }
void musicclass::play(int t) void musicclass::play(int t)
@ -260,7 +262,16 @@ void musicclass::play(int t)
// musicchannel = musicchan[currentsong].play(0); // musicchannel = musicchan[currentsong].play(0);
// musicchannel.soundTransform = new SoundTransform(0); // musicchannel.soundTransform = new SoundTransform(0);
// musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic); // musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic);
if(Mix_FadeInMusic(musicTracks[t].m_music, -1, 3000)==-1) if (Mix_FadingMusic() == MIX_FADING_OUT) {
// We're already fading out
fadeoutqueuesong = t;
currentsong = -1;
if (!dontquickfade)
Mix_FadeOutMusic(500); // fade out quicker
else
dontquickfade = false;
}
else if(Mix_FadeInMusic(musicTracks[t].m_music, -1, 3000)==-1)
{ {
printf("Mix_FadeInMusic: %s\n", Mix_GetError()); printf("Mix_FadeInMusic: %s\n", Mix_GetError());
} }
@ -358,6 +369,11 @@ void musicclass::processmusic()
//if (musicfade > 0) processmusicfade(); //if (musicfade > 0) processmusicfade();
//if (musicfadein > 0) processmusicfadein(); //if (musicfadein > 0) processmusicfadein();
if (fadeoutqueuesong != -1 && Mix_PlayingMusic() == 0) {
play(fadeoutqueuesong);
fadeoutqueuesong = -1;
}
if (nicefade == 1 && Mix_PlayingMusic() == 0) if (nicefade == 1 && Mix_PlayingMusic() == 0)
{ {
play(nicechange); play(nicechange);

View file

@ -56,6 +56,9 @@ public:
bool custompd; bool custompd;
int fadeoutqueuesong; // -1 if no song queued
bool dontquickfade;
// MMMMMM mod settings // MMMMMM mod settings
bool mmmmmm; bool mmmmmm;
bool usingmmmmmm; bool usingmmmmmm;

View file

@ -248,6 +248,7 @@ void scriptclass::run( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map,
if (words[0] == "musicfadeout") if (words[0] == "musicfadeout")
{ {
music.fadeout(); music.fadeout();
music.dontquickfade = true;
} }
if (words[0] == "musicfadein") if (words[0] == "musicfadein")
{ {