diff options
author | Filippos Karapetis | 2008-11-12 23:21:05 +0000 |
---|---|---|
committer | Filippos Karapetis | 2008-11-12 23:21:05 +0000 |
commit | 28da377ccb945797aedf76c73eaec4773d03a0ef (patch) | |
tree | afa63dff0e85beff800b87ed108da91028534702 /engines/cine | |
parent | f1b1327b3359c6b43dff663094c9451b7d1e246b (diff) | |
download | scummvm-rg350-28da377ccb945797aedf76c73eaec4773d03a0ef.tar.gz scummvm-rg350-28da377ccb945797aedf76c73eaec4773d03a0ef.tar.bz2 scummvm-rg350-28da377ccb945797aedf76c73eaec4773d03a0ef.zip |
Saving and loading from the GMM is now supported in the cine engine
svn-id: r35031
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/cine.h | 4 | ||||
-rw-r--r-- | engines/cine/detection.cpp | 55 | ||||
-rw-r--r-- | engines/cine/various.cpp | 2 | ||||
-rw-r--r-- | engines/cine/various.h | 2 |
4 files changed, 61 insertions, 2 deletions
diff --git a/engines/cine/cine.h b/engines/cine/cine.h index 933f692ec2..29d2f05b89 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -92,6 +92,10 @@ public: void makeSystemMenu(void); int modifyGameSpeed(int speedChange); int getTimerDelay() const; + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const char *desc); + bool canLoadGameStateCurrently(); + bool canSaveGameStateCurrently(); const CINEGameDescription *_gameDescription; Common::File _partFileHandle; diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index eefd60e26c..07195fa7b9 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -31,6 +31,7 @@ #include "common/system.h" #include "cine/cine.h" +#include "cine/various.h" namespace Cine { @@ -547,7 +548,9 @@ bool CineMetaEngine::hasFeature(MetaEngineFeature f) const { bool Cine::CineEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); } bool CineMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { @@ -609,3 +612,53 @@ int CineMetaEngine::getMaximumSaveSlot() const { return 9; } #else REGISTER_PLUGIN_STATIC(CINE, PLUGIN_TYPE_ENGINE, CineMetaEngine); #endif + +namespace Cine { + +Common::Error CineEngine::loadGameState(int slot) { + char saveNameBuffer[256]; + sprintf(saveNameBuffer, "%s.%1d", _targetName.c_str(), slot); + bool gameLoaded = makeLoad(saveNameBuffer); + + return gameLoaded ? Common::kNoError : Common::kUnknownError; +} + +Common::Error CineEngine::saveGameState(int slot, const char *desc) { + // Load savegame descriptions from index file + loadSaveDirectory(); + + // Set description for selected slot + strncpy(currentSaveName[slot], desc, 20); + + // Update savegame descriptions + char indexFile[80]; + snprintf(indexFile, 80, "%s.dir", _targetName.c_str()); + + Common::OutSaveFile *fHandle = g_saveFileMan->openForSaving(indexFile); + if (!fHandle) { + warning("Unable to open file %s for saving", indexFile); + return Common::kUnknownError; + } + + fHandle->write(currentSaveName, 10 * 20); + delete fHandle; + + // Save game + char saveFileName[256]; + sprintf(saveFileName, "%s.%1d", _targetName.c_str(), slot); + makeSave(saveFileName); + + checkDataDisk(-1); + + return Common::kNoError; +} + +bool CineEngine::canLoadGameStateCurrently() { + return (!disableSystemMenu && !inMenu); +} + +bool CineEngine::canSaveGameStateCurrently() { + return (allowPlayerInput && !disableSystemMenu && !inMenu); +} + +} // End of namespace Cine diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 1bd3d3967c..4d928456d4 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -115,7 +115,7 @@ uint16 yMoveKeyb = kKeybMoveCenterY; SelectedObjStruct currentSelectedObject; -static CommandeType currentSaveName[10]; +CommandeType currentSaveName[10]; int16 currentDisk; static const int16 choiceResultTable[] = { 1, 1, 1, 2, 1, 1, 1 }; diff --git a/engines/cine/various.h b/engines/cine/various.h index b841908c65..81a1ab1115 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -45,6 +45,8 @@ void makeActionMenu(void); extern bool disableSystemMenu; extern bool inMenu; +extern CommandeType currentSaveName[10]; + struct SeqListElement { int16 var4; uint16 objIdx; ///< Is this really unsigned? |