[Scummvm-git-logs] scummvm master -> ff044aa4314c4543ff4a11cdf10beccb93332755

bluegr bluegr at gmail.com
Sun Feb 9 21:27:34 UTC 2020


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:
ff044aa431 SCI: Move the GK2 subtitle patch dialog inside the SciEngine class


Commit: ff044aa4314c4543ff4a11cdf10beccb93332755
    https://github.com/scummvm/scummvm/commit/ff044aa4314c4543ff4a11cdf10beccb93332755
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-02-09T23:27:11+02:00

Commit Message:
SCI: Move the GK2 subtitle patch dialog inside the SciEngine class

This is now grouped together with the other GUI messages. The script
patcher class itself does not need to handle such logic

Changed paths:
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kgraphics32.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/script_patches.h
    engines/sci/resource.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h


diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index 5562e2c..91be30f 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -70,9 +70,10 @@ static int16 adjustGraphColor(int16 color) {
 		return color;
 }
 
-void showScummVMDialog(const Common::String &message) {
-	GUI::MessageDialog dialog(message, _("OK"));
-	dialog.runModal();
+int showScummVMDialog(const Common::String &message, const char *altButton = nullptr, bool alignCenter = true) {
+	Graphics::TextAlign alignment = alignCenter ? Graphics::kTextAlignCenter : Graphics::kTextAlignLeft;
+	GUI::MessageDialog dialog(message, _("OK"), altButton, alignment);
+	return dialog.runModal();
 }
 
 void kDirLoopWorker(reg_t object, uint16 angle, EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 6c60cff..690da17 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -62,7 +62,7 @@
 namespace Sci {
 #ifdef ENABLE_SCI32
 
-extern void showScummVMDialog(const Common::String &message);
+extern int showScummVMDialog(const Common::String& message, const char* altButton = nullptr, bool alignCenter = true);
 
 reg_t kBaseSetter32(EngineState *s, int argc, reg_t *argv) {
 	reg_t object = argv[0];
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index df600df..ddd82c1 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -680,7 +680,7 @@ reg_t kPlatform(EngineState *s, int argc, reg_t *argv) {
 	return NULL_REG;
 }
 
-extern void showScummVMDialog(const Common::String &message);
+extern int showScummVMDialog(const Common::String& message, const char* altButton = nullptr, bool alignCenter = true);
 
 #ifdef ENABLE_SCI32
 reg_t kPlatform32(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 5f209ce..ed0d03e 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -1196,7 +1196,7 @@ bool gamestate_save(EngineState *s, Common::WriteStream *fh, const Common::Strin
 	return true;
 }
 
-extern void showScummVMDialog(const Common::String &message);
+extern int showScummVMDialog(const Common::String& message, const char* altButton = nullptr, bool alignCenter = true);
 
 void gamestate_afterRestoreFixUp(EngineState *s, int savegameId) {
 	switch (g_sci->getGameId()) {
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index d53627b..b6f8045 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -30,12 +30,7 @@
 #include "sci/engine/guest_additions.h"
 #endif
 
-#include "common/config-manager.h"
 #include "common/util.h"
-#include "common/translation.h"
-#include "common/system.h"
-#include "gui/message.h"
-
 
 namespace Sci {
 
@@ -18465,42 +18460,6 @@ void ScriptPatcher::applyPatch(const SciScriptPatcherEntry *patchEntry, SciSpan<
 	}
 }
 
-
-// TODO: suggest automatic installation
-void ScriptPatcher::suggestDownloadGK2SubTitlesPatch() {
-	if (ConfMan.getBool("subtitles")) {
-
-		const char *altButton;
-		Common::String downloadMessage;
-
-		if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
-			altButton = _("Download patch");
-			downloadMessage = _("(or click 'Download patch' button. But note - it only downloads, you will have to continue from there)\n");
-		} else {
-			altButton = nullptr;
-			downloadMessage = "";
-		}
-
-		GUI::MessageDialog dialog(_("GK2 has a fan made subtitles, available thanks to the good persons at SierraHelp.\n\n"
-			"Installation:\n"
-			"- download http://www.sierrahelp.com/Files/Patches/GabrielKnight/GK2Subtitles.zip\n" +
-			downloadMessage +
-			"- extract zip file\n"
-			"- no need to run the .exe file\n"
-			"- extract the .exe file with a file archiver, like 7-zip\n"
-			"- create a PATCHES subdirectory inside your GK2 directory\n"
-			"- copy the content of GK2Subtitles\\SUBPATCH to the PATCHES subdirectory\n"
-			"- replace files with similar names\n"
-			"- restart the game\n"), _("OK"), altButton, Graphics::kTextAlignLeft);
-		int result = dialog.runModal();
-		if (!result) {
-			char url[] = "http://www.sierrahelp.com/Files/Patches/GabrielKnight/GK2Subtitles.zip";
-			g_system->openUrl(url);
-		}
-
-	}
-}
-
 bool ScriptPatcher::verifySignature(uint32 byteOffset, const uint16 *signatureData, const char *signatureDescription, const SciSpan<const byte> &scriptData) {
 	uint16 sigSelector = 0;
 
@@ -18988,8 +18947,6 @@ void ScriptPatcher::processScript(uint16 scriptNr, SciSpan<byte> scriptData) {
 				// Enable subtitle compatibility if a sync resource is present
 				if (g_sci->getResMan()->testResource(ResourceId(kResourceTypeSync, 10))) {
 					enablePatch(signatureTable, "subtitle patch compatibility");
-				} else {
-					suggestDownloadGK2SubTitlesPatch();
 				}
 				break;
 			case GID_KQ5:
diff --git a/engines/sci/engine/script_patches.h b/engines/sci/engine/script_patches.h
index 32e47b5..69f9794 100644
--- a/engines/sci/engine/script_patches.h
+++ b/engines/sci/engine/script_patches.h
@@ -120,10 +120,6 @@ private:
 	// Applies a patch to a given script + offset (overwrites parts)
 	void applyPatch(const SciScriptPatcherEntry *patchEntry, SciSpan<byte> scriptData, int32 signatureOffset);
 
-	// suggest to download GK2 subtitles patch
-	// in the future, we might refactor it to something more generic, if will needed
-	void suggestDownloadGK2SubTitlesPatch();
-
 	Selector *_selectorIdTable;
 	SciScriptPatcherRuntimeEntry *_runtimeTable;
 	bool _isMacSci11;
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 5635efb..d3f3d98 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -809,7 +809,7 @@ void ResourceManager::addScriptChunkSources() {
 #endif
 }
 
-extern void showScummVMDialog(const Common::String &message);
+extern int showScummVMDialog(const Common::String& message, const char* altButton = nullptr, bool alignCenter = true);
 
 void ResourceManager::scanNewSources() {
 	_hasBadResources = false;
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 2e5b967..eac8022 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -255,7 +255,7 @@ SciEngine::~SciEngine() {
 	g_sci = 0;
 }
 
-extern void showScummVMDialog(const Common::String &message);
+extern int showScummVMDialog(const Common::String& message, const char* altButton = nullptr, bool alignCenter = true);
 
 Common::Error SciEngine::run() {
 	_resMan = new ResourceManager();
@@ -433,6 +433,10 @@ Common::Error SciEngine::run() {
 		                  "having unexpected errors and/or issues later on."));
 	}
 
+	if (getGameId() == GID_GK2 && ConfMan.getBool("subtitles") && !_resMan->testResource(ResourceId(kResourceTypeSync, 10))) {
+		suggestDownloadGK2SubTitlesPatch();
+	}
+
 	runGame();
 
 	ConfMan.flushToDisk();
@@ -503,6 +507,36 @@ bool SciEngine::gameHasFanMadePatch() {
 	return false;
 }
 
+void SciEngine::suggestDownloadGK2SubTitlesPatch() {
+	const char* altButton;
+	Common::String downloadMessage;
+
+	if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
+		altButton = _("Download patch");
+		downloadMessage = _("(or click 'Download patch' button. But note - it only downloads, you will have to continue from there)\n");
+	}
+	else {
+		altButton = nullptr;
+		downloadMessage = "";
+	}
+
+	int result = showScummVMDialog(_("GK2 has a fan made subtitles, available thanks to the good persons at SierraHelp.\n\n"
+		"Installation:\n"
+		"- download http://www.sierrahelp.com/Files/Patches/GabrielKnight/GK2Subtitles.zip\n" +
+		downloadMessage +
+		"- extract zip file\n"
+		"- no need to run the .exe file\n"
+		"- extract the .exe file with a file archiver, like 7-zip\n"
+		"- create a PATCHES subdirectory inside your GK2 directory\n"
+		"- copy the content of GK2Subtitles\\SUBPATCH to the PATCHES subdirectory\n"
+		"- replace files with similar names\n"
+		"- restart the game\n"), altButton, false);
+	if (!result) {
+		char url[] = "http://www.sierrahelp.com/Files/Patches/GabrielKnight/GK2Subtitles.zip";
+		g_system->openUrl(url);
+	}
+}
+
 bool SciEngine::initGame() {
 	// Script 0 needs to be allocated here before anything else!
 	int script0Segment = _gamestate->_segMan->getScriptSegment(0, SCRIPT_GET_LOCK);
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 1689ad3..f44338f 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -270,7 +270,6 @@ public:
 
 	const SciGameId &getGameId() const { return _gameId; }
 	const char *getGameIdStr() const;
-	int getResourceVersion() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	bool isDemo() const;
@@ -351,6 +350,10 @@ public:
 	// Initializes ports and paint16 for non-sci32 games, also sets default palette
 	void initGraphics();
 
+	// Suggest to download the GK2 subtitles patch
+	// in the future, we might refactor it to something more generic, if needed
+	void suggestDownloadGK2SubTitlesPatch();
+
 public:
 	GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
 	GfxCache *_gfxCache;




More information about the Scummvm-git-logs mailing list