mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 08:12:53 +01:00
Add load and save audio options. Fix all sounds not pausing
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
#define RCT2_ADDRESS_DSOUND_GUID 0x009AAC5D
|
||||
|
||||
#define RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER 0x009AAC6E
|
||||
// When all sounds reversed replace with gConfigSound.ride_music
|
||||
#define RCT2_ADDRESS_CONFIG_MUSIC 0x009AAC72
|
||||
|
||||
#define RCT2_ADDRESS_CONFIG_FLAGS 0x009AAC74
|
||||
|
||||
@@ -1768,6 +1768,18 @@ void audio_init2(int device)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= 1 << 4;
|
||||
config_save_default();
|
||||
}
|
||||
|
||||
// When all sound code is reversed this can be removed.
|
||||
if (!gConfigSound.sound){
|
||||
toggle_all_sounds();
|
||||
}
|
||||
|
||||
// When all sound code is reversed this can be removed.
|
||||
if (!gConfigSound.ride_music){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) ^= 1;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) == 0)
|
||||
stop_ride_music();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1794,19 +1806,34 @@ void audio_close()
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x006BAB8A */
|
||||
void toggle_all_sounds(){
|
||||
// When all sound code is reversed replace with gConfigSound.sound
|
||||
RCT2_GLOBAL(0x009AF59D, uint8) ^= 1;
|
||||
if (RCT2_GLOBAL(0x009AF59D, uint8) == 0) {
|
||||
stop_title_music();
|
||||
pause_sounds();
|
||||
}
|
||||
else{
|
||||
unpause_sounds();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BABB4
|
||||
*/
|
||||
void pause_sounds()
|
||||
{
|
||||
if (++RCT2_GLOBAL(0x009AF59C, uint8) == 1) {
|
||||
// When all sound code is reversed replace with gConfigSound.sound
|
||||
RCT2_GLOBAL(0x009AF59C, uint8) = 1;
|
||||
if (RCT2_GLOBAL(0x009AF59C, uint8) == 1) {
|
||||
stop_other_sounds();
|
||||
stop_vehicle_sounds();
|
||||
stop_ride_music();
|
||||
stop_crowd_sound();
|
||||
}
|
||||
g_sounds_disabled = 1;
|
||||
gConfigSound.sound = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1815,8 +1842,9 @@ void pause_sounds()
|
||||
*/
|
||||
void unpause_sounds()
|
||||
{
|
||||
RCT2_GLOBAL(0x009AF59C, uint8)--;
|
||||
g_sounds_disabled = 0;
|
||||
// When all sound code is reversed replace with gConfigSound.sound
|
||||
RCT2_GLOBAL(0x009AF59C, uint8) = 0;
|
||||
gConfigSound.sound = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,13 +218,10 @@ void audio_init1();
|
||||
void audio_init2(int device);
|
||||
void audio_close();
|
||||
void pause_sounds();
|
||||
void toggle_all_sounds();
|
||||
void unpause_sounds();
|
||||
void stop_vehicle_sounds();
|
||||
|
||||
// 0x009AF59C probably does the same job
|
||||
// once it's confirmed and calls in pause_sounds() are reversed, it can be used instead of this
|
||||
int g_sounds_disabled;
|
||||
|
||||
typedef enum {
|
||||
SOUND_LIFT_1 = 0,
|
||||
SOUND_TRACK_FRICTION_1 = 1,
|
||||
|
||||
@@ -172,6 +172,8 @@ config_property_definition _soundDefinitions[] = {
|
||||
{ offsetof(sound_configuration, forced_software_buffering), "forced_software_buffering", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(sound_configuration, sound_quality), "sound_quality", CONFIG_VALUE_TYPE_UINT8, 2, NULL },
|
||||
{ offsetof(sound_configuration, title_music), "title_music", CONFIG_VALUE_TYPE_UINT8, 2, NULL },
|
||||
{ offsetof(sound_configuration, sound), "sound", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
|
||||
{ offsetof(sound_configuration, ride_music), "ride_music", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
|
||||
};
|
||||
|
||||
config_section_definition _sectionDefinitions[] = {
|
||||
|
||||
@@ -141,6 +141,8 @@ typedef struct {
|
||||
sint8 forced_software_buffering;
|
||||
sint8 sound_quality;
|
||||
uint8 title_music;
|
||||
uint8 sound;
|
||||
uint8 ride_music;
|
||||
} sound_configuration;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -345,14 +345,17 @@ static void window_options_mouseup()
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_SOUND_CHECKBOX:
|
||||
if (g_sounds_disabled)
|
||||
unpause_sounds();
|
||||
else
|
||||
pause_sounds();
|
||||
toggle_all_sounds();
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_MUSIC_CHECKBOX:
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) ^= 1;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) == 0)
|
||||
stop_ride_music();
|
||||
|
||||
gConfigSound.ride_music ^= 1;
|
||||
config_save_default();
|
||||
window_invalidate(w);
|
||||
break;
|
||||
}
|
||||
@@ -730,7 +733,7 @@ static void window_options_invalidate()
|
||||
// sound quality: low/medium/high
|
||||
RCT2_GLOBAL(0x013CE952 + 10, uint16) = STR_SOUND_LOW + gConfigSound.sound_quality;
|
||||
|
||||
widget_set_checkbox_value(w, WIDX_SOUND_CHECKBOX, !g_sounds_disabled);
|
||||
widget_set_checkbox_value(w, WIDX_SOUND_CHECKBOX, gConfigSound.sound);
|
||||
widget_set_checkbox_value(w, WIDX_MUSIC_CHECKBOX, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8));
|
||||
|
||||
window_options_widgets[WIDX_SOUND].type = WWT_DROPDOWN;
|
||||
|
||||
Reference in New Issue
Block a user