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:
parent
c2ac1dc7d2
commit
5419e822d8
3 changed files with 21 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
|
||||
bool custompd;
|
||||
|
||||
int fadeoutqueuesong; // -1 if no song queued
|
||||
bool dontquickfade;
|
||||
|
||||
// MMMMMM mod settings
|
||||
bool mmmmmm;
|
||||
bool usingmmmmmm;
|
||||
|
|
|
@ -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")
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue