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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon May 5 19:12:48 CEST 2008


Revision: 31879
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31879&view=rev
Author:   lordhoto
Date:     2008-05-05 10:12:48 -0700 (Mon, 05 May 2008)

Log Message:
-----------
Implemented support for Kyra3 game options menu (including studio audience and skip flag options).

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/gui_hof.cpp
    scummvm/trunk/engines/kyra/gui_mr.cpp
    scummvm/trunk/engines/kyra/gui_mr.h
    scummvm/trunk/engines/kyra/kyra_hof.cpp
    scummvm/trunk/engines/kyra/kyra_mr.cpp
    scummvm/trunk/engines/kyra/kyra_mr.h
    scummvm/trunk/engines/kyra/kyra_v2.h
    scummvm/trunk/engines/kyra/scene_mr.cpp
    scummvm/trunk/engines/kyra/staticres.cpp

Modified: scummvm/trunk/engines/kyra/gui_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/gui_hof.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -977,6 +977,7 @@
 
 	if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) {
 		_vm->_configVoice = 1;
+		_vm->setVolume(KyraEngine::kVolumeSpeech, 75);
 		choiceDialog(0x1E, 0);
 	}
 

Modified: scummvm/trunk/engines/kyra/gui_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui_mr.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/gui_mr.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -961,5 +961,153 @@
 	return 0;
 }
 
