diff options
Diffstat (limited to 'engines/touche')
-rw-r--r-- | engines/touche/detection.cpp | 53 | ||||
-rw-r--r-- | engines/touche/saveload.cpp | 5 | ||||
-rw-r--r-- | engines/touche/touche.h | 4 |
3 files changed, 56 insertions, 6 deletions
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index d2798d7060..63d2a3a078 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -25,6 +25,7 @@ #include "common/config-manager.h" #include "common/advancedDetector.h" +#include "common/savefile.h" #include "base/plugins.h" @@ -136,6 +137,7 @@ public: } virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; }; bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { @@ -146,6 +148,57 @@ bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Comm return gd != 0; } +SaveStateList ToucheMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringList filenames; + char saveDesc[Touche::kGameStateDescriptionLen]; + Common::String pattern = target; + pattern += ".?"; + + filenames = saveFileMan->listSavefiles(pattern.c_str()); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last digit of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 1); + + if (slotNum >= 0 && slotNum <= 9) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + in->readUint16LE(); + in->readUint16LE(); + in->read(saveDesc, Touche::kGameStateDescriptionLen); + saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file)); + delete in; + } + } + } + + pattern += "?"; + + filenames = saveFileMan->listSavefiles(pattern.c_str()); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 2 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 2); + + if (slotNum >= 10 && slotNum <= 99) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + in->readUint16LE(); + in->readUint16LE(); + in->read(saveDesc, Touche::kGameStateDescriptionLen); + saveList.push_back(SaveStateDescriptor(slotNum, Common::String(saveDesc), *file)); + delete in; + } + } + } + + return saveList; +} + #if PLUGIN_ENABLED_DYNAMIC(TOUCHE) REGISTER_PLUGIN_DYNAMIC(TOUCHE, PLUGIN_TYPE_ENGINE, ToucheMetaEngine); #else diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index c96a28bc8e..fedd40eb76 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -31,11 +31,6 @@ namespace Touche { -enum { - kCurrentGameStateVersion = 6, - kGameStateDescriptionLen = 32 -}; - static void saveOrLoad(Common::WriteStream &stream, uint16 &i) { stream.writeUint16LE(i); } diff --git a/engines/touche/touche.h b/engines/touche/touche.h index f5ac492550..90ab9933bd 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -328,7 +328,9 @@ enum { kCursorHeight = 42, kTextHeight = 16, kMaxProgramDataSize = 61440, - kMaxSaveStates = 100 + kMaxSaveStates = 100, + kGameStateDescriptionLen = 32, // Need these two values defined here + kCurrentGameStateVersion = 6 // for --list-saves support }; class MidiPlayer; |