tr2/option: fix music resuming on volume change

Resolves #1707.
This commit is contained in:
Marcin Kurczewski 2024-11-02 18:39:45 +01:00
parent 1e72c4049e
commit 9a3a2ddfb2
4 changed files with 25 additions and 5 deletions

View file

@ -28,6 +28,7 @@
- removed hardcoded `0` key binding for flares
- removed hardcoded cooldown of 15 frames for medipacks
- changed text backend to accept named sequences (eg. "\{arrow up}" and similar)
- changed inventory to pause the music rather than muting it (#1707)
- improved FMV mode appearance - removed black scanlines (#1729)
- improved FMV mode behavior - stopped switching screen resolutions (#1729)
- improved screenshots: now saved in the screenshots/ directory with level titles and timestamps as JPG or PNG, similar to TR1X (#1773)
@ -57,6 +58,7 @@
- fixed a crash when firing grenades at Xian guards in statue form (#1561)
- fixed harpoon bolts damaging inactive enemies (#1804)
- fixed enemies that are run over by the skidoo not being counted in the statistics (#1772)
- fixed sound settings resuming the music (#1707)
## [0.5](https://github.com/LostArtefacts/TRX/compare/afaf12a...tr2-0.5) - 2024-10-08
- added `/sfx` command

View file

@ -208,7 +208,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)
Sound_StopAllSamples();
if (inventory_mode != INV_TITLE_MODE) {
Music_SetVolume(0);
Music_Pause();
}
switch (inventory_mode) {
@ -765,7 +765,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)
if (g_Inv_Chosen == NO_OBJECT) {
if (inventory_mode != INV_TITLE_MODE && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
Music_Unpause();
}
return 0;
}
@ -773,7 +773,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)
switch (g_Inv_Chosen) {
case O_PASSPORT_OPTION:
if (g_Inv_ExtraData[0] == 1 && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
Music_Unpause();
}
return 1;
@ -801,8 +801,8 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode)
break;
}
if (inventory_mode != INV_TITLE_MODE && g_OptionMusicVolume != 0) {
Music_SetVolume(25 * g_OptionMusicVolume + 5);
if (inventory_mode != INV_TITLE_MODE) {
Music_Unpause();
}
return 0;
}

View file

@ -9,3 +9,5 @@ void __cdecl Music_Stop(void);
bool __cdecl Music_PlaySynced(int16_t track_id);
double __cdecl Music_GetTimestamp(void);
void __cdecl Music_SetVolume(int32_t volume);
void Music_Pause(void);
void Music_Unpause(void);

View file

@ -179,3 +179,19 @@ void __cdecl Music_SetVolume(int32_t volume)
Audio_Stream_SetVolume(m_AudioStreamID, m_MusicVolume);
}
}
void Music_Pause(void)
{
if (m_AudioStreamID < 0) {
return;
}
Audio_Stream_Pause(m_AudioStreamID);
}
void Music_Unpause(void)
{
if (m_AudioStreamID < 0) {
return;
}
Audio_Stream_Unpause(m_AudioStreamID);
}