From 3977a7ffa15d1db55d787b450307ef1c62fcda26 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Dec 2015 23:22:54 +0200 Subject: LAB: Add support for saving and loading games from the GMM --- engines/lab/anim.h | 2 ++ engines/lab/detection.cpp | 7 ++++--- engines/lab/engine.cpp | 2 ++ engines/lab/lab.cpp | 25 +++++++++++++++++++------ engines/lab/lab.h | 6 ++++++ 5 files changed, 33 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/lab/anim.h b/engines/lab/anim.h index 0118403842..bdb02e3f02 100644 --- a/engines/lab/anim.h +++ b/engines/lab/anim.h @@ -96,6 +96,8 @@ public: void stopDiffEnd(); uint16 getDIFFHeight(); + + bool isPlaying() const { return _isPlaying; } }; } // End of namespace Lab diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp index 5850dc69ae..c26231292b 100644 --- a/engines/lab/detection.cpp +++ b/engines/lab/detection.cpp @@ -155,9 +155,10 @@ bool LabMetaEngine::hasFeature(MetaEngineFeature f) const { } bool Lab::LabEngine::hasFeature(EngineFeature f) const { - return (f == kSupportsRTL); - //(f == kSupportsLoadingDuringRuntime) || - //(f == kSupportsSavingDuringRuntime); + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); } SaveStateList LabMetaEngine::listSaves(const char *target) const { diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index 20f38ef884..cf6ae71563 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -1036,9 +1036,11 @@ void LabEngine::go() { // If the user has requested to load a game from the launcher, skip the intro if (!ConfMan.hasKey("save_slot")) { _event->mouseHide(); + _introPlaying = true; Intro *intro = new Intro(this); intro->play(); delete intro; + _introPlaying = false; _event->mouseShow(); } diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp index e439aa15a7..70af5e8605 100644 --- a/engines/lab/lab.cpp +++ b/engines/lab/lab.cpp @@ -128,12 +128,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc) _monitorButtonHeight = 1; for (int i = 0; i < 20; i++) _highPalette[i] = 0; - - //const Common::FSNode gameDataDir(ConfMan.get("path")); - //SearchMan.addSubDirectoryMatching(gameDataDir, "game"); - //SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict"); - //SearchMan.addSubDirectoryMatching(gameDataDir, "game/spict"); - //SearchMan.addSubDirectoryMatching(gameDataDir, "music"); + _introPlaying = false; } LabEngine::~LabEngine() { @@ -248,4 +243,22 @@ void LabEngine::updateEvents() { _event->updateMouse(); } +Common::Error LabEngine::loadGameState(int slot) { + bool result = loadGame(slot); + return (result) ? Common::kNoError : Common::kUserCanceled; +} + +Common::Error LabEngine::saveGameState(int slot, const Common::String &desc) { + bool result = saveGame(slot, desc); + return (result) ? Common::kNoError : Common::kUserCanceled; +} + +bool LabEngine::canLoadGameStateCurrently() { + return !_anim->isPlaying() && !_introPlaying; +} + +bool LabEngine::canSaveGameStateCurrently() { + return !_anim->isPlaying() && !_introPlaying; +} + } // End of namespace Lab diff --git a/engines/lab/lab.h b/engines/lab/lab.h index 1933f3aec5..af80c904d1 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -160,6 +160,7 @@ private: Image *_monitorButton; Image *_journalBackImage; TextFont *_journalFont; + bool _introPlaying; public: bool _alternate; @@ -225,6 +226,11 @@ public: void updateEvents(); void waitTOF(); + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const Common::String &desc); + bool canLoadGameStateCurrently(); + bool canSaveGameStateCurrently(); + private: /** * Checks whether all the conditions in a condition list are met. -- cgit v1.2.3