[Scummvm-git-logs] scummvm master -> 901f05fca33415652c7f2225d3a2a52c0cce6dcf

sev- sev at scummvm.org
Sat Apr 17 13:08:12 UTC 2021


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
36755f2276 GUI: Add parameter for optional scaling GraphicsWidget
69ea52c2d0 GUI: Scale thumbnails in saveload dialog in HiDPI
b981e34cc8 JANITORIAL: Remove trailing spaces
901f05fca3 BLADERUNNER: Save full size thumbnails into saves. This bumps the save version to 4.


Commit: 36755f2276c566a66073be43de05233dfede036e
    https://github.com/scummvm/scummvm/commit/36755f2276c566a66073be43de05233dfede036e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-04-17T15:04:35+02:00

Commit Message:
GUI: Add parameter for optional scaling GraphicsWidget

Changed paths:
    gui/widget.cpp
    gui/widget.h


diff --git a/gui/widget.cpp b/gui/widget.cpp
index 87ac63f5b1..7f37e8f3da 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -869,7 +869,7 @@ GraphicsWidget::~GraphicsWidget() {
 	_gfx.free();
 }
 
-void GraphicsWidget::setGfx(const Graphics::ManagedSurface *gfx) {
+void GraphicsWidget::setGfx(const Graphics::ManagedSurface *gfx, bool scale) {
 	_gfx.free();
 
 	if (!gfx || !gfx->getPixels())
@@ -880,15 +880,19 @@ void GraphicsWidget::setGfx(const Graphics::ManagedSurface *gfx) {
 		return;
 	}
 
-	if ((_w != gfx->w || _h != gfx->h) && _w && _h) {
-		_gfx = *scaleGfx(gfx, _w, _h);
+	float sf = g_gui.getScaleFactor();
+	if ((scale && sf != 1.0) || ((_w != gfx->w || _h != gfx->h) && _w && _h)) {
+		Graphics::Surface *tmp2 = gfx->rawSurface().scale(gfx->w * sf, gfx->h * sf, false);
+		_gfx.copyFrom(*tmp2);
+		tmp2->free();
+		delete tmp2;
 	} else {
 		_gfx.copyFrom(*gfx);
 	}
 }
 
-void GraphicsWidget::setGfx(const Graphics::Surface *gfx) {
-	setGfx(new Graphics::ManagedSurface(gfx));
+void GraphicsWidget::setGfx(const Graphics::Surface *gfx, bool scale) {
+	setGfx(new Graphics::ManagedSurface(gfx), scale);
 }
 
 void GraphicsWidget::setGfx(int w, int h, int r, int g, int b) {
diff --git a/gui/widget.h b/gui/widget.h
index cdb7462301..ee92a972a0 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -421,8 +421,8 @@ public:
 	GraphicsWidget(GuiObject *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String());
 	~GraphicsWidget() override;
 
-	void setGfx(const Graphics::ManagedSurface *gfx);
-	void setGfx(const Graphics::Surface *gfx);
+	void setGfx(const Graphics::ManagedSurface *gfx, bool scale = false);
+	void setGfx(const Graphics::Surface *gfx, bool scale = false);
 	void setGfx(int w, int h, int r, int g, int b);
 	void setGfxFromTheme(const char *name);
 


Commit: 69ea52c2d0ba08d2de1eb6e76bfde2f59105e064
    https://github.com/scummvm/scummvm/commit/69ea52c2d0ba08d2de1eb6e76bfde2f59105e064
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-04-17T15:04:36+02:00

Commit Message:
GUI: Scale thumbnails in saveload dialog in HiDPI

Changed paths:
    gui/saveload-dialog.cpp


diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index fd3de19101..dc9e1a3a9f 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -386,6 +386,7 @@ SaveLoadChooserSimple::SaveLoadChooserSimple(const U32String &title, const U32St
 	_list->setEditable(saveMode);
 
 	_gfxWidget = new GraphicsWidget(this, 0, 0, 10, 10);
+	_gfxWidget->useThemeTransparency(false);
 
 	_date = new StaticTextWidget(this, 0, 0, 10, 10, _("No date saved"), Graphics::kTextAlignCenter);
 	_time = new StaticTextWidget(this, 0, 0, 10, 10, _("No time saved"), Graphics::kTextAlignCenter);
@@ -586,10 +587,8 @@ void SaveLoadChooserSimple::updateSelection(bool redraw) {
 
 		if (_thumbnailSupport) {
 			const Graphics::Surface *thumb = desc.getThumbnail();
-			if (thumb) {
-				_gfxWidget->setGfx(thumb);
-				_gfxWidget->useAlpha(256);
-			}
+			if (thumb)
+				_gfxWidget->setGfx(thumb, true);
 		}
 
 		if (_saveDateSupport) {
@@ -999,6 +998,7 @@ void SaveLoadChooserGrid::reflowLayout() {
 			}
 
 			PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, Common::U32String(), buttonCmd);
+			button->useThemeTransparency(false);
 			dstY += buttonHeight;
 
 			StaticTextWidget *description = new StaticTextWidget(container, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignStart);


Commit: b981e34cc8815def5978fb3c8ef70f1d083690ef
    https://github.com/scummvm/scummvm/commit/b981e34cc8815def5978fb3c8ef70f1d083690ef
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-04-17T15:04:36+02:00

Commit Message:
JANITORIAL: Remove trailing spaces

Changed paths:
    engines/bladerunner/bladerunner.cpp


diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 693d20b977..f259bb0d86 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -1279,9 +1279,9 @@ void BladeRunnerEngine::handleEvents() {
 	// This flag check is to skip the first call of handleEvents() in gameTick().
 	// This prevents a "hack" whereby the player could press Esc quickly and enter the KIA screen,
 	// even in the case when no save games for the game exist. In such case the game is supposed
-	// to immediately play the intro video and subsequently start a new game of medium difficulty. 
-	// It does not expect the player to enter KIA beforehand, which causes side-effects and unforeseen behavior. 
-	// Note: eventually we will support the option to launch into KIA in any case, 
+	// to immediately play the intro video and subsequently start a new game of medium difficulty.
+	// It does not expect the player to enter KIA beforehand, which causes side-effects and unforeseen behavior.
+	// Note: eventually we will support the option to launch into KIA in any case,
 	// but not via the "hack" way that is fixed here.
 	if (_gameJustLaunched) {
 		_gameJustLaunched = false;


Commit: 901f05fca33415652c7f2225d3a2a52c0cce6dcf
    https://github.com/scummvm/scummvm/commit/901f05fca33415652c7f2225d3a2a52c0cce6dcf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-04-17T15:04:36+02:00

Commit Message:
BLADERUNNER: Save full size thumbnails into saves. This bumps the save version to 4.

The original format compatibility quirks should stay working

Changed paths:
    engines/bladerunner/bladerunner.cpp
    engines/bladerunner/bladerunner.h
    engines/bladerunner/debugger.cpp
    engines/bladerunner/savefile.cpp
    engines/bladerunner/savefile.h
    engines/bladerunner/ui/kia.cpp
    engines/bladerunner/ui/kia_section_save.cpp


diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index f259bb0d86..e7cba880b7 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -91,7 +91,7 @@
 #include "engines/util.h"
 #include "engines/advancedDetector.h"
 
-#include "graphics/pixelformat.h"
+#include "graphics/thumbnail.h"
 #include "audio/mididrv.h"
 
 namespace BladeRunner {
@@ -277,7 +277,7 @@ Common::Error BladeRunnerEngine::loadGameState(int slot) {
 	// reseting and updating Blade Runner's _pauseStart and offset before starting a loaded game
 	_time->resetPauseStart();
 
-	loadGame(*saveFile);
+	loadGame(*saveFile, header._version);
 
 	delete saveFile;
 
@@ -302,21 +302,17 @@ Common::Error BladeRunnerEngine::saveGameState(int slot, const Common::String &d
 		return Common::kReadingFailed;
 	}
 
-	Graphics::Surface thumbnail = generateThumbnail();
-
 	BladeRunner::SaveFileHeader header;
 	header._name = desc;
 	header._playTime = getTotalPlayTime();
 
 	BladeRunner::SaveFileManager::writeHeader(*saveFile, header);
 	_time->pause();
-	saveGame(*saveFile, thumbnail);
+	saveGame(*saveFile);
 	_time->resume();
 
 	saveFile->finalize();
 
-	thumbnail.free();
-
 	delete saveFile;
 
 	return Common::kNoError;
@@ -2144,7 +2140,7 @@ void BladeRunnerEngine::playerDied() {
 	_kia->open(kKIASectionLoad);
 }
 
-bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, Graphics::Surface &thumbnail) {
+bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, Graphics::Surface *thumb, bool origformat) {
 	if ( !_gameIsAutoSaving
 	     && ( !playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript())
 	) {
@@ -2154,11 +2150,18 @@ bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, Graphics::Surface
 	Common::MemoryWriteStreamDynamic memoryStream(DisposeAfterUse::YES);
 	SaveFileWriteStream s(memoryStream);
 
-	thumbnail.convertToInPlace(gameDataPixelFormat());
+	if (!origformat) {
+		if (thumb)
+			Graphics::saveThumbnail(s, *thumb);
+		else
+			Graphics::saveThumbnail(s);
+	} else {
+		thumb->convertToInPlace(gameDataPixelFormat());
 
-	uint16* thumbnailData = (uint16*)thumbnail.getPixels();
-	for (uint i = 0; i < SaveFileManager::kThumbnailSize / 2; ++i) {
-		s.writeUint16LE(thumbnailData[i]);
+		uint16 *thumbnailData = (uint16*)thumb->getPixels();
+		for (uint i = 0; i < SaveFileManager::kThumbnailSize / 2; ++i) {
+			s.writeUint16LE(thumbnailData[i]);
+		}
 	}
 
 	s.writeFloat(1.0f);
@@ -2209,7 +2212,7 @@ bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, Graphics::Surface
 	return true;
 }
 
-bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream) {
+bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream, int version) {
 	if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) {
 		return false;
 	}
@@ -2244,7 +2247,11 @@ bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream) {
 	_gameIsLoading = true;
 	_settings->setLoadingGame();
 
-	s.skip(SaveFileManager::kThumbnailSize); // skip the thumbnail
+	if (version >= 4)
+		Graphics::skipThumbnail(s);
+	else
+		s.skip(SaveFileManager::kThumbnailSize); // skip the thumbnail
+
 	s.skip(4);// always float 1.0, but never used, assuming it's the game version
 	_settings->load(s);
 	_scene->load(s);
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 0e54eb04ab..2c1792fc19 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -332,8 +332,8 @@ public:
 	void playerGainsControl(bool force = false);
 	void playerDied();
 
-	bool saveGame(Common::WriteStream &stream, Graphics::Surface &thumbnail);
-	bool loadGame(Common::SeekableReadStream &stream);
+	bool saveGame(Common::WriteStream &stream, Graphics::Surface *thumb = NULL, bool origformat = false);
+	bool loadGame(Common::SeekableReadStream &stream, int version);
 	void newGame(int difficulty);
 	void autoSaveGame(int textId, bool endgame);
 
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index 7247e95da6..fb418799cc 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -1024,7 +1024,7 @@ bool Debugger::cmdLoad(int argc, const char **argv) {
 
 	Common::SeekableReadStream *saveFile = fs.createReadStream();
 
-	_vm->loadGame(*saveFile);
+	_vm->loadGame(*saveFile, 3);
 
 	delete saveFile;
 
@@ -1055,7 +1055,7 @@ bool Debugger::cmdSave(int argc, const char **argv) {
 	Graphics::Surface thumbnail = _vm->generateThumbnail();
 
 	_vm->_time->pause();
-	_vm->saveGame(*saveFile, thumbnail);
+	_vm->saveGame(*saveFile, &thumbnail, true);
 	_vm->_time->resume();
 
 	saveFile->finalize();
diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp
index c994d953ca..09e022cdfb 100644
--- a/engines/bladerunner/savefile.cpp
+++ b/engines/bladerunner/savefile.cpp
@@ -152,13 +152,18 @@ bool SaveFileManager::readHeader(Common::SeekableReadStream &in, SaveFileHeader
 
 		s.skip(4); //skip size;
 
-		uint16 *thumbnailData = (uint16*)malloc(kThumbnailSize); // freed by ScummVM's smartptr
-		for (uint i = 0; i < kThumbnailSize / 2; ++i) {
-			thumbnailData[i] = s.readUint16LE();
+		if (header._version >= 4) {
+			Graphics::loadThumbnail(s, header._thumbnail);
+		} else {
+			uint16 alphamask = (0xFF >> gameDataPixelFormat().aLoss) << gameDataPixelFormat().aShift;
+			uint16 *thumbnailData = (uint16*)malloc(kThumbnailSize); // freed by ScummVM's smartptr
+			for (uint i = 0; i < kThumbnailSize / 2; ++i) {
+				thumbnailData[i] = s.readUint16LE() | alphamask; // We set all pixels to non-transparency
+			}
+
+			header._thumbnail->init(80, 60, 160, thumbnailData, gameDataPixelFormat());
 		}
 
-		header._thumbnail->init(80, 60, 160, thumbnailData, gameDataPixelFormat());
-
 		s.seek(pos);
 	}
 
diff --git a/engines/bladerunner/savefile.h b/engines/bladerunner/savefile.h
index 55ede8324c..58ece256ec 100644
--- a/engines/bladerunner/savefile.h
+++ b/engines/bladerunner/savefile.h
@@ -60,7 +60,9 @@ struct SaveFileHeader {
 class SaveFileManager {
 private:
 	static const uint32 kTag = MKTAG('B', 'R', 'S', 'V');
-	static const uint32 kVersion = 3; // kVersion: 3 as of Feb 5th 2020 (UTC) - ScummVM development version 2.2.0git
+	// kVersion: 3 as of Feb 5th 2020 (UTC) - ScummVM development version 2.2.0git
+	// kVersion: 4 as of Apr 17th 2021 - Added full-size thumbnails
+	static const uint32 kVersion = 4;
 
 public:
 	// kVersion
diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp
index 95258cb325..fe2d3a61d0 100644
--- a/engines/bladerunner/ui/kia.cpp
+++ b/engines/bladerunner/ui/kia.cpp
@@ -58,6 +58,8 @@
 #include "common/keyboard.h"
 #include "common/debug.h"
 
+#include "graphics/scaler.h"
+
 namespace BladeRunner {
 
 const char *KIA::kPogo = "POGO";
@@ -586,7 +588,14 @@ void KIA::playPhotograph(int photographId) {
 }
 
 void KIA::playImage(const Graphics::Surface &image) {
-	_playerImage.copyFrom(image);
+	if (image.w != 80) {
+		Graphics::Surface *tmp = image.scale(80, 60);
+		_playerImage.copyFrom(*tmp);
+		tmp->free();
+		delete tmp;
+	} else {
+		_playerImage.copyFrom(image);
+	}
 	_playerImage.convertToInPlace(screenPixelFormat());
 }
 
@@ -719,7 +728,7 @@ void KIA::loopEnded(void *callbackData, int frame, int loopId) {
 }
 
 void KIA::init() {
-	_thumbnail = _vm->generateThumbnail();
+	createThumbnailFromScreen(&_thumbnail);
 
 	if (!_vm->openArchive("MODE.MIX")) {
 		return;
diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp
index c632091941..c044f7e72e 100644
--- a/engines/bladerunner/ui/kia_section_save.cpp
+++ b/engines/bladerunner/ui/kia_section_save.cpp
@@ -410,7 +410,7 @@ void KIASectionSave::save() {
 
 	BladeRunner::SaveFileManager::writeHeader(*saveFile, header);
 
-	_vm->saveGame(*saveFile, _vm->_kia->_thumbnail);
+	_vm->saveGame(*saveFile, &_vm->_kia->_thumbnail);
 
 	saveFile->finalize();
 




More information about the Scummvm-git-logs mailing list