MOHAWK: MYST: Save the options to ConfMan when the game is not started

This commit is contained in:
Bastien Bouclet 2019-10-30 05:51:22 +01:00
parent 08191db22a
commit 8a02d0efad
6 changed files with 55 additions and 13 deletions

@ -186,9 +186,6 @@ void MystOptionsDialog::open() {
if (_vm->getFeatures() & GF_DEMO)
_zipModeCheckbox->setEnabled(false);
_zipModeCheckbox->setState(_vm->_gameState->_globals.zipMode);
_transitionsCheckbox->setState(_vm->_gameState->_globals.transitions);
if (_vm->getFeatures() & GF_25TH) {
// The 25th anniversary version has a main menu, no need to show these buttons here
_loadButton->setVisible(false);
@ -247,15 +244,12 @@ void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
setResult(kActionGoToMenu);
close();
break;
case kQuitCmd: {
case kQuitCmd:
setResult(kActionShowCredits);
close();
}
break;
case GUI::kOKCmd:
_vm->_gameState->_globals.zipMode = _zipModeCheckbox->getState();
_vm->_gameState->_globals.transitions = _transitionsCheckbox->getState();
setResult(kActionNone);
setResult(kActionSaveSettings);
close();
break;
default:
@ -275,6 +269,22 @@ void MystOptionsDialog::setCanReturnToMenu(bool canReturnToMenu) {
_canReturnToMenu = canReturnToMenu;
}
bool MystOptionsDialog::getZipMode() const {
return _zipModeCheckbox->getState();
}
void MystOptionsDialog::setZipMode(bool enabled) {
_zipModeCheckbox->setState(enabled);
}
bool MystOptionsDialog::getTransitions() const {
return _transitionsCheckbox->getState();
}
void MystOptionsDialog::setTransitions(bool enabled) {
_transitionsCheckbox->setState(enabled);
}
#endif
#ifdef ENABLE_RIVEN

@ -80,7 +80,6 @@ public:
~MohawkOptionsDialog() override;
void reflowLayout() override;
int getResult() const { return GUI::Dialog::getResult(); }
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
};
@ -96,7 +95,7 @@ public:
~MystOptionsDialog() override;
enum ResultAction {
kActionNone = 1,
kActionSaveSettings = 1,
kActionDropPage,
kActionShowMap,
kActionGoToMenu,
@ -107,6 +106,11 @@ public:
void setCanShowMap(bool canShowMap);
void setCanReturnToMenu(bool canReturnToMenu);
bool getZipMode() const;
void setZipMode(bool enabled);
bool getTransitions() const;
void setTransitions(bool enabled);
void open() override;
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;

@ -366,6 +366,9 @@ Common::Error MohawkEngine_Myst::run() {
return Common::kAudioDeviceInitFailed;
}
ConfMan.registerDefault("zip_mode", false);
ConfMan.registerDefault("transition_mode", false);
_gfx = new MystGraphics(this);
_video = new VideoManager(this);
_sound = new MystSound(this);
@ -578,6 +581,14 @@ void MohawkEngine_Myst::runOptionsDialog() {
stack = _stack;
}
if (isGameStarted()) {
_optionsDialog->setZipMode(_gameState->_globals.zipMode);
_optionsDialog->setTransitions(_gameState->_globals.transitions);
} else {
_optionsDialog->setZipMode(ConfMan.getBool("zip_mode"));
_optionsDialog->setTransitions(ConfMan.getBool("transition_mode"));
}
_optionsDialog->setCanDropPage(actionsAllowed && _gameState->_globals.heldPage != kNoPage);
_optionsDialog->setCanShowMap(actionsAllowed && stack->getMap());
_optionsDialog->setCanReturnToMenu(actionsAllowed && stack->getStackId() != kDemoStack);
@ -615,6 +626,16 @@ void MohawkEngine_Myst::runOptionsDialog() {
quitGame();
}
break;
case MystOptionsDialog::kActionSaveSettings:
if (isGameStarted()) {
_gameState->_globals.zipMode = _optionsDialog->getZipMode();
_gameState->_globals.transitions = _optionsDialog->getTransitions();
} else {
ConfMan.setBool("zip_mode", _optionsDialog->getZipMode());
ConfMan.setBool("transition_mode", _optionsDialog->getTransitions());
ConfMan.flushToDisk();
}
break;
default:
if (_optionsDialog->getLoadSlot() >= 0)
loadGameState(_optionsDialog->getLoadSlot());
@ -1108,6 +1129,10 @@ void MohawkEngine_Myst::goToMainMenu() {
_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
}
bool MohawkEngine_Myst::isGameStarted() const {
return _prevStack || (_stack->getStackId() != kMenuStack);
}
void MohawkEngine_Myst::resumeFromMainMenu() {
_card->leave();
_card.reset();

@ -214,6 +214,7 @@ private:
void pauseEngineIntern(bool pause) override;
void goToMainMenu();
bool isGameStarted() const;
void dropPage();

@ -24,6 +24,7 @@
#include "mohawk/myst.h"
#include "mohawk/myst_state.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/serializer.h"
#include "common/system.h"
@ -94,6 +95,9 @@ void MystGameState::reset() {
_globals.u1 = 1;
_globals.ending = kDniNotVisited;
_globals.zipMode = ConfMan.getBool("zip_mode");
_globals.transitions = ConfMan.getBool("transition_mode");
// Library Bookcase Door - Default to Up
_myst.libraryBookcaseDoor = 1;
// Dock Imager Numeric Selection - Default to 67

@ -849,9 +849,7 @@ void MohawkEngine_Riven::runOptionsDialog() {
_optionsDialog->setTransitions(sanitizeTransitionMode(transitions));
}
runDialog(*_optionsDialog);
if (_optionsDialog->getResult() > 0) {
if (runDialog(*_optionsDialog) > 0) {
if (isGameStarted()) {
_vars["azip"] = _optionsDialog->getZipMode() ? 1 : 0;
_vars["waterenabled"] = _optionsDialog->getWaterEffect() ? 1 : 0;