diff options
author | Borja Lorente | 2016-08-02 12:00:07 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-14 19:00:36 +0200 |
commit | b7b4862e4c93898e5a315c672e52df0ea1894cc6 (patch) | |
tree | 4b8578e0914e55d146669e4b99adc95b33c43209 /engines/macventure/detection.cpp | |
parent | 90b022c07834d13c0ceacadad09d35ff0ea193b3 (diff) | |
download | scummvm-rg350-b7b4862e4c93898e5a315c672e52df0ea1894cc6.tar.gz scummvm-rg350-b7b4862e4c93898e5a315c672e52df0ea1894cc6.tar.bz2 scummvm-rg350-b7b4862e4c93898e5a315c672e52df0ea1894cc6.zip |
MACVENTURE: Add metadata to savegames
Diffstat (limited to 'engines/macventure/detection.cpp')
-rw-r--r-- | engines/macventure/detection.cpp | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/engines/macventure/detection.cpp b/engines/macventure/detection.cpp index 85cbb11cae..64a7923f04 100644 --- a/engines/macventure/detection.cpp +++ b/engines/macventure/detection.cpp @@ -29,10 +29,9 @@ namespace MacVenture { - const char *MacVentureEngine::getGameFileName() const { - return _gameDescription->filesDescriptions[0].fileName; - } - +const char *MacVentureEngine::getGameFileName() const { + return _gameDescription->filesDescriptions[0].fileName; +} } namespace MacVenture { @@ -46,6 +45,8 @@ static const PlainGameDescriptor macventureGames[] = { { 0, 0 } }; +SaveStateDescriptor loadMetaData(Common::SeekableReadStream *s, int slot); + class MacVentureMetaEngine : public AdvancedMetaEngine { public: MacVentureMetaEngine() : AdvancedMetaEngine(MacVenture::gameDescriptions, sizeof(ADGameDescription), macventureGames) { @@ -62,12 +63,57 @@ public: virtual bool createInstance(OSystem * syst, Engine ** engine, const ADGameDescription * desc) const; virtual bool hasFeature(MetaEngineFeature f) const; + virtual SaveStateList listSaves(const char *target) const; + virtual int getMaximumSaveSlot() const; }; bool MacVentureMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup); } +SaveStateList MacVentureMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String pattern = target; + pattern += ".###"; + + filenames = saveFileMan->listSavefiles(pattern); + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + int slotNum = atoi(file->c_str() + file->size() - 3); + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); + + SaveStateDescriptor desc; + // Do not allow save slot 0 (used for auto-saving) to be deleted or + // overwritten. + desc.setDeletableFlag(slotNum != 0); + desc.setWriteProtectedFlag(slotNum == 0); + + if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) { + Common::InSaveFile *in = saveFileMan->openForLoading(*file); + if (in) { + SaveStateDescriptor desc = loadMetaData(in, slotNum); + if (desc.getSaveSlot() != slotNum) { + // invalid + delete in; + continue; + } + saveList.push_back(desc); + delete in; + } + } + } + + // Sort saves based on slot number. + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); + return saveList; +} + +int MacVentureMetaEngine::getMaximumSaveSlot() const { return 999; } + bool MacVentureMetaEngine::createInstance(OSystem * syst, Engine ** engine, const ADGameDescription *game) const { if (game) { *engine = new MacVentureEngine(syst, game); |