+int GUI_MR::gameOptions(Button *caller) {
+	updateMenuButton(caller);
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+	bool textEnabled = _vm->textEnabled();
+	int lang = _vm->_lang;
+
+	setupOptionsButtons();
+	initMenu(_gameOptions);
+	_isOptionsMenu = true;
+
+	while (_isOptionsMenu) {
+		processHighlights(_gameOptions, _vm->_mouseX, _vm->_mouseY);
+		getInput();
+	}
+
+	restorePage1(_vm->_screenBuffer);
+	backUpPage1(_vm->_screenBuffer);
+
+	if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) {
+		_vm->_configVoice = 1;
+		_vm->setVolume(KyraEngine::kVolumeSpeech, 75);
+		choiceDialog(0x1E, 0);
+	}
+
+	if (_vm->_lang != lang) {
+		_reloadTemporarySave = true;
+		_vm->saveGame(_vm->getSavegameFilename(999), "Temporary Kyrandia 3 Savegame");
+		if (!_vm->loadLanguageFile("ITEMS.", _vm->_itemFile))
+			error("Couldn't load ITEMS");
+		if (!_vm->loadLanguageFile("SCORE.", _vm->_scoreFile))
+			error("Couldn't load SCORE");
+		if (!_vm->loadLanguageFile("C_CODE.", _vm->_cCodeFile))
+			error("Couldn't load C_CODE");
+		if (!_vm->loadLanguageFile("SCENES.", _vm->_scenesFile))
+			error("Couldn't load SCENES");
+		if (!_vm->loadLanguageFile("OPTIONS.", _vm->_optionsFile))
+			error("Couldn't load OPTIONS");
+		if (!_vm->loadLanguageFile("_ACTOR.", _vm->_actorFile))
+			error("couldn't load _ACTOR");
+	}
+
+	_vm->writeSettings();
+
+	initMenu(*_currentMenu);
+	updateAllMenuButtons();
+	return 0;
+}
+
+void GUI_MR::setupOptionsButtons() {
+	_vm->musicUpdate(0);
+	if (_vm->_configWalkspeed == 3)
+		_gameOptions.item[0].itemId = 28;
+	else
+		_gameOptions.item[0].itemId = 27;
+
+	if (_vm->textEnabled())
+		_gameOptions.item[4].itemId = 18;
+	else
+		_gameOptions.item[4].itemId = 17;
+
+	switch (_vm->_lang) {
+	case 0:
+		_gameOptions.item[1].itemId = 31;
+		break;
+	
+	case 1:
+		_gameOptions.item[1].itemId = 32;
+		break;
+
+	case 2:
+		_gameOptions.item[1].itemId = 33;
+		break;
+
+	default:
+		break;
+	}
+
+	if (_vm->_configStudio)
+		_gameOptions.item[2].itemId = 18;
+	else
+		_gameOptions.item[2].itemId = 17;
+
+	if (_vm->_configSkip)
+		_gameOptions.item[3].itemId = 18;
+	else
+		_gameOptions.item[3].itemId = 17;
+}
+
+int GUI_MR::toggleWalkspeed(Button *caller) {
+	updateMenuButton(caller);
+	if (_vm->_configWalkspeed == 5)
+		_vm->_configWalkspeed = 3;
+	else
+		_vm->_configWalkspeed = 5;
+	_vm->_mainCharacter.walkspeed = _vm->_configWalkspeed;
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+int GUI_MR::changeLanguage(Button *caller) {
+	updateMenuButton(caller);
+	if (!_vm->queryGameFlag(0x1B2)) {
+		++_vm->_lang;
+		_vm->_lang %= 3;
+		setupOptionsButtons();
+		renewHighlight(_gameOptions);
+	}
+	return 0;
+}
+
+int GUI_MR::toggleStudioSFX(Button *caller) {
+	updateMenuButton(caller);
+	_vm->_configStudio ^= 1;
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+int GUI_MR::toggleSkipSupport(Button *caller) {
+	updateMenuButton(caller);
+	_vm->_configSkip ^= 1;
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
+int GUI_MR::toggleText(Button *caller) {
+	updateMenuButton(caller);
+	
+	if (_vm->textEnabled()) {
+		if (_vm->speechEnabled())
+			_vm->_configVoice = 1;
+		else
+			_vm->_configVoice = 3;
+	} else {
+		if (_vm->speechEnabled())
+			_vm->_configVoice = 2;
+		else
+			_vm->_configVoice = 0;
+	}
+
+	setupOptionsButtons();
+	renewHighlight(_gameOptions);
+	return 0;
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/gui_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/gui_mr.h	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/gui_mr.h	2008-05-05 17:12:48 UTC (rev 31879)
@@ -66,6 +66,15 @@
 	int loadMenu(Button *button);
 	int loadSecondChance(Button *button);
 
+	int gameOptions(Button *button);
+	void setupOptionsButtons();
+
+	int toggleWalkspeed(Button *caller);
+	int changeLanguage(Button *caller);
+	int toggleStudioSFX(Button *caller);
+	int toggleSkipSupport(Button *caller);
+	int toggleText(Button *caller);
+
 	KyraEngine_MR *_vm;
 	Screen_MR *_screen;
 };

Modified: scummvm/trunk/engines/kyra/kyra_hof.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/kyra_hof.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -2011,6 +2011,3 @@
 
 } // end of namespace Kyra
 
-
-
-

Modified: scummvm/trunk/engines/kyra/kyra_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/kyra_mr.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -495,6 +495,9 @@
 
 void KyraEngine_MR::playStudioSFX(const char *str) {
 	debugC(9, kDebugLevelMain, "KyraEngine_MR::playStudioSFX('%s')", str);
+	if (!_configStudio)
+		return;
+
 	if (_rnd.getRandomNumberRng(1, 2) != 2)
 		return;
 
@@ -570,7 +573,7 @@
 		error("Couldn't load SCENES");
 	if (!loadLanguageFile("OPTIONS.", _optionsFile))
 		error("Couldn't load OPTIONS");
-	if ((_actorFileSize = loadLanguageFile("_ACTOR.", _actorFile)) == 0)
+	if (!loadLanguageFile("_ACTOR.", _actorFile))
 		error("couldn't load _ACTOR");
 
 	musicUpdate(0);
@@ -1343,6 +1346,9 @@
 int KyraEngine_MR::loadLanguageFile(const char *file, uint8 *&buffer) {
 	debugC(9, kDebugLevelMain, "KyraEngine_MR::loadLanguageFile('%s', %p)", file, (const void*)buffer);
 
+	delete[] buffer; 
+	buffer = 0;
+
 	uint32 size = 0;
 	char nBuf[32];
 	strncpy(nBuf, file, 32);
@@ -1473,5 +1479,68 @@
 	enterNewScene(sceneId, facing, 0, 0, 0);
 }
 
+#pragma mark -
+
+bool KyraEngine_MR::skipFlag() const {
+	if (!_configSkip)
+		return false;
+	return KyraEngine_v2::skipFlag();
+}
+
+void KyraEngine_MR::resetSkipFlag(bool removeEvent) {
+	if (!_configSkip) {
+		if (removeEvent)
+			_eventList.clear();
+		return;
+	}
+	KyraEngine_v2::resetSkipFlag(removeEvent);
+}
+
+#pragma mark -
+
+void KyraEngine_MR::registerDefaultSettings() {
+	debugC(9, kDebugLevelMain, "KyraEngine_MR::registerDefaultSettings()");
+	KyraEngine::registerDefaultSettings();
+
+	// Most settings already have sensible defaults. This one, however, is
+	// specific to the Kyra engine.
+	ConfMan.registerDefault("walkspeed", 5);
+	ConfMan.registerDefault("studio_audience", true);
+	ConfMan.registerDefault("skip_support", true);
+}
+
+void KyraEngine_MR::writeSettings() {
+	debugC(9, kDebugLevelMain, "KyraEngine_MR::writeSettings()");
+	switch (_lang) {
+	case 1:
+		_flags.lang = Common::FR_FRA;
+		break;
+
+	case 2:
+		_flags.lang = Common::DE_DEU;
+		break;
+
+	case 0:
+	default:
+		_flags.lang = Common::EN_ANY;
+		break;
+	}
+
+	ConfMan.set("language", Common::getLanguageCode(_flags.lang));
+
+	ConfMan.setBool("studio_audience", _configStudio);
+	ConfMan.setBool("skip_support", _configSkip);
+
+	KyraEngine::writeSettings();
+}
+
+void KyraEngine_MR::readSettings() {
+	debugC(9, kDebugLevelMain, "KyraEngine_MR::readSettings()");
+	KyraEngine::readSettings();
+
+	_configStudio = ConfMan.getBool("studio_audience");
+	_configSkip = ConfMan.getBool("skip_support");
+}
+
 } // end of namespace Kyra
 

Modified: scummvm/trunk/engines/kyra/kyra_mr.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/kyra_mr.h	2008-05-05 17:12:48 UTC (rev 31879)
@@ -60,9 +60,17 @@
 
 	void playVQA(const char *name);
 
-protected:
+private:
 	static const EngineDesc _mrEngineDesc;
 
+	// config
+	bool _configStudio;
+	bool _configSkip;
+
+	void registerDefaultSettings();
+	void writeSettings();
+	void readSettings();
+
 	// --
 	Screen_MR *_screen;
 	SoundDigital *_soundDigital;
@@ -75,6 +83,10 @@
 
 	void setupOpcodeTable();
 
+	// input
+	bool skipFlag() const;
+	void resetSkipFlag(bool removeEvent = true);
+
 	// run
 	bool _menuDirectlyToLoad;
 

Modified: scummvm/trunk/engines/kyra/kyra_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/kyra_v2.h	2008-05-05 17:12:48 UTC (rev 31879)
@@ -97,8 +97,8 @@
 	};
 	Common::List<Event> _eventList;
 
-	bool skipFlag() const;
-	void resetSkipFlag(bool removeEvent = true);
+	virtual bool skipFlag() const;
+	virtual void resetSkipFlag(bool removeEvent = true);
 
 	// Animator
 	struct AnimObj {

Modified: scummvm/trunk/engines/kyra/scene_mr.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_mr.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/scene_mr.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -670,7 +670,9 @@
 		}
 
 		if (unk1) {
-			if (skipFlag()) {
+			// Notice that we can't use KyraEngine_MR's skipFlag handling
+			// here, since Kyra3 allows disabling of skipFlag support
+			if (KyraEngine_v2::skipFlag()) {
 				resetSkipFlag(false);
 				running = false;
 				_unk4 = 1;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2008-05-05 16:18:54 UTC (rev 31878)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2008-05-05 17:12:48 UTC (rev 31879)
@@ -2510,6 +2510,7 @@
 	GUI_V2_MENU_ITEM(_mainMenu.item[2], 1, 35, -1, 64, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	_mainMenu.item[2].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::deleteMenu);
 	GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 4, -1, 81, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+	_mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::gameOptions);
 	GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 37, -1, 98, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 5, -1, 115, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	_mainMenu.item[5].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::quitGame);
@@ -2528,10 +2529,15 @@
 
 	GUI_V2_MENU(_gameOptions, -1, -1, 288, 154, 0xD0, 0xD1, 0xCF, 7, 0xBD, -1, 8, 0, 6, -1, -1, -1, -1);
 	GUI_V2_MENU_ITEM(_gameOptions.item[0], 1, 0, 160, 30, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 21, 8, 32, 0x0000);
+	_gameOptions.item[0].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::toggleWalkspeed);
 	GUI_V2_MENU_ITEM(_gameOptions.item[1], 1, 0, 160, 47, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 26, 8, 49, 0x0000);
+	_gameOptions.item[1].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::changeLanguage);
 	GUI_V2_MENU_ITEM(_gameOptions.item[2], 1, 0, 160, 64, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 40, 8, 66, 0x0000);
+	_gameOptions.item[2].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::toggleStudioSFX);
 	GUI_V2_MENU_ITEM(_gameOptions.item[3], 1, 0, 160, 81, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 46, 8, 83, 0x0000);
+	_gameOptions.item[3].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::toggleSkipSupport);
 	GUI_V2_MENU_ITEM(_gameOptions.item[4], 1, 0, 160, 98, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 22, 8, 100, 0x0000);
+	_gameOptions.item[4].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::toggleText);
 	GUI_V2_MENU_ITEM(_gameOptions.item[5], 1, 16, -1, 127, 125, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
 	_gameOptions.item[5].callback = clickQuitOptionsFunctor;
 	_gameOptions.item[6].enabled = false;


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