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
This commit is contained in:
Filippos Karapetis 2020-02-09 23:23:30 +02:00
parent 13e5042dee
commit ff044aa431
9 changed files with 47 additions and 56 deletions

View File

@ -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) {

View File

@ -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];

View File

@ -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) {

View File

@ -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()) {

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;