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

View File

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