From dc9c51dbf338874d0af8daa042e902d331d603ab Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 8 Jun 2023 15:38:26 -0700 Subject: [PATCH] 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. --- desktop_version/src/Music.cpp | 8 ++++++++ desktop_version/src/Music.h | 1 + 2 files changed, 9 insertions(+) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 7ed403c3..168a16da 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -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; diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index 2a75ec08..4085fb0b 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -89,6 +89,7 @@ public: void changemusicarea(int x, int y); int currentsong; + int haltedsong; void playef(int t); void pauseef(void);