aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1
diff options
context:
space:
mode:
authorThierry Crozat2017-07-08 00:31:10 +0100
committerThierry Crozat2017-07-08 00:38:28 +0100
commit6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6 (patch)
tree696ea01471217a7d3662ad8e1da97a52cdb9c5d9 /engines/sword1
parent07d6ffd989ce89e52c6381d8c9a2c53ffaa7e05e (diff)
downloadscummvm-rg350-6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6.tar.gz
scummvm-rg350-6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6.tar.bz2
scummvm-rg350-6f5ccb8f439a8fbed73996b04babe9c8e1fcc0c6.zip
SWORD1: Add thumbnail when saving from game panel
This fixes bug #9908 SWORD1: Picture previews black when saving in game
Diffstat (limited to 'engines/sword1')
-rw-r--r--engines/sword1/control.cpp16
-rw-r--r--engines/sword1/control.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index a790356974..c9b4f9f6c2 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 2d15bcdd15..4e27728cce 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);