From 92fc264461e1870725310cba38916afaece13022 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 14 Sep 2008 21:00:24 +0000 Subject: - Added thumbnail support to launcher load dialog. - Adopted KYRA to support displaying thumbnails in load dialog (SCUMM engine has yet to follow) svn-id: r34539 --- engines/kyra/detection.cpp | 20 +++++++++++++++++++- engines/metaengine.h | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 834f9f70c6..06d96d57bb 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -1068,6 +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; }; bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const { @@ -1075,7 +1076,8 @@ bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSupportsRTL) || (f == kSupportsListSaves) || (f == kSupportsDirectLoad) || - (f == kSupportsDeleteSave); + (f == kSupportsDeleteSave) || + (f == kSupportsThumbnails); } bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { @@ -1201,6 +1203,22 @@ void KyraMetaEngine::removeSaveState(const char *target, int slot) const { } +Graphics::Surface *KyraMetaEngine::loadThumbnailFromSlot(const char *target, int slot) const { + char extension[6]; + snprintf(extension, sizeof(extension), ".%03d", slot); + + Common::String filename = target; + filename += extension; + + 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; + + return 0; +} + #if PLUGIN_ENABLED_DYNAMIC(KYRA) REGISTER_PLUGIN_DYNAMIC(KYRA, PLUGIN_TYPE_ENGINE, KyraMetaEngine); #else diff --git a/engines/metaengine.h b/engines/metaengine.h index b6fa21fd5f..f9a6c42cbc 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -106,6 +106,18 @@ public: */ virtual void removeSaveState(const char *target, int slot) const {}; + /** + * Loads a thumbnail 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. + * + * @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; } + /** @name MetaEngineFeature flags */ //@{ @@ -131,7 +143,13 @@ public: * Deleting Saves from the Launcher (i.e. implements the * removeSaveState() method) */ - kSupportsDeleteSave = 3 + kSupportsDeleteSave = 3, + + /** + * Features a thumbnail in savegames (i.e. implements the + * loadThumbnailFromSlot method) + */ + kSupportsThumbnails = 4 }; /** -- cgit v1.2.3