[Scummvm-cvs-logs] SF.net SVN: scummvm: [22705] scummvm/trunk

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun May 28 02:22:07 CEST 2006


Revision: 22705
Author:   eriktorbjorn
Date:     2006-05-28 02:21:32 -0700 (Sun, 28 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22705&view=rev

Log Message:
-----------
The Kyra settings are now stored in the config file instead of the savegames.
The settings in older savegames are ignored.

Modified Paths:
--------------
    scummvm/trunk/README
    scummvm/trunk/doc/config.tex
    scummvm/trunk/engines/kyra/gui.cpp
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/staticres.cpp
Modified: scummvm/trunk/README
===================================================================
--- scummvm/trunk/README	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/README	2006-05-28 09:21:32 UTC (rev 22705)
@@ -1319,6 +1319,10 @@
         sfx_mute        bool     If true, sound effects are muted
                                  [Simon the Sorcerer 2 only]
 
+The Legend of Kyrandia adds the following non-standard keyword:
+
+        walkspeed       int      The walk speed (0-4)
+
 9.0) Compiling:
 ---- ----------
 You need SDL-1.2.2 or newer (older versions may work, but are unsupported), and

Modified: scummvm/trunk/doc/config.tex
===================================================================
--- scummvm/trunk/doc/config.tex	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/doc/config.tex	2006-05-28 09:21:32 UTC (rev 22705)
@@ -142,3 +142,8 @@
         music\_mute     &bool    &If true, music is muted\\
         sfx\_mute       &bool    &If true, sound effects are muted\\
 \end{tabular}
+
+The Legend of Kyrandia adds the following non-standard keyword:\\
+\begin{tabular}[h]{lll}
+        walkspeed       &int     &The walk speed (0-4)\\
+\end{tabular}

Modified: scummvm/trunk/engines/kyra/gui.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui.cpp	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/engines/kyra/gui.cpp	2006-05-28 09:21:32 UTC (rev 22705)
@@ -26,11 +26,92 @@
 #include "kyra/text.h"
 #include "kyra/animator.h"
 
