[Scummvm-cvs-logs] SF.net SVN: scummvm: [30653] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Jan 27 16:30:53 CET 2008


Revision: 30653
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30653&view=rev
Author:   lordhoto
Date:     2008-01-27 07:30:53 -0800 (Sun, 27 Jan 2008)

Log Message:
-----------
- slightly refactored user settings handling
- added user some settings handling for HoF

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_v1.cpp
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/engines/kyra/kyra_v1.h
    scummvm/trunk/engines/kyra/kyra_v2.cpp
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/sound_v1.cpp
    scummvm/trunk/engines/kyra/text_v2.cpp
    scummvm/trunk/engines/kyra/timer_v2.cpp

Modified: scummvm/trunk/engines/kyra/gui_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_v1.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/gui_v1.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -37,99 +37,6 @@
 
 namespace Kyra {
 
-void KyraEngine_v1::registerDefaultSettings() {
-	// Most settings already have sensible defaults. This one, however, is
-	// specific to the Kyra engine.
-	ConfMan.registerDefault("walkspeed", 2);
-	ConfMan.registerDefault("cdaudio", (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98));
-}
-
-void KyraEngine_v1::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 : ((ConfMan.getBool("cdaudio") && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) ? 2 : 1);	
-	_configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1;
-
-	_sound->enableMusic(_configMusic);
-	_sound->enableSFX(_configSounds);
-
-	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
-
-	setWalkspeed(_configWalkspeed);
-}
-
-void KyraEngine_v1::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("cdaudio", _configMusic == 2);
-	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;
-	}
-
-	if (!_configMusic)
-		_sound->beginFadeOut();
-
-	_sound->enableMusic(_configMusic);
-	_sound->enableSFX(_configSounds);
-
-	ConfMan.setBool("speech_mute", speechMute);
-	ConfMan.setBool("subtitles", subtitles);
-
-	ConfMan.flushToDisk();
-}
-
 void KyraEngine_v1::initMainButtonList() {
 	_haveScrollButtons = false;
 	_buttonList = &_buttonData[0];

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -230,6 +230,75 @@
 	delay(ticks * _tickLength);
 }
 
+void KyraEngine::registerDefaultSettings() {
+	if (_flags.gameID != GI_KYRA3)
+		ConfMan.registerDefault("cdaudio", (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98));
+}
+
+void KyraEngine::readSettings() {
+	_configWalkspeed = ConfMan.getInt("walkspeed");
+	_configMusic = ConfMan.getBool("music_mute") ? 0 : ((ConfMan.getBool("cdaudio") && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) ? 2 : 1);	
+	_configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1;
+
+	_sound->enableMusic(_configMusic);
+	_sound->enableSFX(_configSounds);
+
+	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
+
+	setWalkspeed(_configWalkspeed);
+}
+
+void KyraEngine::writeSettings() {
+	bool speechMute, subtitles;
+
+	ConfMan.setInt("walkspeed", _configWalkspeed);
+	ConfMan.setBool("music_mute", _configMusic == 0);
+	ConfMan.setBool("cdaudio", _configMusic == 2);
+	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;
+	}
+
+	if (!_configMusic)
+		_sound->beginFadeOut();
+
+	_sound->enableMusic(_configMusic);
+	_sound->enableSFX(_configSounds);
+
+	ConfMan.setBool("speech_mute", speechMute);
+	ConfMan.setBool("subtitles", subtitles);
+
+	ConfMan.flushToDisk();
+}
+
+bool KyraEngine::speechEnabled() {
+	return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2);
+}
+
+bool KyraEngine::textEnabled() {
+	return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2);
+}
+
 } // End of namespace Kyra
 
 

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra.h	2008-01-27 15:30:53 UTC (rev 30653)
@@ -147,11 +147,28 @@
 	StaticResource *_staticres;
 	TimerManager *_timer;
 	ScriptHelper *_scriptInterpreter;
+
+	// config specific
+	virtual void registerDefaultSettings();
+	virtual void readSettings();
+	virtual void writeSettings();
+
+	uint8 _configWalkspeed;
+
+	int _configMusic;
+	bool _configSounds;
+	uint8 _configVoice;
+
+	bool speechEnabled();
+	bool textEnabled();
 	
 	// game speed
 	bool _skipFlag;
 	uint16 _tickLength;
 	uint16 _gameSpeed;
+
+	// timer
+	virtual void setWalkspeed(uint8 speed) = 0;
 	
 	// detection
 	GameFlags _flags;

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -1008,6 +1008,58 @@
 	}
 }
 
