From b44afb45e6b1994d11d3360412859ab90be5890a Mon Sep 17 00:00:00 2001 From: sluicebox <22204938+sluicebox@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:04:53 -0500 Subject: [PATCH] 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. --- gui/options.cpp | 24 +++++++++++++++--------- gui/options.h | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gui/options.cpp b/gui/options.cpp index d62ed5db6ab..f817e347f3c 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -231,6 +231,7 @@ void OptionsDialog::init() { _speechVolumeLabel = nullptr; _muteCheckbox = nullptr; _enableSubtitleSettings = false; + _enableSubtitleToggle = false; _subToggleDesc = nullptr; _subToggleGroup = nullptr; _subToggleSubOnly = nullptr; @@ -909,11 +910,9 @@ void OptionsDialog::apply() { // Subtitle options if (_subToggleGroup) { if (_enableSubtitleSettings) { - bool subtitles, speech_mute; - int talkspeed; - int sliderMaxValue = _subSpeedSlider->getMaxValue(); - - switch (_subToggleGroup->getValue()) { + if (_enableSubtitleToggle) { + bool subtitles, speech_mute; + switch (_subToggleGroup->getValue()) { case kSubtitlesSpeech: subtitles = speech_mute = false; break; @@ -925,14 +924,19 @@ void OptionsDialog::apply() { default: subtitles = speech_mute = true; break; - } + } - ConfMan.setBool("subtitles", subtitles, _domain); - ConfMan.setBool("speech_mute", speech_mute, _domain); + ConfMan.setBool("subtitles", subtitles, _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. // 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); } else { @@ -1218,6 +1222,7 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) { if ((_guioptions.contains(GUIO_NOSUBTITLES)) || (_guioptions.contains(GUIO_NOSPEECH))) ena = false; + _enableSubtitleToggle = ena; _subToggleGroup->setEnabled(ena); _subToggleDesc->setEnabled(ena); @@ -1678,6 +1683,7 @@ void OptionsDialog::addSubtitleControls(GuiObject *boss, const Common::String &p _subSpeedLabel->setFlags(WIDGET_CLEARBG); _enableSubtitleSettings = true; + _enableSubtitleToggle = true; } void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &prefix) { diff --git a/gui/options.h b/gui/options.h index 7a189a42d6d..175a4dd21e2 100644 --- a/gui/options.h +++ b/gui/options.h @@ -208,6 +208,7 @@ private: // int getSubtitleMode(bool subtitles, bool speech_mute); bool _enableSubtitleSettings; + bool _enableSubtitleToggle; StaticTextWidget *_subToggleDesc; RadiobuttonGroup *_subToggleGroup; RadiobuttonWidget *_subToggleSubOnly;