From 28da377ccb945797aedf76c73eaec4773d03a0ef Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 12 Nov 2008 23:21:05 +0000 Subject: Saving and loading from the GMM is now supported in the cine engine svn-id: r35031 --- engines/cine/cine.h | 4 ++++ engines/cine/detection.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++- engines/cine/various.cpp | 2 +- engines/cine/various.h | 2 ++ 4 files changed, 61 insertions(+), 2 deletions(-) (limited to 'engines') 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? -- cgit v1.2.3