diff options
author | Matthew Hoops | 2011-12-19 18:55:08 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-12-19 18:55:08 -0500 |
commit | 924e0b32ad80cefb81d1cadc55d389a14430a5a7 (patch) | |
tree | 854aa6d4407a4c8fd905e9b16daf224963a44a84 /engines/pegasus | |
parent | fa92148098c2ea5302e6b324e289fed118d6ace3 (diff) | |
download | scummvm-rg350-924e0b32ad80cefb81d1cadc55d389a14430a5a7.tar.gz scummvm-rg350-924e0b32ad80cefb81d1cadc55d389a14430a5a7.tar.bz2 scummvm-rg350-924e0b32ad80cefb81d1cadc55d389a14430a5a7.zip |
PEGASUS: Implement saving/loading from the in-game pause menu
Diffstat (limited to 'engines/pegasus')
-rw-r--r-- | engines/pegasus/pegasus.cpp | 59 | ||||
-rw-r--r-- | engines/pegasus/pegasus.h | 3 |
2 files changed, 56 insertions, 6 deletions
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 5e7d188d7b..da2f09e6c5 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -306,7 +306,7 @@ void PegasusEngine::runIntro() { delete video; } -void PegasusEngine::showLoadDialog() { +Common::Error PegasusEngine::showLoadDialog() { GUI::SaveLoadChooser slc(_("Load game:"), _("Load")); slc.setSaveMode(false); @@ -317,10 +317,47 @@ void PegasusEngine::showLoadDialog() { int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); - if (slot >= 0) - loadGameState(slot); + Common::Error result; + + if (slot >= 0) { + if (loadGameState(slot).getCode() == Common::kNoError) + result = Common::kNoError; + else + result = Common::kUnknownError; + } else { + result = Common::kUserCanceled; + } slc.close(); + + return result; +} + +Common::Error PegasusEngine::showSaveDialog() { + GUI::SaveLoadChooser slc(_("Save game:"), _("Save")); + slc.setSaveMode(true); + + Common::String gameId = ConfMan.get("gameid"); + + const EnginePlugin *plugin = 0; + EngineMan.findGame(gameId, &plugin); + + int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + + Common::Error result; + + if (slot >= 0) { + if (saveGameState(slot, slc.getResultString()).getCode() == Common::kNoError) + result = Common::kNoError; + else + result = Common::kUnknownError; + } else { + result = Common::kUserCanceled; + } + + slc.close(); + + return result; } GUI::Debugger *PegasusEngine::getDebugger() { @@ -640,6 +677,8 @@ bool PegasusEngine::checkGameMenu() { } void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) { + Common::Error result; + switch (command) { case kMenuCmdStartAdventure: GameState.setWalkthroughMode(false); @@ -734,13 +773,23 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) { resetIntroTimer(); break; case kMenuCmdPauseSave: - error("Save game"); + if (showSaveDialog().getCode() != Common::kUserCanceled) + pauseMenu(false); break; case kMenuCmdPauseContinue: pauseMenu(false); break; case kMenuCmdPauseRestore: - error("Load game"); + makeContinuePoint(); + result = showLoadDialog(); + + if (result.getCode() == Common::kNoError) { + // Successfully loaded, unpause the game + pauseMenu(false); + } else if (result.getCode() != Common::kUserCanceled) { + // Try to get us back to a sane state + loadFromContinuePoint(); + } break; case kMenuCmdPauseQuit: _gfx->doFadeOutSync(); diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index 86ba267e54..bd8f04b17b 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -236,11 +236,12 @@ private: void loadFromContinuePoint(); Common::ReadStream *_continuePoint; bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P + Common::Error showLoadDialog(); + Common::Error showSaveDialog(); // Misc. Hotspot _returnHotspot; InputHandler *_savedHandler; - void showLoadDialog(); void showTempScreen(const Common::String &fileName); bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y); void throwAwayEverything(); |