TuneManager: clear current song if music is disabled, so music can resume later

This commit is contained in:
James R 2023-12-23 01:12:03 -08:00
parent 7744a2823e
commit 2d450b05f8
4 changed files with 13 additions and 0 deletions

View file

@ -183,6 +183,11 @@ void Music_Tick(void)
g_tunes.tick();
}
void Music_Flip(void)
{
g_tunes.flip();
}
void Music_Play(const char* id)
{
Tune* tune = g_tunes.find(id);

View file

@ -144,6 +144,11 @@ void Music_Init(void);
// Call this every tic to update the music.
void Music_Tick(void);
// Flips the internal state so music is reloaded next tick.
// This is required when disabling music during runtime so
// the music plays again when re-enabled.
void Music_Flip(void);
#ifdef __cplusplus
} // extern "C"

View file

@ -53,6 +53,8 @@ public:
return res.first->second;
}
void flip() { current_song_ = {}; }
void tick();
void pause_unpause() const;

View file

@ -2515,6 +2515,7 @@ void GameDigiMusic_OnChange(void)
{
digital_disabled = true;
I_UnloadSong();
Music_Flip();
}
}