aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-08-29 01:10:25 +0200
committerThierry Crozat2018-01-23 01:53:00 +0000
commit1af00170b42a20e0c507ff288155d7fda5c5db37 (patch)
tree01a45050e71b2c912c21068578fabd23bc5dd546
parent2b03a1f52ab0a97e094282654e903758a806c9c8 (diff)
downloadscummvm-rg350-1af00170b42a20e0c507ff288155d7fda5c5db37.tar.gz
scummvm-rg350-1af00170b42a20e0c507ff288155d7fda5c5db37.tar.bz2
scummvm-rg350-1af00170b42a20e0c507ff288155d7fda5c5db37.zip
SUPERNOVA: Extends MetaEngine for load/save support
-rw-r--r--engines/supernova/detection.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/engines/supernova/detection.cpp b/engines/supernova/detection.cpp
index 1ac9ff98d0..3e1082c7b0 100644
--- a/engines/supernova/detection.cpp
+++ b/engines/supernova/detection.cpp
@@ -78,21 +78,66 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual void removeSaveState(const char *target, int slot) const;
+ virtual int getMaximumSaveSlot() const {
+ return 10;
+ }
};
bool SupernovaMetaEngine::hasFeature(MetaEngineFeature f) const {
- // STUB
- return false;
+ switch (f) {
+ case kSupportsLoadingDuringStartup:
+ // fallthrough
+ case kSupportsListSaves:
+ // fallthrough
+ case kSupportsDeleteSave:
+ return true;
+ default:
+ return false;
+ }
}
bool SupernovaMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new Supernova::SupernovaEngine(syst);
}
-
+
return desc != NULL;
}
+SaveStateList SupernovaMetaEngine::listSaves(const char *target) const {
+ Common::StringArray filenames;
+ Common::String pattern("msn_save.##");
+
+ filenames = g_system->getSavefileManager()->listSavefiles(pattern);
+
+ char saveFileDesc[128];
+ SaveStateList saveFileList;
+ for (Common::StringArray::const_iterator file = filenames.begin();
+ file != filenames.end(); ++file) {
+ int saveSlot = atoi(file->c_str() + file->size() - 2);
+ if (saveSlot >= 0 && saveSlot <= getMaximumSaveSlot()) {
+ Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(*file);
+ if (savefile) {
+ savefile->skip(2);
+ savefile->read(saveFileDesc, sizeof(saveFileDesc));
+ saveFileList.push_back(SaveStateDescriptor(saveSlot, saveFileDesc));
+
+ delete savefile;
+ }
+ }
+ }
+
+ Common::sort(saveFileList.begin(), saveFileList.end(), SaveStateDescriptorSlotComparator());
+ return saveFileList;
+}
+
+void SupernovaMetaEngine::removeSaveState(const char *target, int slot) const {
+ Common::String filename = Common::String::format("msn_save.%02d", slot);
+ g_system->getSavefileManager()->removeSavefile(filename);
+}
+
#if PLUGIN_ENABLED_DYNAMIC(SUPERNOVA)
REGISTER_PLUGIN_DYNAMIC(SUPERNOVA, PLUGIN_TYPE_ENGINE, SupernovaMetaEngine);
#else