+#pragma mark -
+
+void KyraEngine_v1::registerDefaultSettings() {
+	KyraEngine::registerDefaultSettings();
+
+	// Most settings already have sensible defaults. This one, however, is
+	// specific to the Kyra engine.
+	ConfMan.registerDefault("walkspeed", 2);
+}
+
+void KyraEngine_v1::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
+
+	KyraEngine::readSettings();
+}
+
+void KyraEngine_v1::writeSettings() {
+	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);
+	
+	KyraEngine::writeSettings();
+}
+
+#pragma mark -
+
 typedef Functor1Mem<ScriptState*, int, KyraEngine_v1> OpcodeV1;
 #define Opcode(x) OpcodeV1(this, &KyraEngine_v1::x)
 void KyraEngine_v1::setupOpcodeTable() {

Modified: scummvm/trunk/engines/kyra/kyra_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.h	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra_v1.h	2008-01-27 15:30:53 UTC (rev 30653)
@@ -279,9 +279,6 @@
 	void snd_playWanderScoreViaMap(int command, int restart);
 	virtual void snd_playVoiceFile(int id);
 	void snd_voiceWaitForFinish(bool ingame = true);
-
-	bool speechEnabled();
-	bool textEnabled();
 	
 	void saveGame(const char *fileName, const char *saveName);
 	void loadGame(const char *fileName);
@@ -594,10 +591,6 @@
 	bool _fadeText;
 
 	uint8 _configTextspeed;
-	uint8 _configWalkspeed;
-	int _configMusic;
-	bool _configSounds;
-	uint8 _configVoice;
 
 	ScreenAnimator *_animator;
 	SeqPlayer *_seq;

Modified: scummvm/trunk/engines/kyra/kyra_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra_v2.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -35,6 +35,7 @@
 #include "kyra/debugger.h"
 
 #include "common/system.h"
+#include "common/config-manager.h"
 
 namespace Kyra {
 
@@ -1705,6 +1706,16 @@
 
 #pragma mark -
 
+void KyraEngine_v2::registerDefaultSettings() {
+	KyraEngine::registerDefaultSettings();
+
+	// Most settings already have sensible defaults. This one, however, is
+	// specific to the Kyra engine.
+	ConfMan.registerDefault("walkspeed", 5);
+}
+
+#pragma mark -
+
 typedef Functor1Mem<ScriptState*, int, KyraEngine_v2> OpcodeV2;
 #define Opcode(x) OpcodeV2(this, &KyraEngine_v2::x)
 #define OpcodeUnImpl() OpcodeV2(this, 0)

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-01-27 15:30:53 UTC (rev 30653)
@@ -272,6 +272,8 @@
 	void runLoop();
 	void cleanup();
 
+	void registerDefaultSettings();
+
 	// TODO: get rid of all variables having pointers to the static resources if possible
 	// i.e. let them directly use the _staticres functions
 	void initStaticResource();
@@ -666,6 +668,7 @@
 	void showIdleAnim();
 	void runIdleScript(int script);
 
+	void setWalkspeed(uint8 speed);
 
 	// delay
 	void delay(uint32 millis, bool updateGame = false, bool isMainLoop = false);

Modified: scummvm/trunk/engines/kyra/sound_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_v1.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/sound_v1.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -28,14 +28,6 @@
 
 namespace Kyra {
 
-bool KyraEngine_v1::speechEnabled() {
-	return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2);
-}
-
-bool KyraEngine_v1::textEnabled() {
-	return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2);
-}
-
 void KyraEngine_v1::snd_playSoundEffect(int track) {
 	debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playSoundEffect(%d)", track);
 	if ((_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) && track == 49) {

Modified: scummvm/trunk/engines/kyra/text_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/text_v2.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/text_v2.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -212,14 +212,14 @@
 
 	_screen->hideMouse();
 
-	if (1/*textEnabled()*/) {
+	if (textEnabled()) {
 		objectChatPrintText(str, object);
 		_chatEndTime = _system->getMillis() + chatCalcDuration(str) * _tickLength;
 	} else {
 		_chatEndTime = _system->getMillis();
 	}
 
-	if (1/*voiceEnabled()*/) {
+	if (speechEnabled()) {
 		_chatVocHigh = vocHigh;
 		_chatVocLow = vocLow;
 	} else {
@@ -318,7 +318,7 @@
 			}
 
 			const uint32 curTime = _system->getMillis();
-			if ((1/*textEnabled()*/ && curTime > endTime) || (1/*voiceEnabled()*/ && !snd_voiceIsPlaying()) || _skipFlag) {
+			if ((textEnabled() && curTime > endTime) || (speechEnabled() && !snd_voiceIsPlaying()) || _skipFlag) {
 				_skipFlag = false;
 				nextFrame = curTime;
 				running = false;

Modified: scummvm/trunk/engines/kyra/timer_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/timer_v2.cpp	2008-01-27 15:23:45 UTC (rev 30652)
+++ scummvm/trunk/engines/kyra/timer_v2.cpp	2008-01-27 15:30:53 UTC (rev 30653)
@@ -100,4 +100,16 @@
 	_timer->setCountdown(1, secs * 60);
 }
 
+void KyraEngine_v2::setWalkspeed(uint8 newSpeed) {
+	debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::setWalkspeed(%i)", newSpeed);
+
+	if (newSpeed < 5)
+		newSpeed = 3;
+	else
+		newSpeed = 5;
+
+	_timer->setDelay(5, newSpeed);
+}
+
+
 } // end of namespace Kyra


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