[Scummvm-cvs-logs] scummvm master -> 92cc2a7bc8f844a49b7e43840282ca6c57a7a80b

dreammaster dreammaster at scummvm.org
Sun Jun 29 04:41:03 CEST 2014


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:
92cc2a7bc8 MADS: Create savegame thumbnail from scenes before opening in-game dialogs


Commit: 92cc2a7bc8f844a49b7e43840282ca6c57a7a80b
    https://github.com/scummvm/scummvm/commit/92cc2a7bc8f844a49b7e43840282ca6c57a7a80b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-06-28T22:40:25-04:00

Commit Message:
MADS: Create savegame thumbnail from scenes before opening in-game dialogs

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 8639f59..dde2b40 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -64,6 +64,7 @@ Game::Game(MADSEngine *vm)
 	_loadGameSlot = -1;
 	_lastSave = -1;
 	_saveFile = nullptr;
+	_saveThumb = nullptr;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
 	_sectionNumber = 1;
@@ -93,6 +94,11 @@ Game::Game(MADSEngine *vm)
 }
 
 Game::~Game() {
+	if (_saveThumb) {
+		_saveThumb->free();
+		delete _saveThumb;
+	}
+
 	delete _saveFile;
 	delete _surface;
 	delete _sectionHandler;
@@ -548,16 +554,14 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
 	out->write(header._saveName.c_str(), header._saveName.size());
 	out->writeByte('\0');
 
-	// Get the active palette
-	uint8 thumbPalette[256 * 3];
-	g_system->getPaletteManager()->grabPalette(thumbPalette, 0, 256);
-
-	// Create a thumbnail and save it
-	Graphics::Surface *thumb = new Graphics::Surface();
-	::createThumbnail(thumb, _vm->_screen.getData(), MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, thumbPalette);
-	Graphics::saveThumbnail(*out, *thumb);
-	thumb->free();
-	delete thumb;
+	// Handle the thumbnail. If there's already one set by the game, create one
+	if (!_saveThumb)
+		createThumbnail();
+	Graphics::saveThumbnail(*out, *_saveThumb);
+	
+	_saveThumb->free();
+	delete _saveThumb;
+	_saveThumb = nullptr;
 
 	// Write out the save date/time
 	TimeDate td;
@@ -570,4 +574,16 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
 	out->writeUint32LE(_vm->_events->getFrameCounter());
 }
 
+void Game::createThumbnail() {
+	if (_saveThumb) {
+		_saveThumb->free();
+		delete _saveThumb;
+	}
+
+	uint8 thumbPalette[256 * 3];
+	_vm->_palette->grabPalette(thumbPalette, 0, 256);
+	_saveThumb = new Graphics::Surface();
+	::createThumbnail(_saveThumb, _vm->_screen.getData(), MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, thumbPalette);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 08cd7e7..1a61fc8 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -82,6 +82,7 @@ protected:
 	int _lastSave;
 	Common::String _saveName;
 	Common::InSaveFile *_saveFile;
+	Graphics::Surface *_saveThumb;
 
 	/**
 	 * Constructor
@@ -226,6 +227,11 @@ public:
 	 * Read in a savegame header
 	 */
 	static bool readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header);
+
+	/**
+	 * Creates a temporary thumbnail for use in saving games
+	 */
+	void createThumbnail();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index d6d7a07..8fddf8b 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "common/config-manager.h"
+#include "graphics/scaler.h"
 #include "mads/mads.h"
 #include "mads/game.h"
 #include "mads/screen.h"
@@ -310,6 +311,11 @@ void GameNebular::setSectionHandler() {
 void GameNebular::checkShowDialog() {
 	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[kCopyProtectFailed]) {
 		_player.releasePlayerSprites();
+
+		// Make a thumbnail in case it's needed for making a savegame
+		_vm->_game->createThumbnail();
+
+		// Show the dialog
 		_vm->_dialogs->showDialog();
 		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 	}
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ffeed6c..639f297 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -346,7 +346,7 @@ void Scene::loop() {
 		// Handle drawing a game frame
 		doFrame();
 
-		// TODO: Verify correctness of frame wait
+		// Wait for the next frame
 		_vm->_events->waitForNextFrame();
 
 		if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger






More information about the Scummvm-git-logs mailing list