GUI: Don't apply values from disabled subtitle toggle

When the subtitle toggle controls are disabled for a game, don't
read the value and then set config values based on it.
This caused "Override global audio settings" to always set "subtitles"
and "mute_speech" even when the controls were disabled.

Fixes bug #13007 where "Override global audio settings" always
mutes the speech clips in Hoyle4.
This commit is contained in:
sluicebox 2021-10-14 13:04:53 -05:00
parent 11d1088298
commit b44afb45e6
2 changed files with 16 additions and 9 deletions

View file

@ -231,6 +231,7 @@ void OptionsDialog::init() {
_speechVolumeLabel = nullptr; _speechVolumeLabel = nullptr;
_muteCheckbox = nullptr; _muteCheckbox = nullptr;
_enableSubtitleSettings = false; _enableSubtitleSettings = false;
_enableSubtitleToggle = false;
_subToggleDesc = nullptr; _subToggleDesc = nullptr;
_subToggleGroup = nullptr; _subToggleGroup = nullptr;
_subToggleSubOnly = nullptr; _subToggleSubOnly = nullptr;
@ -909,11 +910,9 @@ void OptionsDialog::apply() {
// Subtitle options // Subtitle options
if (_subToggleGroup) { if (_subToggleGroup) {
if (_enableSubtitleSettings) { if (_enableSubtitleSettings) {
bool subtitles, speech_mute; if (_enableSubtitleToggle) {
int talkspeed; bool subtitles, speech_mute;
int sliderMaxValue = _subSpeedSlider->getMaxValue(); switch (_subToggleGroup->getValue()) {
switch (_subToggleGroup->getValue()) {
case kSubtitlesSpeech: case kSubtitlesSpeech:
subtitles = speech_mute = false; subtitles = speech_mute = false;
break; break;
@ -925,14 +924,19 @@ void OptionsDialog::apply() {
default: default:
subtitles = speech_mute = true; subtitles = speech_mute = true;
break; break;
} }
ConfMan.setBool("subtitles", subtitles, _domain); ConfMan.setBool("subtitles", subtitles, _domain);
ConfMan.setBool("speech_mute", speech_mute, _domain); ConfMan.setBool("speech_mute", speech_mute, _domain);
} else {
ConfMan.removeKey("subtitles", _domain);
ConfMan.removeKey("speech_mute", _domain);
}
// Engines that reuse the subtitle speed widget set their own max value. // Engines that reuse the subtitle speed widget set their own max value.
// Scale the config value accordingly (see addSubtitleControls) // Scale the config value accordingly (see addSubtitleControls)
talkspeed = (_subSpeedSlider->getValue() * 255 + sliderMaxValue / 2) / sliderMaxValue; int sliderMaxValue = _subSpeedSlider->getMaxValue();
int talkspeed = (_subSpeedSlider->getValue() * 255 + sliderMaxValue / 2) / sliderMaxValue;
ConfMan.setInt("talkspeed", talkspeed, _domain); ConfMan.setInt("talkspeed", talkspeed, _domain);
} else { } else {
@ -1218,6 +1222,7 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) {
if ((_guioptions.contains(GUIO_NOSUBTITLES)) || (_guioptions.contains(GUIO_NOSPEECH))) if ((_guioptions.contains(GUIO_NOSUBTITLES)) || (_guioptions.contains(GUIO_NOSPEECH)))
ena = false; ena = false;
_enableSubtitleToggle = ena;
_subToggleGroup->setEnabled(ena); _subToggleGroup->setEnabled(ena);
_subToggleDesc->setEnabled(ena); _subToggleDesc->setEnabled(ena);
@ -1678,6 +1683,7 @@ void OptionsDialog::addSubtitleControls(GuiObject *boss, const Common::String &p
_subSpeedLabel->setFlags(WIDGET_CLEARBG); _subSpeedLabel->setFlags(WIDGET_CLEARBG);
_enableSubtitleSettings = true; _enableSubtitleSettings = true;
_enableSubtitleToggle = true;
} }
void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &prefix) { void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &prefix) {

View file

@ -208,6 +208,7 @@ private:
// //
int getSubtitleMode(bool subtitles, bool speech_mute); int getSubtitleMode(bool subtitles, bool speech_mute);
bool _enableSubtitleSettings; bool _enableSubtitleSettings;
bool _enableSubtitleToggle;
StaticTextWidget *_subToggleDesc; StaticTextWidget *_subToggleDesc;
RadiobuttonGroup *_subToggleGroup; RadiobuttonGroup *_subToggleGroup;
RadiobuttonWidget *_subToggleSubOnly; RadiobuttonWidget *_subToggleSubOnly;