Rename public sound config data members

This commit is contained in:
Hielke Morsink 2022-10-16 17:50:42 +02:00
parent f605b02630
commit 371470b5d5
No known key found for this signature in database
GPG Key ID: FE0B343DF883E7F2
8 changed files with 67 additions and 67 deletions

View File

@ -146,8 +146,8 @@ void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length)
else
{
auto group = channel->GetGroup();
if ((group != MixerGroup::Sound || gConfigSound.sound_enabled) && gConfigSound.master_sound_enabled
&& gConfigSound.master_volume != 0)
if ((group != MixerGroup::Sound || gConfigSound.SoundEnabled) && gConfigSound.MasterSoundEnabled
&& gConfigSound.MasterVolume != 0)
{
MixChannel(channel.get(), dst, length);
}
@ -159,14 +159,14 @@ void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length)
void AudioMixer::UpdateAdjustedSound()
{
// Did the volume level get changed? Recalculate level in this case.
if (_settingSoundVolume != gConfigSound.sound_volume)
if (_settingSoundVolume != gConfigSound.SoundVolume)
{
_settingSoundVolume = gConfigSound.sound_volume;
_settingSoundVolume = gConfigSound.SoundVolume;
_adjustSoundVolume = powf(static_cast<float>(_settingSoundVolume) / 100.f, 10.f / 6.f);
}
if (_settingMusicVolume != gConfigSound.ride_music_volume)
if (_settingMusicVolume != gConfigSound.AudioFocus)
{
_settingMusicVolume = gConfigSound.ride_music_volume;
_settingMusicVolume = gConfigSound.AudioFocus;
_adjustMusicVolume = powf(static_cast<float>(_settingMusicVolume) / 100.f, 10.f / 6.f);
}
}
@ -297,7 +297,7 @@ void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len
int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len)
{
float volumeAdjust = _volume;
volumeAdjust *= gConfigSound.master_sound_enabled ? (static_cast<float>(gConfigSound.master_volume) / 100.0f) : 0.0f;
volumeAdjust *= gConfigSound.MasterSoundEnabled ? (static_cast<float>(gConfigSound.MasterVolume) / 100.0f) : 0.0f;
switch (channel->GetGroup())
{

View File

@ -1293,14 +1293,14 @@ private:
switch (widgetIndex)
{
case WIDX_SOUND_CHECKBOX:
gConfigSound.sound_enabled = !gConfigSound.sound_enabled;
gConfigSound.SoundEnabled = !gConfigSound.SoundEnabled;
config_save_default();
Invalidate();
break;
case WIDX_MASTER_SOUND_CHECKBOX:
gConfigSound.master_sound_enabled = !gConfigSound.master_sound_enabled;
if (!gConfigSound.master_sound_enabled)
gConfigSound.MasterSoundEnabled = !gConfigSound.MasterSoundEnabled;
if (!gConfigSound.MasterSoundEnabled)
OpenRCT2::Audio::Pause();
else
OpenRCT2::Audio::Resume();
@ -1310,8 +1310,8 @@ private:
break;
case WIDX_MUSIC_CHECKBOX:
gConfigSound.ride_music_enabled = !gConfigSound.ride_music_enabled;
if (!gConfigSound.ride_music_enabled)
gConfigSound.RideMusicEnabled = !gConfigSound.RideMusicEnabled;
if (!gConfigSound.RideMusicEnabled)
{
OpenRCT2::RideAudio::StopAllChannels();
}
@ -1358,9 +1358,9 @@ private:
gDropdownItems[numItems].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[numItems++].Args = TitleMusicNames[2];
ShowDropdown(widget, numItems);
if (gConfigSound.title_music == TitleMusicKind::None)
if (gConfigSound.TitleMusic == TitleMusicKind::None)
Dropdown::SetChecked(0, true);
else if (gConfigSound.title_music == TitleMusicKind::Rct2)
else if (gConfigSound.TitleMusic == TitleMusicKind::Rct2)
Dropdown::SetChecked(1, true);
}
else
@ -1373,7 +1373,7 @@ private:
gDropdownItems[numItems++].Args = musicName;
}
ShowDropdown(widget, numItems);
Dropdown::SetChecked(EnumValue(gConfigSound.title_music), true);
Dropdown::SetChecked(EnumValue(gConfigSound.TitleMusic), true);
}
break;
}
@ -1392,13 +1392,13 @@ private:
if (dropdownIndex == 0)
{
audioContext->SetOutputDevice("");
gConfigSound.device = "";
gConfigSound.Device = "";
}
else
{
const auto& deviceName = GetDeviceName(dropdownIndex);
audioContext->SetOutputDevice(deviceName);
gConfigSound.device = deviceName;
gConfigSound.Device = deviceName;
}
config_save_default();
OpenRCT2::Audio::PlayTitleMusic();
@ -1413,7 +1413,7 @@ private:
titleMusic = TitleMusicKind::Rct2;
}
gConfigSound.title_music = titleMusic;
gConfigSound.TitleMusic = titleMusic;
config_save_default();
Invalidate();
@ -1432,9 +1432,9 @@ private:
const auto& masterVolumeWidget = widgets[WIDX_MASTER_VOLUME];
const auto& masterVolumeScroll = scrolls[0];
uint8_t masterVolume = GetScrollPercentage(masterVolumeWidget, masterVolumeScroll);
if (masterVolume != gConfigSound.master_volume)
if (masterVolume != gConfigSound.MasterVolume)
{
gConfigSound.master_volume = masterVolume;
gConfigSound.MasterVolume = masterVolume;
config_save_default();
InvalidateWidget(WIDX_MASTER_VOLUME);
}
@ -1442,9 +1442,9 @@ private:
const auto& soundVolumeWidget = widgets[WIDX_MASTER_VOLUME];
const auto& soundVolumeScroll = scrolls[1];
uint8_t soundVolume = GetScrollPercentage(soundVolumeWidget, soundVolumeScroll);
if (soundVolume != gConfigSound.sound_volume)
if (soundVolume != gConfigSound.SoundVolume)
{
gConfigSound.sound_volume = soundVolume;
gConfigSound.SoundVolume = soundVolume;
config_save_default();
InvalidateWidget(WIDX_SOUND_VOLUME);
}
@ -1452,9 +1452,9 @@ private:
const auto& musicVolumeWidget = widgets[WIDX_MASTER_VOLUME];
const auto& musicVolumeScroll = scrolls[2];
uint8_t rideMusicVolume = GetScrollPercentage(musicVolumeWidget, musicVolumeScroll);
if (rideMusicVolume != gConfigSound.ride_music_volume)
if (rideMusicVolume != gConfigSound.AudioFocus)
{
gConfigSound.ride_music_volume = rideMusicVolume;
gConfigSound.AudioFocus = rideMusicVolume;
config_save_default();
InvalidateWidget(WIDX_MUSIC_VOLUME);
}
@ -1467,7 +1467,7 @@ private:
StringId GetTitleMusicName()
{
auto index = EnumValue(gConfigSound.title_music);
auto index = EnumValue(gConfigSound.TitleMusic);
if (index < 0 || static_cast<size_t>(index) >= std::size(TitleMusicNames))
{
index = EnumValue(TitleMusicKind::None);
@ -1506,19 +1506,19 @@ private:
widgets[WIDX_TITLE_MUSIC].text = GetTitleMusicName();
SetCheckboxValue(WIDX_SOUND_CHECKBOX, gConfigSound.sound_enabled);
SetCheckboxValue(WIDX_MASTER_SOUND_CHECKBOX, gConfigSound.master_sound_enabled);
SetCheckboxValue(WIDX_MUSIC_CHECKBOX, gConfigSound.ride_music_enabled);
SetCheckboxValue(WIDX_SOUND_CHECKBOX, gConfigSound.SoundEnabled);
SetCheckboxValue(WIDX_MASTER_SOUND_CHECKBOX, gConfigSound.MasterSoundEnabled);
SetCheckboxValue(WIDX_MUSIC_CHECKBOX, gConfigSound.RideMusicEnabled);
SetCheckboxValue(WIDX_AUDIO_FOCUS_CHECKBOX, gConfigSound.audio_focus);
WidgetSetEnabled(*this, WIDX_SOUND_CHECKBOX, gConfigSound.master_sound_enabled);
WidgetSetEnabled(*this, WIDX_MUSIC_CHECKBOX, gConfigSound.master_sound_enabled);
WidgetSetEnabled(*this, WIDX_SOUND_CHECKBOX, gConfigSound.MasterSoundEnabled);
WidgetSetEnabled(*this, WIDX_MUSIC_CHECKBOX, gConfigSound.MasterSoundEnabled);
// Initialize only on first frame, otherwise the scrollbars won't be able to be modified
if (frame_no == 0)
{
InitializeScrollPosition(WIDX_MASTER_VOLUME, 0, gConfigSound.master_volume);
InitializeScrollPosition(WIDX_SOUND_VOLUME, 1, gConfigSound.sound_volume);
InitializeScrollPosition(WIDX_MUSIC_VOLUME, 2, gConfigSound.ride_music_volume);
InitializeScrollPosition(WIDX_MASTER_VOLUME, 0, gConfigSound.MasterVolume);
InitializeScrollPosition(WIDX_SOUND_VOLUME, 1, gConfigSound.SoundVolume);
InitializeScrollPosition(WIDX_MUSIC_VOLUME, 2, gConfigSound.AudioFocus);
}
}

View File

@ -459,7 +459,7 @@ namespace OpenRCT2
Init();
PopulateDevices();
InitRideSoundsAndInfo();
gGameSoundsOff = !gConfigSound.master_sound_enabled;
gGameSoundsOff = !gConfigSound.MasterSoundEnabled;
}
chat_init();

