[Scummvm-git-logs] scummvm master -> 56757592bd03bb7a35cf12641cfd1c672bb5606a

criezy criezy at scummvm.org
Sat Jul 8 13:59:57 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6ff927bff7 SWORD1: Use booleans for _systemVars speech and subtitles flags
56757592bd SWORD1: Only write config in in-game menu when they are changed


Commit: 6ff927bff745d1a5977b556b62840858bbb695e1
    https://github.com/scummvm/scummvm/commit/6ff927bff745d1a5977b556b62840858bbb695e1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-07-08T12:55:11+01:00

Commit Message:
SWORD1: Use booleans for _systemVars speech and subtitles flags

The were defined as uint8 and the code was inconsistent in the
way they were handled, for example setting them to 1 in some
places and to true in others. It was working but relying on implicit
conversions both ways between 1 and true.

Changed paths:
    engines/sword1/control.cpp
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h


diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index c9b4f9f..0384e68 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -410,7 +410,7 @@ uint8 Control::runPanel() {
 		ConfMan.setInt("sfx_volume", (int)((volR + volL) / 2));
 		ConfMan.setInt("sfx_balance", volToBalance(volL, volR));
 
-		ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText == 1);
+		ConfMan.setBool("subtitles", SwordEngine::_systemVars.showText);
 		ConfMan.flushToDisk();
 	}
 
@@ -503,8 +503,8 @@ uint8 Control::handleButtonClick(uint8 id, uint8 mode, uint8 *retVal) {
 		           (id == BUTTON_DONE) || (id == BUTTON_VOLUME_PANEL))
 			return id;
 		else if (id == BUTTON_TEXT) {
-			SwordEngine::_systemVars.showText ^= 1;
-			_buttons[5]->setSelected(SwordEngine::_systemVars.showText);
+			SwordEngine::_systemVars.showText = !SwordEngine::_systemVars.showText;
+			_buttons[5]->setSelected(SwordEngine::_systemVars.showText ? 1 : 0);
 		} else if (id == BUTTON_QUIT) {
 			if (getConfirm(_lStrings[STR_QUIT]))
 				Engine::quitGame();
@@ -566,7 +566,7 @@ void Control::setupMainPanel() {
 		createButtons(_deathButtons, 3);
 	else {
 		createButtons(_panelButtons, 7);
-		_buttons[5]->setSelected(SwordEngine::_systemVars.showText);
+		_buttons[5]->setSelected(SwordEngine::_systemVars.showText ? 1 : 0);
 	}
 
 	if (SwordEngine::_systemVars.controlPanelMode == CP_THEEND) // end of game
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 1556f08..1e7b6da 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -154,7 +154,7 @@ Common::Error SwordEngine::init() {
 
 	_systemVars.showText = ConfMan.getBool("subtitles");
 
-	_systemVars.playSpeech = 1;
+	_systemVars.playSpeech = true;
 	_mouseState = 0;
 
 	// Some Mac versions use big endian for the speech files but not all of them.
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index 8dab522..32375e9 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -70,8 +70,8 @@ struct SystemVars {
 	uint8   controlPanelMode;   // 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart
 	bool    forceRestart;
 	bool    wantFade;           // when true => fade during scene change, else cut.
-	uint8   playSpeech;
-	uint8   showText;
+	bool   playSpeech;
+	bool   showText;
 	uint8   language;
 	bool    isDemo;
 	Common::Platform platform;


Commit: 56757592bd03bb7a35cf12641cfd1c672bb5606a
    https://github.com/scummvm/scummvm/commit/56757592bd03bb7a35cf12641cfd1c672bb5606a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-07-08T12:55:12+01:00

Commit Message:
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.

Changed paths:
    engines/sword1/control.cpp


diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 0384e68..fbc3f6a 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();
 	}
 





More information about the Scummvm-git-logs mailing list