aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2013-01-22 20:58:12 +0100
committerEinar Johan Trøan Sømåen2013-01-22 20:58:12 +0100
commitbede97c52c703366dbcf64fbfff4c7a6e77763d2 (patch)
treed125c7fcb4d32724525416c967680de33006cf35
parentc6df5f99949809fceb998d760ec332ce8626c615 (diff)
downloadscummvm-rg350-bede97c52c703366dbcf64fbfff4c7a6e77763d2.tar.gz
scummvm-rg350-bede97c52c703366dbcf64fbfff4c7a6e77763d2.tar.bz2
scummvm-rg350-bede97c52c703366dbcf64fbfff4c7a6e77763d2.zip
WINTERMUTE: Store larger thumbnails (Bump Savegame-version to 1.2.0.0)
-rw-r--r--engines/wintermute/base/base_persistence_manager.cpp57
-rw-r--r--engines/wintermute/base/base_persistence_manager.h2
-rw-r--r--engines/wintermute/base/base_save_thumb_helper.cpp56
-rw-r--r--engines/wintermute/base/base_save_thumb_helper.h3
-rw-r--r--engines/wintermute/dcgf.h2
5 files changed, 102 insertions, 18 deletions
diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp
index bd53ed38e4..1e2c06e5ef 100644
--- a/engines/wintermute/base/base_persistence_manager.cpp
+++ b/engines/wintermute/base/base_persistence_manager.cpp
@@ -71,6 +71,9 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool dele
_richBuffer = NULL;
_richBufferSize = 0;
+ _scummVMThumbnailData = NULL;
+ _scummVMThumbSize = 0;
+
_savedDescription = NULL;
// _savedTimestamp = 0;
_savedVerMajor = _savedVerMinor = _savedVerBuild = 0;
@@ -123,6 +126,12 @@ void BasePersistenceManager::cleanup() {
_thumbnailData = NULL;
}
+ _scummVMThumbSize = 0;
+ if (_scummVMThumbnailData) {
+ delete[] _scummVMThumbnailData;
+ _scummVMThumbnailData = NULL;
+ }
+
delete _loadStream;
delete _saveStream;
_loadStream = NULL;
@@ -131,7 +140,7 @@ void BasePersistenceManager::cleanup() {
Common::String BasePersistenceManager::getFilenameForSlot(int slot) const {
// 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise)
- return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot);
+ return Common::String::format("%s.%03d", _savePrefix.c_str(), slot);
}
void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
@@ -146,8 +155,18 @@ void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &des
desc.setDeletableFlag(true);
desc.setWriteProtectedFlag(false);
- if (_thumbnailDataSize > 0) {
- Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize);
+ int thumbSize = 0;
+ byte *thumbData = NULL;
+ if (_scummVMThumbSize > 0) {
+ thumbSize = _scummVMThumbSize;
+ thumbData = _scummVMThumbnailData;
+ } else if (_thumbnailDataSize > 0) {
+ thumbSize = _thumbnailDataSize;
+ thumbData = _thumbnailData;
+ }
+
+ if (thumbSize > 0) {
+ Common::MemoryReadStream thumbStream(thumbData, thumbSize);
Graphics::BitmapDecoder bmpDecoder;
if (bmpDecoder.loadStream(thumbStream)) {
Graphics::Surface *surf = NULL;
@@ -171,13 +190,13 @@ void BasePersistenceManager::deleteSaveSlot(int slot) {
}
uint32 BasePersistenceManager::getMaxUsedSlot() {
- Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str());
+ Common::String saveMask = Common::String::format("%s.???", _savePrefix.c_str());
Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask);
Common::StringArray::iterator it = saves.begin();
int ret = -1;
for (; it != saves.end(); ++it) {
int num = -1;
- sscanf(it->c_str(), "save%d", &num);
+ sscanf(it->c_str(), ".%d", &num);
ret = MAX(ret, num);
}
return ret;
@@ -249,6 +268,25 @@ bool BasePersistenceManager::initSave(const char *desc) {
if (!thumbnailOK) {
putDWORD(0);
}
+ thumbnailOK = false;
+ // Again for the ScummVM-thumb:
+ if (_gameRef->_cachedThumbnail) {
+ if (_gameRef->_cachedThumbnail->_scummVMThumb) {
+ Common::MemoryWriteStreamDynamic scummVMthumbStream(DisposeAfterUse::YES);
+ if (_gameRef->_cachedThumbnail->_scummVMThumb->writeBMPToStream(&scummVMthumbStream)) {
+ _saveStream->writeUint32LE(scummVMthumbStream.size());
+ _saveStream->write(scummVMthumbStream.getData(), scummVMthumbStream.size());
+ } else {
+ _saveStream->writeUint32LE(0);
+ }
+
+ thumbnailOK = true;
+ }
+ }
+ if (!thumbnailOK) {
+ putDWORD(0);
+ }
+
// in any case, destroy the cached thumbnail once used
delete _gameRef->_cachedThumbnail;
@@ -308,6 +346,15 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) {
_thumbnailDataSize = 0;
}
}
+ if (_savedVerMajor >= 1 && _savedVerMinor >= 2) {
+ _scummVMThumbSize = getDWORD();
+ _scummVMThumbnailData = new byte[_scummVMThumbSize];
+ if (_scummVMThumbnailData) {
+ getBytes(_scummVMThumbnailData, _scummVMThumbSize);
+ } else {
+ _scummVMThumbSize = 0;
+ }
+ }
} else {
_savedVerBuild = 35; // last build with ver1 savegames
}
diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h
index a262c92a0b..114f6e066f 100644
--- a/engines/wintermute/base/base_persistence_manager.h
+++ b/engines/wintermute/base/base_persistence_manager.h
@@ -93,6 +93,8 @@ public:
uint32 _thumbnailDataSize;
byte *_thumbnailData;
+ uint32 _scummVMThumbSize;
+ byte *_scummVMThumbnailData;
Common::String getFilenameForSlot(int slot) const;
private:
bool _deleteSingleton;
diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp
index b4205c21c4..d4df1dffb4 100644
--- a/engines/wintermute/base/base_save_thumb_helper.cpp
+++ b/engines/wintermute/base/base_save_thumb_helper.cpp
@@ -30,51 +30,83 @@
#include "engines/wintermute/base/gfx/base_image.h"
#include "engines/wintermute/base/gfx/base_renderer.h"
#include "engines/wintermute/base/base_game.h"
+#include "graphics/scaler.h"
namespace Wintermute {
//////////////////////////////////////////////////////////////////////////
BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) {
_thumbnail = NULL;
+ _scummVMThumb = NULL;
}
//////////////////////////////////////////////////////////////////////////
BaseSaveThumbHelper::~BaseSaveThumbHelper(void) {
delete _thumbnail;
_thumbnail = NULL;
+ delete _scummVMThumb;
+ _scummVMThumb = NULL;
}
-//////////////////////////////////////////////////////////////////////////
-bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) {
- delete _thumbnail;
- _thumbnail = NULL;
-
+BaseImage *BaseSaveThumbHelper::storeThumb(bool doFlip, int width, int height) {
+ BaseImage *thumbnail = NULL;
if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
if (doFlip) {
// when using opengl on windows it seems to be necessary to do this twice
// works normally for direct3d
_gameRef->displayContent(false);
_gameRef->_renderer->flip();
-
+
_gameRef->displayContent(false);
_gameRef->_renderer->flip();
}
-
+
BaseImage *screenshot = _gameRef->_renderer->takeScreenshot();
if (!screenshot) {
return STATUS_FAILED;
}
-
+
// normal thumbnail
if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
- _thumbnail = new BaseImage();
- _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
+ thumbnail = new BaseImage();
+ thumbnail->copyFrom(screenshot, width, height);
}
-
-
+
+
delete screenshot;
screenshot = NULL;
}
+ return thumbnail;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) {
+ delete _thumbnail;
+ _thumbnail = NULL;
+
+ if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+
+ _thumbnail = storeThumb(doFlip, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
+ if (!_thumbnail) {
+ return STATUS_FAILED;
+ }
+ }
+ storeScummVMThumbNail();
+ return STATUS_OK;
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool BaseSaveThumbHelper::storeScummVMThumbNail(bool doFlip) {
+ delete _thumbnail;
+ _thumbnail = NULL;
+
+ if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+
+ _scummVMThumb = storeThumb(doFlip, kThumbnailWidth, kThumbnailHeight2);
+ if (!_scummVMThumb) {
+ return STATUS_FAILED;
+ }
+ }
return STATUS_OK;
}
diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h
index 8863508ac9..8e8a7183c2 100644
--- a/engines/wintermute/base/base_save_thumb_helper.h
+++ b/engines/wintermute/base/base_save_thumb_helper.h
@@ -40,9 +40,12 @@ public:
BaseSaveThumbHelper(BaseGame *inGame);
virtual ~BaseSaveThumbHelper(void);
bool storeThumbnail(bool doFlip = false);
+ bool storeScummVMThumbNail(bool doFlip = false);
BaseImage *_thumbnail;
+ BaseImage *_scummVMThumb;
private:
+ BaseImage *storeThumb(bool doFlip, int width, int height);
BaseImage *_richThumbnail;
};
diff --git a/engines/wintermute/dcgf.h b/engines/wintermute/dcgf.h
index fc4174094b..0fbb1c6b29 100644
--- a/engines/wintermute/dcgf.h
+++ b/engines/wintermute/dcgf.h
@@ -32,7 +32,7 @@
//////////////////////////////////////////////////////////////////////////
#define DCGF_VER_MAJOR 1
-#define DCGF_VER_MINOR 1
+#define DCGF_VER_MINOR 2
#define DCGF_VER_BUILD 1
#define DCGF_VER_SUFFIX "beta"
#define DCGF_VER_BETA true