aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2008-09-16 14:10:55 +0000
committerJohannes Schickel2008-09-16 14:10:55 +0000
commit259d87a8a68d443d2bbb2bcc1887b4f11b7d342e (patch)
tree15389a0901e3439eda5b83975f0d98556fbd2b41 /engines
parent9d96d9d3806c43107ffcf4173bd99c3d10eeb565 (diff)
downloadscummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.tar.gz
scummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.tar.bz2
scummvm-rg350-259d87a8a68d443d2bbb2bcc1887b4f11b7d342e.zip
Added "querySaveMetaInfos" to MetaEngine.
-> Allows easy addition of save state specific infos like playtime, save date atc. -> Removed MetaEngine::loadThumbnailFromSlot, superseded by meta infos -> Changed SCUMM / KYRA to implement the newly added functionallity -> Removed hack in KYRAs listSavefiles, which is now handled via meta infos svn-id: r34581
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/detection.cpp32
-rw-r--r--engines/metaengine.h23
-rw-r--r--engines/scumm/detection.cpp24
3 files changed, 56 insertions, 23 deletions
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index c630e61b05..7a377471c1 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -1068,7 +1068,7 @@ public:
bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const;
SaveStateList listSaves(const char *target) const;
void removeSaveState(const char *target, int slot) const;
- Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
};
bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -1077,6 +1077,7 @@ bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSupportsListSaves) ||
(f == kSupportsDirectLoad) ||
(f == kSupportsDeleteSave) ||
+ (f == kSupportsMetaInfos) ||
(f == kSupportsThumbnails);
}
@@ -1137,10 +1138,7 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
- // HACK: Until we have a way to check whether a save is deletable in our launcher delete savegame dialog.
- // We do not list slot 0 here, since it's for restarting the game and it should never be deleted.
- // The downside of it is of course we can not load it via the menu and it isn't listed via --list-saves.
- if (slotNum > 0 && slotNum <= 999) {
+ if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
if (in) {
if (Kyra::KyraEngine_v1::readSaveHeader(in, false, header) == Kyra::KyraEngine_v1::kRSHENoError) {
@@ -1194,16 +1192,28 @@ void KyraMetaEngine::removeSaveState(const char *target, int slot) const {
}
-Graphics::Surface *KyraMetaEngine::loadThumbnailFromSlot(const char *target, int slot) const {
+SaveStateDescriptor KyraMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String filename = Kyra::KyraEngine_v1::getSavegameFilename(target, slot);
-
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
- Kyra::KyraEngine_v1::SaveHeader header;
- if (in && Kyra::KyraEngine_v1::readSaveHeader(in, true, header) == Kyra::KyraEngine_v1::kRSHENoError)
- return header.thumbnail;
+ if (in) {
+ Kyra::KyraEngine_v1::SaveHeader header;
+ Kyra::KyraEngine_v1::kReadSaveHeaderError error;
+
+ error = Kyra::KyraEngine_v1::readSaveHeader(in, true, header);
+ delete in;
+
+ if (error == Kyra::KyraEngine_v1::kRSHENoError) {
+ SaveStateDescriptor desc(slot, header.description, filename);
+
+ desc.setDeletableFlag(slot != 0);
+ desc.setThumbnail(header.thumbnail);
+
+ return desc;
+ }
+ }
- return 0;
+ return SaveStateDescriptor();
}
#if PLUGIN_ENABLED_DYNAMIC(KYRA)
diff --git a/engines/metaengine.h b/engines/metaengine.h
index f9a6c42cbc..525afe5fa3 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -107,18 +107,16 @@ public:
virtual void removeSaveState(const char *target, int slot) const {};
/**
- * Loads a thumbnail from the specified save state.
+ * Returns meta infos from the specified save state.
*
- * This can return '0' to indicate that no thumbnail was found.
- * If it returns a valid Graphics::Surface object, it must be the same
- * format as the overlay.
+ * Depending on the MetaEngineFeatures set this can include
+ * thumbnails, save date / time, play time.
*
* @param target name of a config manager target
* @param slot slot number of the save state
*/
- virtual Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot) const { return 0; }
+ virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); }
-
/** @name MetaEngineFeature flags */
//@{
@@ -146,10 +144,17 @@ public:
kSupportsDeleteSave = 3,
/**
- * Features a thumbnail in savegames (i.e. implements the
- * loadThumbnailFromSlot method)
+ * Features meta infos for savestates (i.e. implements the
+ * querySaveMetaInfos method properly)
+ */
+ kSupportsMetaInfos = 4,
+
+ /**
+ * Features a thumbnail in savegames (i.e. includes a thumbnail
+ * in savestates returned via querySaveMetaInfo). This flag may
+ * only be set when 'kSupportsMetaInfos' is set.
*/
- kSupportsThumbnails = 4
+ kSupportsThumbnails = 5
};
/**
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index ce991a8997..34775ab575 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -683,7 +683,7 @@ public:
virtual SaveStateList listSaves(const char *target) const;
virtual void removeSaveState(const char *target, int slot) const;
- virtual Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot) const;
+ virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
};
bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -692,6 +692,7 @@ bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSupportsListSaves) ||
(f == kSupportsDirectLoad) ||
(f == kSupportsDeleteSave) ||
+ (f == kSupportsMetaInfos) ||
(f == kSupportsThumbnails);
}
@@ -983,8 +984,25 @@ void ScummMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(filename.c_str());
}
-Graphics::Surface *ScummMetaEngine::loadThumbnailFromSlot(const char *target, int slot) const {
- return ScummEngine::loadThumbnailFromSlot(target, slot);
+SaveStateDescriptor ScummMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Common::String filename = ScummEngine::makeSavegameName(target, slot, false);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+ if (!in)
+ return SaveStateDescriptor();
+
+ Common::String saveDesc;
+ Scumm::getSavegameName(in, saveDesc, 0); // FIXME: heversion?!?
+ delete in;
+
+ // TODO: Cleanup
+ Graphics::Surface *thumbnail = ScummEngine::loadThumbnailFromSlot(target, slot);
+
+ SaveStateDescriptor desc(slot, saveDesc, filename);
+ desc.setDeletableFlag(true);
+ desc.setThumbnail(thumbnail);
+
+ return desc;
}
#if PLUGIN_ENABLED_DYNAMIC(SCUMM)