diff options
author | Bastien Bouclet | 2017-12-20 17:51:57 +0100 |
---|---|---|
committer | Bastien Bouclet | 2017-12-20 19:16:07 +0100 |
commit | a33548c0d2085f6f5ea0e66be2d4f22ef1192047 (patch) | |
tree | 5e0f28a58cecd80fce7fe6d7ea0c309ca9e05844 | |
parent | f4bc714677fd778015053fac532c4dc2a9dfccd7 (diff) | |
download | scummvm-rg350-a33548c0d2085f6f5ea0e66be2d4f22ef1192047.tar.gz scummvm-rg350-a33548c0d2085f6f5ea0e66be2d4f22ef1192047.tar.bz2 scummvm-rg350-a33548c0d2085f6f5ea0e66be2d4f22ef1192047.zip |
MOHAWK: RIVEN: Add keyboard shortcuts for loading and saving
Those shortcuts are documented in the original game manual.
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | engines/mohawk/dialogs.cpp | 24 | ||||
-rw-r--r-- | engines/mohawk/dialogs.h | 6 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 45 | ||||
-rw-r--r-- | engines/mohawk/riven.h | 8 |
6 files changed, 72 insertions, 15 deletions
@@ -944,6 +944,8 @@ Page Down: Look down Space: Pause the game Esc: Skip cutscene F5: Menu +Ctrl-o: Load game +Ctrl-s: Save game 3.18) Simon the Sorcerer games notes: diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp index df832c9a2c..029867f6a6 100644 --- a/engines/mohawk/dialogs.cpp +++ b/engines/mohawk/dialogs.cpp @@ -94,13 +94,13 @@ enum { MohawkOptionsDialog::MohawkOptionsDialog(MohawkEngine *vm) : GUI::Dialog(0, 0, 360, 200), - _vm(vm), _loadSlot(-1) { - _loadButton = new GUI::ButtonWidget(this, 245, 25, 100, 25, _("~L~oad"), 0, kLoadCmd); - _saveButton = new GUI::ButtonWidget(this, 245, 60, 100, 25, _("~S~ave"), 0, kSaveCmd); - new GUI::ButtonWidget(this, 245, 95, 100, 25, _("~Q~uit"), 0, kQuitCmd); + _vm(vm), _loadSlot(-1), _saveSlot(-1) { + _loadButton = new GUI::ButtonWidget(this, 245, 25, 100, 25, _("~L~oad"), nullptr, kLoadCmd); + _saveButton = new GUI::ButtonWidget(this, 245, 60, 100, 25, _("~S~ave"), nullptr, kSaveCmd); + new GUI::ButtonWidget(this, 245, 95, 100, 25, _("~Q~uit"), nullptr, kQuitCmd); - new GUI::ButtonWidget(this, 95, 160, 120, 25, _("~O~K"), 0, GUI::kOKCmd); - new GUI::ButtonWidget(this, 225, 160, 120, 25, _("~C~ancel"), 0, GUI::kCloseCmd); + new GUI::ButtonWidget(this, 95, 160, 120, 25, _("~O~K"), nullptr, GUI::kOKCmd); + new GUI::ButtonWidget(this, 225, 160, 120, 25, _("~C~ancel"), nullptr, GUI::kCloseCmd); _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false); _saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); @@ -115,22 +115,22 @@ void MohawkOptionsDialog::open() { GUI::Dialog::open(); _loadSlot = -1; + _saveSlot = -1; _loadButton->setEnabled(_vm->canLoadGameStateCurrently()); _saveButton->setEnabled(_vm->canSaveGameStateCurrently()); } void MohawkOptionsDialog::save() { - int slot = _saveDialog->runModalWithCurrentTarget(); + _saveSlot = _saveDialog->runModalWithCurrentTarget(); - if (slot >= 0) { - Common::String result(_saveDialog->getResultString()); - if (result.empty()) { + if (_saveSlot >= 0) { + _saveDescription = _saveDialog->getResultString(); + if (_saveDescription.empty()) { // If the user was lazy and entered no save name, come up with a default name. - result = _saveDialog->createDefaultSaveDescription(slot); + _saveDescription = _saveDialog->createDefaultSaveDescription(_saveSlot); } - _vm->saveGameState(slot, result); close(); } } diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h index 9cbf5ff74c..efc1005737 100644 --- a/engines/mohawk/dialogs.h +++ b/engines/mohawk/dialogs.h @@ -83,7 +83,9 @@ public: virtual void reflowLayout() override; virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override; - int getLoadSlot() const {return _loadSlot;} + int getLoadSlot() const { return _loadSlot; } + int getSaveSlot() const { return _saveSlot; } + Common::String getSaveDescription() const { return _saveDescription; } private: MohawkEngine *_vm; @@ -95,6 +97,8 @@ private: GUI::SaveLoadChooser *_saveDialog; int _loadSlot; + int _saveSlot; + Common::String _saveDescription; void save(); void load(); diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index e229faf078..5baa89cea8 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -391,6 +391,8 @@ void MohawkEngine_Myst::doFrame() { runDialog(*_optionsDialog); if (_optionsDialog->getLoadSlot() >= 0) loadGameState(_optionsDialog->getLoadSlot()); + if (_optionsDialog->getSaveSlot() >= 0) + saveGameState(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription()); if (_needsPageDrop) { dropPage(); diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index 266706ae11..0bf4024057 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -238,6 +238,8 @@ void MohawkEngine_Riven::doFrame() { runDialog(*_optionsDialog); if (_optionsDialog->getLoadSlot() >= 0) loadGameStateAndDisplayError(_optionsDialog->getLoadSlot()); + if (_optionsDialog->getSaveSlot() >= 0) + saveGameStateAndDisplayError(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription()); _gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]); _card->initializeZipMode(); break; @@ -257,6 +259,20 @@ void MohawkEngine_Riven::doFrame() { changeToCard(6); } break; + case Common::KEYCODE_o: + if (event.kbd.flags & Common::KBD_CTRL) { + if (canLoadGameStateCurrently()) { + runLoadDialog(); + } + } + break; + case Common::KEYCODE_s: + if (event.kbd.flags & Common::KBD_CTRL) { + if (canSaveGameStateCurrently()) { + runSaveDialog(); + } + } + break; default: if (event.kbdRepeat) { continue; @@ -525,6 +541,24 @@ void MohawkEngine_Riven::runLoadDialog() { } } +void MohawkEngine_Riven::runSaveDialog() { + GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true); + + pauseEngine(true); + int slot = slc.runModalWithCurrentTarget(); + pauseEngine(false); + + if (slot >= 0) { + Common::String result(slc.getResultString()); + if (result.empty()) { + // If the user was lazy and entered no save name, come up with a default name. + result = slc.createDefaultSaveDescription(slot); + } + + saveGameStateAndDisplayError(slot, result); + } +} + Common::Error MohawkEngine_Riven::loadGameState(int slot) { return _saveLoad->loadGame(slot); } @@ -544,6 +578,17 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String & return _saveLoad->saveGame(slot, desc); } +void MohawkEngine_Riven::saveGameStateAndDisplayError(int slot, const Common::String &desc) { + assert(slot >= 0 && !desc.empty()); + + Common::Error saveError = saveGameState(slot, desc); + + if (saveError.getCode() != Common::kNoError) { + GUI::MessageDialog dialog(saveError.getDesc()); + dialog.runModal(); + } +} + void MohawkEngine_Riven::addZipVisitedCard(uint16 cardId, uint16 cardNameId) { Common::String cardName = getStack()->getName(kCardNames, cardNameId); if (cardName.empty()) diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h index 58d0855074..86a431170f 100644 --- a/engines/mohawk/riven.h +++ b/engines/mohawk/riven.h @@ -100,7 +100,6 @@ public: bool canLoadGameStateCurrently(); bool canSaveGameStateCurrently(); Common::Error loadGameState(int slot); - void loadGameStateAndDisplayError(int slot); Common::Error saveGameState(int slot, const Common::String &desc); bool hasFeature(EngineFeature f) const; @@ -148,9 +147,14 @@ public: Common::SeekableReadStream *getExtrasResource(uint32 tag, uint16 id); bool _activatedPLST; bool _activatedSLST; - void runLoadDialog(); void delay(uint32 ms); + // Save / Load + void runLoadDialog(); + void runSaveDialog(); + void loadGameStateAndDisplayError(int slot); + void saveGameStateAndDisplayError(int slot, const Common::String &desc); + /** * Has the game ended, or has the user requested to quit? */ |