aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorJohannes Schickel2008-09-16 14:10:55 +0000
committerJohannes Schickel2008-09-16 14:10:55 +0000
commit259d87a8a68d443d2bbb2bcc1887b4f11b7d342e (patch)
tree15389a0901e3439eda5b83975f0d98556fbd2b41 /base
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 'base')
-rw-r--r--base/game.cpp29
-rw-r--r--base/game.h39
2 files changed, 49 insertions, 19 deletions
diff --git a/base/game.cpp b/base/game.cpp
index e65c891dc7..30fd5fc850 100644
--- a/base/game.cpp
+++ b/base/game.cpp
@@ -69,9 +69,30 @@ void GameDescriptor::updateDesc(const char *extra) {
}
void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) {
- if (_thumbnail && _thumbnail != t) {
- _thumbnail->free();
- delete _thumbnail;
+ if (_thumbnail.get() == t)
+ return;
+
+ _thumbnail = Common::SharedPtr<Graphics::Surface>(t, Graphics::SharedPtrSurfaceDeleter());
+}
+
+bool SaveStateDescriptor::getBool(const Common::String &key) const {
+ if (contains(key)) {
+ Common::String value = getVal(key);
+ if (value.equalsIgnoreCase("true") ||
+ value.equalsIgnoreCase("yes") ||
+ value.equals("1"))
+ return true;
+ if (value.equalsIgnoreCase("false") ||
+ value.equalsIgnoreCase("no") ||
+ value.equals("0"))
+ return false;
+ error("SaveStateDescriptor: %s '%s' has unknown value '%s' for boolean '%s'",
+ save_slot().c_str(), description().c_str(), value.c_str(), key.c_str());
}
- _thumbnail = t;
+ return false;
}
+
+void SaveStateDescriptor::setDeletableFlag(bool state) {
+ setVal("is_deletable", state ? "true" : "false");
+}
+
diff --git a/base/game.h b/base/game.h
index d81f2afb8a..6f9030c56f 100644
--- a/base/game.h
+++ b/base/game.h
@@ -29,6 +29,7 @@
#include "common/str.h"
#include "common/array.h"
#include "common/hash-str.h"
+#include "common/ptr.h"
namespace Graphics {
struct Surface;
@@ -119,15 +120,16 @@ public:
*/
class SaveStateDescriptor : public Common::StringMap {
protected:
- Graphics::Surface *_thumbnail; // can be NULL
+ Common::SharedPtr<Graphics::Surface> _thumbnail; // can be 0
+
public:
- SaveStateDescriptor() : _thumbnail(0) {
+ SaveStateDescriptor() : _thumbnail() {
setVal("save_slot", "-1"); // FIXME: default to 0 (first slot) or to -1 (invalid slot) ?
setVal("description", "");
setVal("filename", "");
}
- SaveStateDescriptor(int s, const Common::String &d, const Common::String &f) : _thumbnail(0) {
+ SaveStateDescriptor(int s, const Common::String &d, const Common::String &f) : _thumbnail() {
char buf[16];
sprintf(buf, "%d", s);
setVal("save_slot", buf);
@@ -135,16 +137,12 @@ public:
setVal("filename", f);
}
- SaveStateDescriptor(const Common::String &s, const Common::String &d, const Common::String &f) : _thumbnail(0) {
+ SaveStateDescriptor(const Common::String &s, const Common::String &d, const Common::String &f) : _thumbnail() {
setVal("save_slot", s);
setVal("description", d);
setVal("filename", f);
}
- ~SaveStateDescriptor() {
- setThumbnail(0);
- }
-
/** The saveslot id, as it would be passed to the "-x" command line switch. */
Common::String &save_slot() { return getVal("save_slot"); }
@@ -163,19 +161,30 @@ public:
/** The filename of the savestate, for use with the SaveFileManager API (read-only variant). */
const Common::String &filename() const { return getVal("filename"); }
+ /** Optional entries only included when querying via MetaEngine::querySaveMetaInfo */
+
+ /**
+ * Returns the value of a given key as boolean.
+ * It accepts 'true', 'yes' and '1' for true and
+ * 'false', 'no' and '0' for false.
+ * (FIXME:) On unknown value it errors out ScummVM.
+ * On unknown key it returns false as default.
+ */
+ bool getBool(const Common::String &key) const;
+
+ /**
+ * Sets the 'is_deletable' key, which indicates, if the
+ * given savestate is safe for deletion.
+ */
+ void setDeletableFlag(bool state);
+
/**
* Return a thumbnail graphics surface representing the savestate visually
* This is usually a scaled down version of the game graphics. The size
* should be either 160x100 or 160x120 pixels, depending on the aspect
* ratio of the game. If another ratio is required, contact the core team.
- *
- * TODO: it is probably a bad idea to read this for *all* games at once,
- * at least on low-end devices. So this info should probably normally only
- * be included optionally. I.e. only upon a query for a specific savegame...
- * To this end, add a getFullSaveStateInfo(target, slot) to the plugin API.
*/
- const Graphics::Surface *getThumbnail() const { return _thumbnail; }
-
+ const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); }
void setThumbnail(Graphics::Surface *t);
};