[Scummvm-git-logs] scummvm master -> 6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6

criezy criezy at scummvm.org
Sat Jul 8 01:44:09 CEST 2017


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:
6f5ccb8f43 SWORD1: Add thumbnail when saving from game panel


Commit: 6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6
    https://github.com/scummvm/scummvm/commit/6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-07-08T00:38:28+01:00

Commit Message:
SWORD1: Add thumbnail when saving from game panel

This fixes bug #9908 SWORD1: Picture previews black when
saving in game

Changed paths:
    engines/sword1/control.cpp
    engines/sword1/control.h


diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index a790356..c9b4f9f 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -28,6 +28,7 @@
 #include "common/config-manager.h"
 #include "common/textconsole.h"
 #include "common/translation.h"
+#include "common/memstream.h"
 
 #include "graphics/palette.h"
 #include "graphics/thumbnail.h"
@@ -239,6 +240,7 @@ Control::Control(Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMa
 	_lStrings = _languageStrings + SwordEngine::_systemVars.language * 20;
 	_selectedButton = 255;
 	_panelShown = false;
+	_tempThumbnail = 0;
 }
 
 void Control::askForCd() {
@@ -299,6 +301,11 @@ static int volToBalance(int volL, int volR) {
 }
 
 uint8 Control::runPanel() {
+	// Make a thumbnail of the screen before displaying the menu in case we want to save
+	// the game from the menu.
+	_tempThumbnail = new Common::MemoryWriteStreamDynamic;
+	Graphics::saveThumbnail(*_tempThumbnail);
+
 	_panelShown = true;
 	_mouseDown = false;
 	_restoreBuf = NULL;
@@ -418,6 +425,8 @@ uint8 Control::runPanel() {
 	_music->startMusic(Logic::_scriptVars[CURRENT_MUSIC], 1);
 	_sound->newScreen(Logic::_scriptVars[SCREEN]);
 	_panelShown = false;
+	delete _tempThumbnail;
+	_tempThumbnail = 0;
 	return retVal;
 }
 
@@ -1105,8 +1114,13 @@ void Control::saveGameToFile(uint8 slot) {
 	outf->write(_saveNames[slot].c_str(), 40);
 	outf->writeByte(SAVEGAME_VERSION);
 
-	if (!isPanelShown()) // Generate a thumbnail only if we are outside of game menu
+	// Saving can occur either delayed from the GMM (in which case the panel is now shown and we can make
+	// a thumbnail now) or from the game menu (the panel, in which case we created the _tempThumbnail just
+	// before showing the panel).
+	if (!isPanelShown())
 		Graphics::saveThumbnail(*outf);
+	else if (_tempThumbnail)
+		outf->write(_tempThumbnail->getData(), _tempThumbnail->size());
 
 	// Date / time
 	TimeDate curTime;
diff --git a/engines/sword1/control.h b/engines/sword1/control.h
index 2d15bcd..4e27728 100644
--- a/engines/sword1/control.h
+++ b/engines/sword1/control.h
@@ -31,6 +31,7 @@
 class OSystem;
 namespace Common {
 class SaveFileManager;
+class MemoryWriteStreamDynamic;
 }
 
 namespace Sword1 {
@@ -114,6 +115,7 @@ private:
 	uint8 _cursorTick;
 	bool _cursorVisible;
 	bool _panelShown;
+	Common::MemoryWriteStreamDynamic *_tempThumbnail;
 
 	uint8 getClicks(uint8 mode, uint8 *retVal);
 	uint8 handleButtonClick(uint8 id, uint8 mode, uint8 *retVal);





More information about the Scummvm-git-logs mailing list