diff options
author | Bendegúz Nagy | 2016-08-18 17:50:56 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | bcb067698efe6e18be02a23eb48499ed8e0e714f (patch) | |
tree | 6a056d32fecbf7ce1fad0f27f45c1f81e083e295 /engines/dm/detection.cpp | |
parent | 4442b0b302f107013e88120c69d8cf41aaec0ecc (diff) | |
download | scummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.tar.gz scummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.tar.bz2 scummvm-rg350-bcb067698efe6e18be02a23eb48499ed8e0e714f.zip |
DM: Add support for loading from launcher
Diffstat (limited to 'engines/dm/detection.cpp')
-rw-r--r-- | engines/dm/detection.cpp | 69 |
1 files changed, 65 insertions, 4 deletions
diff --git a/engines/dm/detection.cpp b/engines/dm/detection.cpp index 200a81fe97..7f506ac478 100644 --- a/engines/dm/detection.cpp +++ b/engines/dm/detection.cpp @@ -32,6 +32,8 @@ #include "common/fs.h" #include "engines/advancedDetector.h" +#include <common/system.h> + namespace DM { static const PlainGameDescriptor DMGames[] = { {"dm", "Dungeon Master"}, @@ -46,7 +48,7 @@ static const ADGameDescription gameDescriptions[] = { {"Dungeon.dat", 0, "43a213da8eda413541dd12f90ce202f6", 25006}, AD_LISTEND }, - Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) + Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, { "dm", "Atari ???v English", @@ -94,13 +96,72 @@ public: virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { return gameDescriptions; } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { - if(desc) + if (desc) *engine = new DM::DMEngine(syst, desc); return desc != nullptr; } + + virtual bool hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportCreationDate); + } + virtual int getMaximumSaveSlot() const { return 99; } - virtual SaveStateList listSaves(const char *target) const { return SaveStateList(); } - SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); } + + virtual SaveStateList listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + SaveGameHeader header; + Common::String pattern = target; + pattern += ".###"; + + Common::StringArray filenames; + filenames = saveFileMan->listSavefiles(pattern.c_str()); + + SaveStateList saveList; + + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if ((slotNum >= 0) && (slotNum <= 999)) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + if (DM::readSaveGameHeader(in, &header)) + saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription())); + delete in; + } + } + } + + // Sort saves based on slot number. + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); + return saveList; + } + + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { + Common::String filename = Common::String::format("%s.%03u", target, slot); + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str()); + + if (in) { + DM::SaveGameHeader header; + + bool successfulRead = DM::readSaveGameHeader(in, &header); + delete in; + + if (successfulRead) { + SaveStateDescriptor desc(slot, header._descr.getDescription()); + + return header._descr; + } + } + + return SaveStateDescriptor(); + } + virtual void removeSaveState(const char *target, int slot) const {} }; |