aboutsummaryrefslogtreecommitdiff
path: root/engines/composer/detection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/composer/detection.cpp')
-rw-r--r--engines/composer/detection.cpp58
1 files changed, 57 insertions, 1 deletions
diff --git a/engines/composer/detection.cpp b/engines/composer/detection.cpp
index 689a72a743..1157623de4 100644
--- a/engines/composer/detection.cpp
+++ b/engines/composer/detection.cpp
@@ -21,6 +21,11 @@
*/
#include "base/plugins.h"
+#ifdef SAVING_ANYWHERE
+#include "common/savefile.h"
+#include "common/serializer.h"
+#include "common/str-array.h"
+#endif //SAVING_ANYWHERE
#include "engines/advancedDetector.h"
#include "composer/composer.h"
@@ -448,6 +453,8 @@ public:
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual SaveStateList listSaves(const char* target) const;
};
bool ComposerMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -459,11 +466,60 @@ bool ComposerMetaEngine::createInstance(OSystem *syst, Engine **engine, const AD
}
bool ComposerMetaEngine::hasFeature(MetaEngineFeature f) const {
+#ifdef SAVING_ANYWHERE
+ return (f == kSupportsListSaves);
+#else
return false;
+#endif //SAVING_ANYWHERE
+}
+
+#ifdef SAVING_ANYWHERE
+Common::String getSaveName(Common::InSaveFile *in) {
+ Common::Serializer ser(in,NULL);
+ Common::String name;
+ uint32 tmp;
+ ser.syncAsUint32LE(tmp);
+ ser.syncAsUint32LE(tmp);
+ ser.syncString(name);
+ return name;
+}
+int ComposerMetaEngine::getMaximumSaveSlot() const {
+ return 99;
+}
+SaveStateList ComposerMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String saveDesc;
+ Common::String pattern = Common::String::format("%s.??",target);
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ 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() - 2);
+
+ if (slotNum >= 0 && slotNum <= 99) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ if (in) {
+ saveDesc = getSaveName(in);
+ saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
}
+#endif //SAVING_ANYWHERE
bool Composer::ComposerEngine::hasFeature(EngineFeature f) const {
- return (f == kSupportsRTL);
+ return (f == kSupportsRTL
+#ifdef SAVING_ANYWHERE
+ || f == kSupportsSavingDuringRuntime || f == kSupportsLoadingDuringRuntime
+#endif //SAVING_ANYWHERE
+ );
}
#if PLUGIN_ENABLED_DYNAMIC(COMPOSER)