mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 09:28:15 +03:00
Stop the game from freezing if we play a song during a fadeout (#61)
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user