diff options
author | Max Horn | 2008-02-04 10:15:21 +0000 |
---|---|---|
committer | Max Horn | 2008-02-04 10:15:21 +0000 |
commit | 5fb7f7a4d66c48be928440c3142b196a479ca94c (patch) | |
tree | 14d1855b57dc2306ef094887a1b735b2722148b1 /base/game.h | |
parent | dd7fcd686790ea6a2e9021eac5b9e1c8bff88d26 (diff) | |
download | scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.tar.gz scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.tar.bz2 scummvm-rg350-5fb7f7a4d66c48be928440c3142b196a479ca94c.zip |
Commited updated version of my own patch #1868402: Basic savestate plugin API
svn-id: r30786
Diffstat (limited to 'base/game.h')
-rw-r--r-- | base/game.h | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/base/game.h b/base/game.h index 0764b7fbac..7dddea7b30 100644 --- a/base/game.h +++ b/base/game.h @@ -30,6 +30,10 @@ #include "common/array.h" #include "common/hash-str.h" +namespace Graphics { + class Surface; +} + /** * A simple structure used to map gameids (like "monkey", "sword1", ...) to * nice human readable and descriptive game titles (like "The Secret of Monkey Island"). @@ -67,7 +71,7 @@ public: setVal("description", pgd.description); } - GameDescriptor(Common::String g, Common::String d, Common::Language l = Common::UNK_LANG, + GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l = Common::UNK_LANG, Common::Platform p = Common::kPlatformUnknown) { setVal("gameid", g); setVal("description", d); @@ -103,6 +107,77 @@ public: } }; +/** + * A hashmap describing details about a given save state. + * TODO + * Guaranteed to contain save_slot, filename and description values. + * Additional ideas: Playtime, creation date, thumbnail, ... + */ +class SaveStateDescriptor : public Common::StringMap { +protected: + Graphics::Surface *_thumbnail; // can be NULL +public: + SaveStateDescriptor() : _thumbnail(0) { + 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) { + char buf[16]; + sprintf(buf, "%d", s); + setVal("save_slot", buf); + setVal("description", d); + setVal("filename", f); + } + + SaveStateDescriptor(const Common::String &s, const Common::String &d, const Common::String &f) : _thumbnail(0) { + 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"); } + + /** The saveslot id, as it would be passed to the "-x" command line switch (read-only variant). */ + const Common::String &save_slot() const { return getVal("save_slot"); } + + /** A human readable description of the save state. */ + Common::String &description() { return getVal("description"); } + + /** A human readable description of the save state (read-only variant). */ + const Common::String &description() const { return getVal("description"); } + + /** The filename of the savestate, for use with the SaveFileManager API. */ + Common::String &filename() { return getVal("filename"); } + + /** The filename of the savestate, for use with the SaveFileManager API (read-only variant). */ + const Common::String &filename() const { return getVal("filename"); } + + /** + * 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; } + + + void setThumbnail(Graphics::Surface *t); +}; + +/** List of savestates. */ +typedef Common::Array<SaveStateDescriptor> SaveStateList; class Plugin; |