diff options
author | Matthew Hoops | 2012-04-09 11:20:18 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-04-09 11:20:18 -0400 |
commit | 981833b34e73905045338053d528af68f81884d7 (patch) | |
tree | 88cc6738db075c29654e5b7a219f1cb8db65f096 /engines/pegasus | |
parent | ec0b4f7b96676dac890503cc156113b0966886b3 (diff) | |
download | scummvm-rg350-981833b34e73905045338053d528af68f81884d7.tar.gz scummvm-rg350-981833b34e73905045338053d528af68f81884d7.tar.bz2 scummvm-rg350-981833b34e73905045338053d528af68f81884d7.zip |
PEGASUS: Add support for load/save keys
Diffstat (limited to 'engines/pegasus')
-rw-r--r-- | engines/pegasus/ai/ai_area.cpp | 2 | ||||
-rw-r--r-- | engines/pegasus/input.cpp | 13 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/caldoria/caldoria.cpp | 2 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/neighborhood.cpp | 2 | ||||
-rw-r--r-- | engines/pegasus/pegasus.cpp | 59 | ||||
-rw-r--r-- | engines/pegasus/pegasus.h | 5 |
6 files changed, 73 insertions, 10 deletions
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp index b9b5ce9a51..e4d31049f2 100644 --- a/engines/pegasus/ai/ai_area.cpp +++ b/engines/pegasus/ai/ai_area.cpp @@ -309,7 +309,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo Input input; InputDevice.getInput(input, interruptFilter); - if (input.anyInput() || vm->shouldQuit()) { + if (input.anyInput() || vm->shouldQuit() || vm->saveRequested() || vm->loadRequested()) { result = false; break; } diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp index c60f00ddad..0250ecf99a 100644 --- a/engines/pegasus/input.cpp +++ b/engines/pegasus/input.cpp @@ -41,8 +41,6 @@ InputDeviceManager::InputDeviceManager() { } void InputDeviceManager::getInput(Input &input, const InputBits filter) { - // TODO: Save/Load keys - InputBits currentBits = 0; bool consoleRequested = false; bool altDown = false; @@ -102,6 +100,17 @@ void InputDeviceManager::getInput(Input &input, const InputBits filter) { if (event.kbd.flags & Common::KBD_CTRL) // Console! consoleRequested = true; break; + case Common::KEYCODE_s: + // We support meta where available and control elsewhere + if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META)) + ((PegasusEngine *)g_engine)->requestSave(); + break; + case Common::KEYCODE_o: // o for open (original) + case Common::KEYCODE_l: // l for load (ScummVM terminology) + // We support meta where available and control elsewhere + if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META)) + ((PegasusEngine *)g_engine)->requestLoad(); + break; default: break; } diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp index b7c45dc0c6..dedfd88aa8 100644 --- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp +++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp @@ -223,7 +223,7 @@ void Caldoria::start() { } InputDevice.getInput(input, kPullbackInterruptFilter); - if (input.anyInput()) { // TODO: Save/Quit requests + if (input.anyInput() || _vm->saveRequested() || _vm->loadRequested()) { skipped = true; break; } diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp index c8fc28e148..3378459a5d 100644 --- a/engines/pegasus/neighborhood/neighborhood.cpp +++ b/engines/pegasus/neighborhood/neighborhood.cpp @@ -1591,7 +1591,7 @@ void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordTy while (_croppedMovie.isRunning() && !_vm->shouldQuit()) { _vm->processShell(); InputDevice.getInput(input, interruptionFilter); - if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request + if (input.anyInput() || _vm->saveRequested() || _vm->loadRequested() || _vm->shouldQuit()) break; _vm->_system->delayMillis(10); } diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index e863626266..225bcbc35f 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -78,6 +78,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede _smallInfoMovie(kNoDisplayElement) { _continuePoint = 0; _saveAllowed = _loadAllowed = true; + _saveRequested = _loadRequested = false; _gameMenu = 0; _deathReason = kDeathStranded; _neighborhood = 0; @@ -891,8 +892,55 @@ void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) { _console->onFrame(); } - // TODO: Save request - // TODO: Load request + // Handle save requests here + if (_saveRequested && _saveAllowed) { + _saveRequested = false; + + // Can only save during a game and not in the demo + if (g_neighborhood && !isDemo()) { + pauseEngine(true); + showSaveDialog(); + pauseEngine(false); + } + } + + // Handle load requests here + if (_loadRequested && _loadAllowed) { + _loadRequested = false; + + // WORKAROUND: Do not entertain load requests when the pause menu is up + // The original did and the game entered a bad state after loading. + // It's theoretically possible to make it so it does work while the + // pause menu is up, but the pause state of the engine is just too weird. + // Just use the pause menu's restore button since it's there for that + // for you to load anyway. + if (!isDemo() && !(_gameMenu && _gameMenu->getObjectID() == kPauseMenuID)) { + pauseEngine(true); + + if (g_neighborhood) { + makeContinuePoint(); + + Common::Error result = showLoadDialog(); + if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled) + loadFromContinuePoint(); + } else { + if (_introTimer) + _introTimer->stopFuse(); + + Common::Error result = showLoadDialog(); + if (result.getCode() != Common::kNoError) { + if (!_gameMenu) { + useMenu(new MainMenu()); + ((MainMenu *)_gameMenu)->startMainMenuLoop(); + } + + resetIntroTimer(); + } + } + + pauseEngine(false); + } + } } void PegasusEngine::doInterfaceOverview() { @@ -1008,7 +1056,7 @@ void PegasusEngine::doInterfaceOverview() { for (;;) { InputDevice.getInput(input, kFilterAllInput); - if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too + if (input.anyInput() || shouldQuit() || _loadRequested || _saveRequested) break; input.getInputLocation(cursorLoc); @@ -1055,7 +1103,8 @@ void PegasusEngine::doInterfaceOverview() { ((MainMenu *)_gameMenu)->startMainMenuLoop(); _gfx->doFadeInSync(); - // TODO: Cancel save/load requests? + _saveRequested = false; + _loadRequested = false; } void PegasusEngine::showTempScreen(const Common::String &fileName) { @@ -1223,7 +1272,7 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x Input input; InputDevice.getInput(input, kFilterAllInput); - if (input.anyInput()) + if (input.anyInput() || _saveRequested || _loadRequested) skipped = true; _system->delayMillis(10); diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index 349856d27b..a1b4cff9ab 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -189,6 +189,10 @@ public: _loadAllowed = allow; return old; } + void requestSave() { _saveRequested = true; } + bool saveRequested() const { return _saveRequested; } + void requestLoad() { _loadRequested = true; } + bool loadRequested() const { return _loadRequested; } protected: Common::Error run(); @@ -243,6 +247,7 @@ private: bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P Common::Error showLoadDialog(); Common::Error showSaveDialog(); + bool _saveRequested, _loadRequested; // Misc. Hotspot _returnHotspot; |