From 56757592bd03bb7a35cf12641cfd1c672bb5606a Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 8 Jul 2017 12:54:29 +0100 Subject: SWORD1: Only write config in in-game menu when they are changed The in-game menu contains not only subtitles and volume settings, but also load and save game options. Every time the menu was opened it would write the subtitles and audio volumes to the ConfMan resulting in toggling on overriding global options for this game, which was a but strange when it was previously using global options and we only wanted to load a game. So now the settings are written to ConfMan from the in-game menu only when they are actually changed. --- engines/sword1/control.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'engines/sword1/control.cpp') diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 0384e685b3..fbc3f6af4a 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -399,18 +399,31 @@ uint8 Control::runPanel() { if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL) { uint8 volL, volR; _music->giveVolume(&volL, &volR); - ConfMan.setInt("music_volume", (int)((volR + volL) / 2)); - ConfMan.setInt("music_balance", volToBalance(volL, volR)); + int vol = (int)((volR + volL) / 2); + int volBalance = volToBalance(volL, volR); + if (vol != ConfMan.getInt("music_volume")) + ConfMan.setInt("music_volume", vol); + if (volBalance != ConfMan.getInt("music_balance")) + ConfMan.setInt("music_balance", volBalance); _sound->giveSpeechVol(&volL, &volR); - ConfMan.setInt("speech_volume", (int)((volR + volL) / 2)); - ConfMan.setInt("speech_balance", volToBalance(volL, volR)); + vol = (int)((volR + volL) / 2); + volBalance = volToBalance(volL, volR); + if (vol != ConfMan.getInt("speech_volume")) + ConfMan.setInt("speech_volume", vol); + if (volBalance != ConfMan.getInt("speech_balance")) + ConfMan.setInt("speech_balance", volBalance); _sound->giveSfxVol(&volL, &volR); - ConfMan.setInt("sfx_volume", (int)((volR + volL) / 2)); - ConfMan.setInt("sfx_balance", volToBalance(volL, volR)); - - ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText); + vol = (int)((volR + volL) / 2); + volBalance = volToBalance(volL, volR); + if (vol != ConfMan.getInt("sfx_volume")) + ConfMan.setInt("sfx_volume", vol); + if (volBalance != ConfMan.getInt("sfx_balance")) + ConfMan.setInt("sfx_balance", volBalance); + + if (SwordEngine::_systemVars.showText != ConfMan.getBool("subtitles")) + ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText); ConfMan.flushToDisk(); } -- cgit v1.2.3