View File

@ -65,7 +65,7 @@ namespace OpenRCT2::Audio
return false;
if (gGameSoundsOff)
return false;
if (!gConfigSound.sound_enabled)
if (!gConfigSound.SoundEnabled)
return false;
if (gOpenRCT2Headless)
return false;
@ -75,19 +75,19 @@ namespace OpenRCT2::Audio
void Init()
{
auto audioContext = GetContext()->GetAudioContext();
if (gConfigSound.device.empty())
if (gConfigSound.Device.empty())
{
audioContext->SetOutputDevice("");
_currentAudioDevice = 0;
}
else
{
audioContext->SetOutputDevice(gConfigSound.device);
audioContext->SetOutputDevice(gConfigSound.Device);
PopulateDevices();
for (int32_t i = 0; i < GetDeviceCount(); i++)
{
if (_audioDevices[i] == gConfigSound.device)
if (_audioDevices[i] == gConfigSound.Device)
{
_currentAudioDevice = i;
}
@ -256,7 +256,7 @@ namespace OpenRCT2::Audio
static ObjectEntryDescriptor GetTitleMusicDescriptor()
{
switch (gConfigSound.title_music)
switch (gConfigSound.TitleMusic)
{
default:
return {};
@ -379,8 +379,8 @@ namespace OpenRCT2::Audio
void ToggleAllSounds()
{
gConfigSound.master_sound_enabled = !gConfigSound.master_sound_enabled;
if (gConfigSound.master_sound_enabled)
gConfigSound.MasterSoundEnabled = !gConfigSound.MasterSoundEnabled;
if (gConfigSound.MasterSoundEnabled)
{
Resume();
PlayTitleMusic();

View File

@ -359,14 +359,14 @@ namespace Config
if (reader->ReadSection("sound"))
{
auto model = &gConfigSound;
model->device = reader->GetString("audio_device", "");
model->master_sound_enabled = reader->GetBoolean("master_sound", true);
model->master_volume = reader->GetInt32("master_volume", 100);
model->title_music = static_cast<TitleMusicKind>(reader->GetInt32("title_music", EnumValue(TitleMusicKind::Rct2)));
model->sound_enabled = reader->GetBoolean("sound", true);
model->sound_volume = reader->GetInt32("sound_volume", 100);
model->ride_music_enabled = reader->GetBoolean("ride_music", true);
model->ride_music_volume = reader->GetInt32("ride_music_volume", 100);
model->Device = reader->GetString("audio_device", "");
model->MasterSoundEnabled = reader->GetBoolean("master_sound", true);
model->MasterVolume = reader->GetInt32("master_volume", 100);
model->TitleMusic = static_cast<TitleMusicKind>(reader->GetInt32("title_music", EnumValue(TitleMusicKind::Rct2)));
model->SoundEnabled = reader->GetBoolean("sound", true);
model->SoundVolume = reader->GetInt32("sound_volume", 100);
model->RideMusicEnabled = reader->GetBoolean("ride_music", true);
model->AudioFocus = reader->GetInt32("ride_music_volume", 100);
model->audio_focus = reader->GetBoolean("audio_focus", false);
}
}
@ -375,14 +375,14 @@ namespace Config
{
auto model = &gConfigSound;
writer->WriteSection("sound");
writer->WriteString("audio_device", model->device);
writer->WriteBoolean("master_sound", model->master_sound_enabled);
writer->WriteInt32("master_volume", model->master_volume);
writer->WriteInt32("title_music", EnumValue(model->title_music));
writer->WriteBoolean("sound", model->sound_enabled);
writer->WriteInt32("sound_volume", model->sound_volume);
writer->WriteBoolean("ride_music", model->ride_music_enabled);
writer->WriteInt32("ride_music_volume", model->ride_music_volume);
writer->WriteString("audio_device", model->Device);
writer->WriteBoolean("master_sound", model->MasterSoundEnabled);
writer->WriteInt32("master_volume", model->MasterVolume);
writer->WriteInt32("title_music", EnumValue(model->TitleMusic));
writer->WriteBoolean("sound", model->SoundEnabled);
writer->WriteInt32("sound_volume", model->SoundVolume);
writer->WriteBoolean("ride_music", model->RideMusicEnabled);
writer->WriteInt32("ride_music_volume", model->AudioFocus);
writer->WriteBoolean("audio_focus", model->audio_focus);
}

View File

@ -139,14 +139,14 @@ struct InterfaceConfiguration
struct SoundConfiguration
{
std::string device;
bool master_sound_enabled;
uint8_t master_volume;
TitleMusicKind title_music;
bool sound_enabled;
uint8_t sound_volume;
bool ride_music_enabled;
uint8_t ride_music_volume;
std::string Device;
bool MasterSoundEnabled;
uint8_t MasterVolume;
TitleMusicKind TitleMusic;
bool SoundEnabled;
uint8_t SoundVolume;
bool RideMusicEnabled;
uint8_t AudioFocus;
bool audio_focus;
};

View File

@ -1249,7 +1249,7 @@ void peep_update_crowd_noise()
if (OpenRCT2::Audio::gGameSoundsOff)
return;
if (!gConfigSound.sound_enabled)
if (!gConfigSound.SoundEnabled)
return;
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)

View File

@ -257,7 +257,7 @@ namespace OpenRCT2::RideAudio
return;
// TODO Allow circus music (CSS24) to play if ride music is disabled (that should be sound)
if (gGameSoundsOff || !gConfigSound.ride_music_enabled)
if (gGameSoundsOff || !gConfigSound.RideMusicEnabled)
return;
StopInactiveRideMusicChannels();