aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sludge')
-rw-r--r--engines/sludge/builtin.cpp5
-rw-r--r--engines/sludge/graphics.cpp4
-rw-r--r--engines/sludge/graphics.h7
-rw-r--r--engines/sludge/sludger.cpp3
-rw-r--r--engines/sludge/thumbnail.cpp23
5 files changed, 30 insertions, 12 deletions
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 8195fc53f9..909118a2dd 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -58,7 +58,7 @@ int speechMode = 0;
Variable *launchResult = NULL;
-extern int lastFramesPerSecond, thumbWidth, thumbHeight;
+extern int lastFramesPerSecond;
extern bool allowAnyFilename;
extern VariableStack *noStack;
extern StatusStuff *nowStatus;
@@ -2460,13 +2460,14 @@ builtIn(showThumbnail) {
builtIn(setThumbnailSize) {
UNUSEDALL
+ int thumbHeight, thumbWidth;
if (!getValueType(thumbHeight, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
if (!getValueType(thumbWidth, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
- if (!g_sludge->_gfxMan->checkSizeValide(thumbWidth, thumbHeight)) {
+ if (!g_sludge->_gfxMan->setThumbnailSize(thumbWidth, thumbHeight)) {
Common::String buff = Common::String::format("%i x %i", thumbWidth, thumbWidth);
fatal("Invalid thumbnail size", buff);
return BR_ERROR;
diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp
index 578e6f65fe..580124f513 100644
--- a/engines/sludge/graphics.cpp
+++ b/engines/sludge/graphics.cpp
@@ -83,6 +83,10 @@ void GraphicsManager::init() {
_currentBurnR = 0;
_currentBurnG = 0;
_currentBurnB = 0;
+
+ // Thumbnail
+ _thumbWidth = 0;
+ _thumbHeight = 0;
}
void GraphicsManager::kill() {
diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h
index 16973a1658..6c5351cb53 100644
--- a/engines/sludge/graphics.h
+++ b/engines/sludge/graphics.h
@@ -167,7 +167,8 @@ public:
void saveColors(Common::WriteStream *stream);
void loadColors(Common::SeekableReadStream *stream);
- // Thumb nail
+ // Thumbnail
+ bool setThumbnailSize(int thumbWidth, int thumbHeight);
bool saveThumbnail(Common::WriteStream *stream);
bool skipThumbnail(Common::SeekableReadStream *stream);
void showThumbnail(const Common::String &filename, int x, int y);
@@ -222,6 +223,10 @@ private:
// Colors
uint _currentBlankColour;
byte _currentBurnR, _currentBurnG, _currentBurnB;
+
+ // Thumbnail
+ int _thumbWidth;
+ int _thumbHeight;
};
} // End of namespace Sludge
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index 4f5f204d92..f616fe696b 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -79,7 +79,7 @@ Variable *globalVars;
int numGlobals = 0;
extern Variable *launchResult;
-extern int lastFramesPerSecond, thumbWidth, thumbHeight;
+extern int lastFramesPerSecond;
extern bool allowAnyFilename;
extern byte fadeMode;
@@ -167,7 +167,6 @@ void initSludge() {
launchResult = nullptr;
lastFramesPerSecond = -1;
- thumbWidth = thumbHeight = 0;
allowAnyFilename = true;
noStack = nullptr;
numBIFNames = numUserFunc = 0;
diff --git a/engines/sludge/thumbnail.cpp b/engines/sludge/thumbnail.cpp
index 2c7e007f71..dcbcd91db3 100644
--- a/engines/sludge/thumbnail.cpp
+++ b/engines/sludge/thumbnail.cpp
@@ -35,14 +35,23 @@
namespace Sludge {
-int thumbWidth = 0, thumbHeight = 0;
+bool GraphicsManager::setThumbnailSize(int thumbWidth, int thumbHeight)
+{
+ if (checkSizeValide(thumbWidth, thumbHeight))
+ {
+ _thumbWidth = thumbWidth;
+ _thumbHeight = thumbHeight;
+ return true;
+ }
+ return false;
+}
bool GraphicsManager::saveThumbnail(Common::WriteStream *stream) {
- stream->writeUint32LE(thumbWidth);
- stream->writeUint32LE(thumbHeight);
+ stream->writeUint32LE(_thumbWidth);
+ stream->writeUint32LE(_thumbHeight);
- if (thumbWidth && thumbHeight) {
+ if (_thumbWidth && _thumbHeight) {
if (!freeze())
return false;
@@ -117,12 +126,12 @@ void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int
}
bool GraphicsManager::skipThumbnail(Common::SeekableReadStream *stream) {
- thumbWidth = stream->readUint32LE();
- thumbHeight = stream->readUint32LE();
+ _thumbWidth = stream->readUint32LE();
+ _thumbHeight = stream->readUint32LE();
// Load image
Graphics::Surface tmp;
- if (thumbWidth & thumbHeight) {
+ if (_thumbWidth & _thumbHeight) {
if (!ImgLoader::loadPNGImage(stream, &tmp))
return false;
else