[Scummvm-git-logs] scummvm master -> ae4da8bce0ea13adfcd2c7b368c9af1608fd6eaf

dreammaster dreammaster at scummvm.org
Sun Mar 7 17:34:35 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ae4da8bce0 ENGINES: Make creation of savegame thumbnails an overrideable method


Commit: ae4da8bce0ea13adfcd2c7b368c9af1608fd6eaf
    https://github.com/scummvm/scummvm/commit/ae4da8bce0ea13adfcd2c7b368c9af1608fd6eaf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T09:34:33-08:00

Commit Message:
ENGINES: Make creation of savegame thumbnails an overrideable method

Changed paths:
    engines/cine/saveload.cpp
    engines/engine.cpp
    engines/metaengine.cpp
    engines/metaengine.h
    engines/ultima/nuvie/files/nuvie_io_file.cpp


diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp
index 6b03f4fcd3..8398aff349 100644
--- a/engines/cine/saveload.cpp
+++ b/engines/cine/saveload.cpp
@@ -1030,7 +1030,7 @@ void CineEngine::makeSave(const Common::String &saveFileName, uint32 playtime,
 		renderer->popSavedBackBuffer(BEFORE_OPENING_MENU);
 	}
 
-	MetaEngine::appendExtendedSave(fHandle.get(), playtime, desc, isAutosave);
+	getMetaEngine().appendExtendedSave(fHandle.get(), playtime, desc, isAutosave);
 
 	renderer->restoreSavedBackBuffer(BEFORE_TAKING_THUMBNAIL);
 
diff --git a/engines/engine.cpp b/engines/engine.cpp
index dcd14f4d9f..a4e2526434 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -774,7 +774,7 @@ Common::Error Engine::saveGameState(int slot, const Common::String &desc, bool i
 
 	Common::Error result = saveGameStream(saveFile, isAutosave);
 	if (result.getCode() == Common::kNoError) {
-		MetaEngine::appendExtendedSave(saveFile, getTotalPlayTime() / 1000, desc, isAutosave);
+		getMetaEngine().appendExtendedSave(saveFile, getTotalPlayTime() / 1000, desc, isAutosave);
 
 		saveFile->finalize();
 	}
diff --git a/engines/metaengine.cpp b/engines/metaengine.cpp
index 6f4984aa18..f7e7d96927 100644
--- a/engines/metaengine.cpp
+++ b/engines/metaengine.cpp
@@ -165,21 +165,19 @@ void MetaEngine::appendExtendedSave(Common::OutSaveFile *saveFile, uint32 playti
 	saveFile->writeString(desc);
 	saveFile->writeByte(isAutosave);
 
-	saveScreenThumbnail(saveFile);
+	// Write out the thumbnail
+	Graphics::Surface thumb;
+	getSavegameThumbnail(thumb);
+	Graphics::saveThumbnail(*saveFile, thumb);
+	thumb.free();
 
 	saveFile->writeUint32LE(headerPos);	// Store where the header starts
 
 	saveFile->finalize();
 }
 
-void MetaEngine::saveScreenThumbnail(Common::OutSaveFile *saveFile) {
-	// Create a thumbnail surface from the screen
-	Graphics::Surface thumb;
+void MetaEngine::getSavegameThumbnail(Graphics::Surface &thumb) {
 	::createThumbnailFromScreen(&thumb);
-
-	// Write out the thumbnail
-	Graphics::saveThumbnail(*saveFile, thumb);
-	thumb.free();
 }
 
 void MetaEngine::parseSavegameHeader(ExtendedSavegameHeader *header, SaveStateDescriptor *desc) {
diff --git a/engines/metaengine.h b/engines/metaengine.h
index c0ff716985..b759693ec8 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -200,11 +200,13 @@ public:
  * the engine, while a MetaEngine will always build into the executable to be able to detect code.
  */
 class MetaEngine : public PluginObject {
-private:
+protected:
 	/**
-	 * Convert the current screen contents to a thumbnail and save it.
+	 * Convert the current screen contents to a thumbnail. Can be overriden by individual
+	 * engine meta engines to provide their own thumb, such as hiding any on-screen save
+	 * dialog so that it won't appear in the thumbnail.
 	 */
-	static void saveScreenThumbnail(Common::OutSaveFile *saveFile);
+	virtual void getSavegameThumbnail(Graphics::Surface &thumb);
 public:
 	virtual ~MetaEngine() {}
 
@@ -488,7 +490,8 @@ public:
 	/**
 	 * Write the extended savegame header to the given savegame file.
 	 */
-	static void appendExtendedSave(Common::OutSaveFile *saveFile, uint32 playtime, Common::String desc, bool isAutosave);
+	void appendExtendedSave(Common::OutSaveFile *saveFile, uint32 playtime, Common::String desc, bool isAutosave);
+
 	/**
 	 * Parse the extended savegame header to retrieve the SaveStateDescriptor information.
 	 */
diff --git a/engines/ultima/nuvie/files/nuvie_io_file.cpp b/engines/ultima/nuvie/files/nuvie_io_file.cpp
index 32be6b9f26..0594994099 100644
--- a/engines/ultima/nuvie/files/nuvie_io_file.cpp
+++ b/engines/ultima/nuvie/files/nuvie_io_file.cpp
@@ -185,7 +185,7 @@ void NuvieIOFileWrite::close() {
 	} else if (_saveFile) {
 		// Writing using savefile interface, so flush out data
 		_saveFile->write(_saveFileData.getData(), _saveFileData.size());
-		MetaEngine::appendExtendedSave(_saveFile, Shared::g_ultima->getTotalPlayTime(), _description, _isAutosave);
+		g_engine->getMetaEngine().appendExtendedSave(_saveFile, Shared::g_ultima->getTotalPlayTime(), _description, _isAutosave);
 
 		_saveFile->finalize();
 		delete _saveFile;




More information about the Scummvm-git-logs mailing list