diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 12e7dfbe..e6566b79 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -214,6 +214,8 @@ musicclass::musicclass() nicefade = 0; resumesong = 0; volume = 0.0f; + fadeoutqueuesong = -1; + dontquickfade = false; } void musicclass::play(int t) @@ -260,7 +262,16 @@ void musicclass::play(int t) // musicchannel = musicchan[currentsong].play(0); // musicchannel.soundTransform = new SoundTransform(0); // 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()); } @@ -358,6 +369,11 @@ void musicclass::processmusic() //if (musicfade > 0) processmusicfade(); //if (musicfadein > 0) processmusicfadein(); + if (fadeoutqueuesong != -1 && Mix_PlayingMusic() == 0) { + play(fadeoutqueuesong); + fadeoutqueuesong = -1; + } + if (nicefade == 1 && Mix_PlayingMusic() == 0) { play(nicechange); diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index 7e2a67f1..dd081eae 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -56,6 +56,9 @@ public: bool custompd; + int fadeoutqueuesong; // -1 if no song queued + bool dontquickfade; + // MMMMMM mod settings bool mmmmmm; bool usingmmmmmm; diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 5069f694..7736aa0b 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -248,6 +248,7 @@ void scriptclass::run( KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, if (words[0] == "musicfadeout") { music.fadeout(); + music.dontquickfade = true; } if (words[0] == "musicfadein") {