+#include "common/config-manager.h"
 #include "common/savefile.h"
 #include "common/system.h"
 
 namespace Kyra {
 
+void KyraEngine::registerDefaultSettings() {
+	// Most settings already have sensible defaults. This one, however, is
+	// specific to the Kyra engine.
+	ConfMan.registerDefault("walkspeed", 2);
+}
+
+void KyraEngine::readSettings() {
+	int talkspeed = ConfMan.getInt("talkspeed");
+
+	// The default talk speed is 60. This should be mapped to "Normal".
+
+	if (talkspeed == 0)
+		_configTextspeed = 3;	// Clickable
+	if (talkspeed <= 50)
+		_configTextspeed = 0;	// Slow
+	else if (talkspeed <= 150)
+		_configTextspeed = 1;	// Normal
+	else
+		_configTextspeed = 2;	// Fast
+
+	_configWalkspeed = ConfMan.getInt("walkspeed");
+	_configMusic = ConfMan.getBool("music_mute") ? 0 : 1;
+	_configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1;
+
+	bool speechMute = ConfMan.getBool("speech_mute");
+	bool subtitles = ConfMan.getBool("subtitles");
+
+	if (!speechMute && subtitles)
+		_configVoice = 2;	// Voice & Text
+	else if (!speechMute && !subtitles)
+		_configVoice = 1;	// Voice only
+	else
+		_configVoice = 0;	// Text only
+}
+
+void KyraEngine::writeSettings() {
+	bool speechMute, subtitles;
+	int talkspeed;
+
+	switch (_configTextspeed) {
+	case 0:		// Slow
+		talkspeed = 1;
+		break;
+	case 1:		// Normal
+		talkspeed = 60;
+		break;
+	case 2:		// Fast
+		talkspeed = 255;
+		break;
+	default:	// Clickable
+		talkspeed = 0;
+		break;
+	}
+
+	ConfMan.setInt("talkspeed", talkspeed);
+	ConfMan.setInt("walkspeed", _configWalkspeed);
+	ConfMan.setBool("music_mute", _configMusic == 0);
+	ConfMan.setBool("sfx_mute", _configSounds == 0);
+
+	switch (_configVoice) {
+	case 0:		// Text only
+		speechMute = true;
+		subtitles = true;
+		break;
+	case 1:		// Voice only
+		speechMute = false;
+		subtitles = false;
+		break;
+	default:	// Voice & Text
+		speechMute = false;
+		subtitles = true;
+		break;
+	}
+
+	ConfMan.setBool("speech_mute", speechMute);
+	ConfMan.setBool("subtitles", subtitles);
+
+	ConfMan.flushToDisk();
+}
+
 void KyraEngine::initMainButtonList() {
 	_haveScrollButtons = false;
 	_buttonList = &_buttonData[0];
@@ -385,7 +466,6 @@
 	button->flags2 &= 0xfb;
 
 	processButton(button);
-
 }
 
 int KyraEngine::drawBoxCallback(Button *button) {
@@ -1071,6 +1151,8 @@
 int KyraEngine::gui_gameControlsMenu(Button *button) {
 	debugC(9, kDebugLevelGUI, "KyraEngine::gui_gameControlsMenu()");
 
+	readSettings();
+
 	_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
 	_screen->savePageToDisk("SEENPAGE.TMP", 0);
 
@@ -1169,10 +1251,10 @@
 			menu.item[3].itemString = _configStrings[5]; //"Text only"
 			break;
 		case 1:
-			menu.item[3].itemString = _configStrings[6]; //"Voice & Text"
+			menu.item[3].itemString = _configStrings[6]; //"Voice only"
 			break;
 		case 2:
-			menu.item[3].itemString = _configStrings[7]; //"Voice only"
+			menu.item[3].itemString = _configStrings[7]; //"Voice & Text"
 			break;
 		default:
 			menu.item[3].itemString = "ERROR";
@@ -1248,6 +1330,12 @@
 	return 0;
 }
 
+int KyraEngine::gui_controlsApply(Button *button) {
+	debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsApply()");
+	writeSettings();
+	return gui_cancelSubMenu(button);
+}
+
 int KyraEngine::gui_scrollUp(Button *button) {
 	debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollUp()");
 	processMenuButton(button);

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2006-05-28 09:21:32 UTC (rev 22705)
@@ -274,11 +274,8 @@
 	assert(_movFacingTable);
 	_movFacingTable[0] = 8;
 
-	_configTextspeed = 1;
-	_configWalkspeed = 2;
-	_configMusic = true;
-	_configSounds = true;
-	_configVoice = 1;
+	registerDefaultSettings();
+	readSettings();
 
 	_skipFlag = false;
 

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/engines/kyra/kyra.h	2006-05-28 09:21:32 UTC (rev 22705)
@@ -295,6 +295,10 @@
 	void quitGame();
 	void loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData);
 
+	void registerDefaultSettings();
+	void readSettings();
+	void writeSettings();
+
 	void snd_playTheme(int file, int track = 0);
 	void snd_playVoiceFile(int id);
 	void snd_voiceWaitForFinish(bool ingame = true);
@@ -675,6 +679,7 @@
 	int gui_controlsChangeWalk(Button *button);
 	int gui_controlsChangeText(Button *button);
 	int gui_controlsChangeVoice(Button *button);
+	int gui_controlsApply(Button *button);
 
 	bool gui_quitConfirm(const char *str);
 	void gui_getInput();

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2006-05-28 09:21:32 UTC (rev 22705)
@@ -30,7 +30,7 @@
 #include "kyra/screen.h"
 #include "kyra/resource.h"
 
-#define CURRENT_VERSION 4
+#define CURRENT_VERSION 5
 
 namespace Kyra {
 void KyraEngine::loadGame(const char *fileName) {
@@ -179,13 +179,16 @@
 		if (_lastMusicCommand != -1)
 			snd_playWanderScoreViaMap(_lastMusicCommand, 1);
 	}
+
+	// Version 4 stored settings in the savegame. As of version 5, they are
+	// handled by the config manager.
 	
-	if (version >= 4) {
-		_configTextspeed = in->readByte();
-		_configWalkspeed = in->readByte();
-		_configMusic = in->readByte() != 0;
-		_configSounds = in->readByte() != 0;
-		_configVoice = in->readByte();
+	if (version == 4) {
+		in->readByte(); // Text speed
+		in->readByte(); // Walk speed
+		in->readByte(); // Music
+		in->readByte(); // Sound
+		in->readByte(); // Voice
 	}
 
 	loadMainScreen(8);
@@ -317,12 +320,6 @@
 	
 	out->writeSint16BE(_lastMusicCommand);
 
-	out->writeByte(_configTextspeed);
-	out->writeByte(_configWalkspeed);
-	out->writeByte(_configMusic);
-	out->writeByte(_configSounds);
-	out->writeByte(_configVoice);
-
 	out->flush();
 
 	// check for errors

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2006-05-28 08:16:07 UTC (rev 22704)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2006-05-28 09:21:32 UTC (rev 22705)
@@ -1178,7 +1178,7 @@
 			248, 249, 250, &KyraEngine::gui_controlsChangeText, -1, 0, 34, 100, 0, 0 },
 
 			{1, 0, 0, 0, 64, 0, 127, 92, 15, 252, 253, -1, 255,
-			248, 249, 250, &KyraEngine::gui_cancelSubMenu, -1, -0, 0, 0, 0, 0}
+			248, 249, 250, &KyraEngine::gui_controlsApply, -1, -0, 0, 0, 0, 0}
 		}
 	}
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list