diff options
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/dialogs.cpp | 29 | ||||
-rw-r--r-- | engines/mohawk/dialogs.h | 8 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 42 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 1 | ||||
-rw-r--r-- | engines/mohawk/riven_vars.cpp | 8 |
5 files changed, 77 insertions, 11 deletions
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp index 9be05a178d..154b1b10e6 100644 --- a/engines/mohawk/dialogs.cpp +++ b/engines/mohawk/dialogs.cpp @@ -296,20 +296,33 @@ RivenOptionsDialog::RivenOptionsDialog(MohawkEngine_Riven* vm) : RivenOptionsDialog::~RivenOptionsDialog() { } -void RivenOptionsDialog::open() { - MohawkOptionsDialog::open(); +bool RivenOptionsDialog::getZipMode() const { + return _zipModeCheckbox->getState(); +} + +void RivenOptionsDialog::setZipMode(bool enabled) { + _zipModeCheckbox->setState(enabled); +} + +bool RivenOptionsDialog::getWaterEffect() const { + return _waterEffectCheckbox->getState(); +} + +void RivenOptionsDialog::setWaterEffect(bool enabled) { + _waterEffectCheckbox->setState(enabled); +} + +uint32 RivenOptionsDialog::getTransitions() const { + return _transitionModePopUp->getSelectedTag(); +} - _zipModeCheckbox->setState(_vm->_vars["azip"] != 0); - _waterEffectCheckbox->setState(_vm->_vars["waterenabled"] != 0); - _transitionModePopUp->setSelectedTag(_vm->_vars["transitionmode"]); +void RivenOptionsDialog::setTransitions(uint32 mode) { + _transitionModePopUp->setSelectedTag(mode); } void RivenOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { case GUI::kOKCmd: - _vm->_vars["azip"] = _zipModeCheckbox->getState() ? 1 : 0; - _vm->_vars["waterenabled"] = _waterEffectCheckbox->getState() ? 1 : 0; - _vm->_vars["transitionmode"] = _transitionModePopUp->getSelectedTag(); setResult(1); close(); break; diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h index 03b964369d..a23d251878 100644 --- a/engines/mohawk/dialogs.h +++ b/engines/mohawk/dialogs.h @@ -80,6 +80,7 @@ public: ~MohawkOptionsDialog() override; void reflowLayout() override; + int getResult() const { return GUI::Dialog::getResult(); } void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override; }; @@ -153,9 +154,14 @@ public: explicit RivenOptionsDialog(MohawkEngine_Riven *vm); ~RivenOptionsDialog() override; - void open() override; void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override; + bool getZipMode() const; + void setZipMode(bool enabled); + bool getWaterEffect() const; + void setWaterEffect(bool enabled); + uint32 getTransitions() const; + void setTransitions(uint32 mode); private: MohawkEngine_Riven *_vm; diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 2545c686b4..1843de95ae 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -122,6 +122,10 @@ Common::Error MohawkEngine_Riven::run() { return Common::kAudioDeviceInitFailed; } + ConfMan.registerDefault("zip_mode", false); + ConfMan.registerDefault("water_effects", true); + ConfMan.registerDefault("transition_mode", kRivenTransitionModeFastest); + // Let's try to open the installer file (it holds extras.mhk) // Though, we set a low priority to prefer the extracted version if (_installerArchive.open("arcriven.z")) @@ -387,6 +391,17 @@ void MohawkEngine_Riven::pauseEngineIntern(bool pause) { } } +uint32 MohawkEngine_Riven::sanitizeTransitionMode(uint32 mode) { + if (mode != kRivenTransitionModeDisabled + && mode != kRivenTransitionModeFastest + && mode != kRivenTransitionModeNormal + && mode != kRivenTransitionModeBest) { + return kRivenTransitionModeFastest; + } + + return mode; +} + // Stack/Card-Related Functions void MohawkEngine_Riven::changeToStack(uint16 stackId) { @@ -666,6 +681,8 @@ void MohawkEngine_Riven::startNewGame() { _zipModeData.clear(); + _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]); + setTotalPlayTime(0); } @@ -820,8 +837,33 @@ void MohawkEngine_Riven::setGameEnded() { } void MohawkEngine_Riven::runOptionsDialog() { + if (isGameStarted()) { + _optionsDialog->setZipMode(_vars["azip"] != 0); + _optionsDialog->setWaterEffect(_vars["waterenabled"] != 0); + _optionsDialog->setTransitions(_vars["transitionmode"]); + } else { + _optionsDialog->setZipMode(ConfMan.getBool("zip_mode")); + _optionsDialog->setWaterEffect(ConfMan.getBool("water_effects")); + + uint32 transitions = ConfMan.getInt("transition_mode"); + _optionsDialog->setTransitions(sanitizeTransitionMode(transitions)); + } + runDialog(*_optionsDialog); + if (_optionsDialog->getResult() > 0) { + if (isGameStarted()) { + _vars["azip"] = _optionsDialog->getZipMode() ? 1 : 0; + _vars["waterenabled"] = _optionsDialog->getWaterEffect() ? 1 : 0; + _vars["transitionmode"] = _optionsDialog->getTransitions(); + } else { + ConfMan.setBool("zip_mode", _optionsDialog->getZipMode()); + ConfMan.setBool("water_effects", _optionsDialog->getWaterEffect()); + ConfMan.setInt("transition_mode", _optionsDialog->getTransitions()); + ConfMan.flushToDisk(); + } + } + if (hasGameEnded()) { // Attempt to autosave before exiting tryAutoSaving(); diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 7a0d8b51c3..fa82f92682 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -135,6 +135,7 @@ private: void initVars(); void pauseEngineIntern(bool) override; + uint32 sanitizeTransitionMode(uint32 mode); public: // Stack/card/script funtions RivenStack *constructStackById(uint16 id); diff --git a/engines/mohawk/riven_vars.cpp b/engines/mohawk/riven_vars.cpp index e2166c9f4c..e79d418b97 100644 --- a/engines/mohawk/riven_vars.cpp +++ b/engines/mohawk/riven_vars.cpp @@ -21,6 +21,7 @@ */ #include "common/str.h" +#include "common/config-manager.h" #include "mohawk/riven.h" #include "mohawk/riven_stack.h" @@ -302,7 +303,8 @@ void MohawkEngine_Riven::initVars() { _vars["blabpage"] = 1; _vars["bidvlv"] = 1; _vars["bvise"] = 1; - _vars["waterenabled"] = 1; + _vars["azip"] = ConfMan.getBool("zip_mode"); + _vars["waterenabled"] = ConfMan.getBool("water_effects"); _vars["ogehnpage"] = 1; _vars["bblrsw"] = 1; _vars["ocage"] = 1; @@ -319,9 +321,11 @@ void MohawkEngine_Riven::initVars() { _vars["gpinpos"] = 1; _vars["grviewmpos"] = 1617; _vars["omusicplayer"] = 1; - _vars["transitionmode"] = kRivenTransitionModeFastest; _vars["tdomeelev"] = 1; + uint32 transitions = ConfMan.getInt("transition_mode"); + _vars["transitionmode"] = sanitizeTransitionMode(transitions); + // Randomize the telescope combination uint32 &teleCombo = _vars["tcorrectorder"]; for (byte i = 0; i < 5; i++) { |