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

Implement haltedsong

This fixes a bug where if a track was resumed, pausing it by unfocusing
the window (if enabled, of course) would not resume it after refocusing
the window.

This happens because resuming the music doesn't change currentsong back
from -1, and the window refocusing code checks that currentsong isn't -1
before resuming music.

haltedsong is only used when resuming music. It is set back to -1 when
resuming music or when playing a new track.
This commit is contained in:
Misa 2023-06-08 15:38:26 -07:00
parent e36c2764fb
commit dc9c51dbf3
2 changed files with 9 additions and 0 deletions

View file

@ -738,6 +738,7 @@ musicclass::musicclass(void)
user_sound_volume = USER_VOLUME_MAX; user_sound_volume = USER_VOLUME_MAX;
currentsong = -1; currentsong = -1;
haltedsong = -1;
nicechange = -1; nicechange = -1;
nicefade = false; nicefade = false;
quick_fade = true; quick_fade = true;
@ -953,6 +954,7 @@ void musicclass::play(int t)
} }
currentsong = t; currentsong = t;
haltedsong = -1;
if (t == -1) if (t == -1)
{ {
@ -1009,6 +1011,11 @@ void musicclass::play(int t)
void musicclass::resume(void) void musicclass::resume(void)
{ {
if (currentsong == -1)
{
currentsong = haltedsong;
haltedsong = -1;
}
MusicTrack::Resume(); MusicTrack::Resume();
} }
@ -1037,6 +1044,7 @@ void musicclass::haltdasmusik(const bool from_fade)
{ {
/* Just pauses music. This is intended. */ /* Just pauses music. This is intended. */
pause(); pause();
haltedsong = currentsong;
currentsong = -1; currentsong = -1;
m_doFadeInVol = false; m_doFadeInVol = false;
m_doFadeOutVol = false; m_doFadeOutVol = false;

View file

@ -89,6 +89,7 @@ public:
void changemusicarea(int x, int y); void changemusicarea(int x, int y);
int currentsong; int currentsong;
int haltedsong;
void playef(int t); void playef(int t);
void pauseef(void); void pauseef(void);