diff options
author | Johannes Schickel | 2008-05-05 17:12:48 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-05-05 17:12:48 +0000 |
commit | 81cfd2a716ff42d5425a456faff9068c92130969 (patch) | |
tree | e12f84f4b29eb9816f12e5436ab794c832f1c0a0 | |
parent | 0f62fb0a88d89703f3f3029e57005ace07b112ee (diff) | |
download | scummvm-rg350-81cfd2a716ff42d5425a456faff9068c92130969.tar.gz scummvm-rg350-81cfd2a716ff42d5425a456faff9068c92130969.tar.bz2 scummvm-rg350-81cfd2a716ff42d5425a456faff9068c92130969.zip |
Implemented support for Kyra3 game options menu (including studio audience and skip flag options).
svn-id: r31879
-rw-r--r-- | engines/kyra/gui_hof.cpp | 1 | ||||
-rw-r--r-- | engines/kyra/gui_mr.cpp | 148 | ||||
-rw-r--r-- | engines/kyra/gui_mr.h | 9 | ||||
-rw-r--r-- | engines/kyra/kyra_hof.cpp | 3 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.cpp | 71 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.h | 14 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 4 | ||||
-rw-r--r-- | engines/kyra/scene_mr.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 6 |
9 files changed, 252 insertions, 8 deletions
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp index ce00a418f6..1ca90c6549 100644 --- a/engines/kyra/gui_hof.cpp +++ b/engines/kyra/gui_hof.cpp @@ -977,6 +977,7 @@ int GUI_HoF::gameOptionsTalkie(Button *caller) { if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) { _vm->_configVoice = 1; + _vm->setVolume(KyraEngine::kVolumeSpeech, 75); choiceDialog(0x1E, 0); } diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp index f37d5bb572..655585b734 100644 --- a/engines/kyra/gui_mr.cpp +++ b/engines/kyra/gui_mr.cpp @@ -961,5 +961,153 @@ int GUI_MR::loadSecondChance(Button *button) { 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 diff --git a/engines/kyra/gui_mr.h b/engines/kyra/gui_mr.h index 36c250d32b..fcf783492f 100644 --- a/engines/kyra/gui_mr.h +++ b/engines/kyra/gui_mr.h @@ -66,6 +66,15 @@ private: 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; }; diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index fff96f456c..c25af91bec 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -2011,6 +2011,3 @@ void KyraEngine_HoF::readSettings() { } // end of namespace Kyra - - - diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 8fed57c2b7..1c4396b320 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -495,6 +495,9 @@ void KyraEngine_MR::snd_stopVoice() { 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 @@ void KyraEngine_MR::startup() { 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 @@ char *KyraEngine_MR::appendLanguage(char *buf, int lang, int bufSize) { 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 @@ void KyraEngine_MR::changeChapter(int newChapter, int sceneId, int malcolmShapes 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 diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h index 2e7d0a507c..7abca43513 100644 --- a/engines/kyra/kyra_mr.h +++ b/engines/kyra/kyra_mr.h @@ -60,9 +60,17 @@ public: 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 @@ protected: void setupOpcodeTable(); + // input + bool skipFlag() const; + void resetSkipFlag(bool removeEvent = true); + // run bool _menuDirectlyToLoad; diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 7636f92e7c..f0d26ca011 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -97,8 +97,8 @@ protected: }; 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 { diff --git a/engines/kyra/scene_mr.cpp b/engines/kyra/scene_mr.cpp index 57ac328286..196c87424d 100644 --- a/engines/kyra/scene_mr.cpp +++ b/engines/kyra/scene_mr.cpp @@ -670,7 +670,9 @@ int KyraEngine_MR::trySceneChange(int *moveTable, int unk1, int updateChar) { } 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; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 83ae17ba1c..0695847d7a 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2510,6 +2510,7 @@ void GUI_MR::initStaticData() { 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 @@ void GUI_MR::initStaticData() { 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; |