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

neuromancer noreply at scummvm.org
Fri Oct 30 13:37:31 UTC 2026


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

Summary:
acfe76c21c HOLLYWOOD: allow to switch game language during gameplay


Commit: acfe76c21cba5ea3b8a7d72ec7b380c18497c916
    https://github.com/scummvm/scummvm/commit/acfe76c21cba5ea3b8a7d72ec7b380c18497c916
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2026-10-30T14:37:17+01:00

Commit Message:
HOLLYWOOD: allow to switch game language during gameplay

Changed paths:
    devtools/README
    devtools/create_hollywood/module.mk
    devtools/extract_hollywood_translation.py
    dists/engine-data/README
    dists/engine-data/hollywood.dat
    engines/hollywood/image_translation.h
    engines/hollywood/monsters/detection.cpp
    engines/hollywood/monsters/detection.h
    engines/hollywood/monsters/detection_tables.h
    engines/hollywood/monsters/game_strings.cpp
    engines/hollywood/monsters/game_strings.h
    engines/hollywood/monsters/gameplay/game_loop.cpp
    engines/hollywood/monsters/gameplay/game_loop.h
    engines/hollywood/monsters/gameplay/options_menu.cpp
    engines/hollywood/monsters/gameplay/options_menu.h
    engines/hollywood/monsters/hollywood.cpp
    engines/hollywood/monsters/hollywood.h
    engines/hollywood/monsters/metaengine.cpp
    engines/hollywood/monsters/po/en.po
    engines/hollywood/monsters/scenes/playable/playable_scene.cpp
    engines/hollywood/monsters/scenes/playable/playable_scene.h
    engines/hollywood/monsters/scenes/playable/scene4030.cpp
    engines/hollywood/monsters/scenes/playable/scene4030.h
    engines/hollywood/text_translation.cpp
    engines/hollywood/text_translation.h


diff --git a/devtools/README b/devtools/README
index 148e2822766..42204ab0147 100644
--- a/devtools/README
+++ b/devtools/README
@@ -183,7 +183,7 @@ extract_hollywood_translation.py
     Nikos Daskos (ShinjiGR) into editable PO text and image overlays.
 
     Rebuild dists/engine-data/hollywood.dat (ZIP) from
-    engines/hollywood/monsters/po/en.po and the extracted image assets:
+    engines/hollywood/monsters/po/*.po and the extracted image assets:
 
       make hollywood.dat
 
diff --git a/devtools/create_hollywood/module.mk b/devtools/create_hollywood/module.mk
index 1dfe5e1752c..1d6e9b7c6c4 100644
--- a/devtools/create_hollywood/module.mk
+++ b/devtools/create_hollywood/module.mk
@@ -2,7 +2,7 @@ hollywood.dat: devtools/create_translations
 	python3 $(srcdir)/devtools/extract_hollywood_translation.py pack \
 		$(srcdir)/devtools/create_hollywood/files \
 		$(srcdir)/dists/engine-data/hollywood.dat \
-		--po $(srcdir)/engines/hollywood/monsters/po/en.po \
+		--po $(wildcard $(srcdir)/engines/hollywood/monsters/po/*.po) \
 		--compiler devtools/create_translations/create_translations$(EXEEXT)
 
 .PHONY: hollywood.dat
diff --git a/devtools/extract_hollywood_translation.py b/devtools/extract_hollywood_translation.py
index 9b7485198a2..f0405882117 100644
--- a/devtools/extract_hollywood_translation.py
+++ b/devtools/extract_hollywood_translation.py
@@ -379,9 +379,18 @@ def pack_translation(source, output, compiler, po=None):
                 files[name] = (source / name).read_bytes()
 
     with tempfile.TemporaryDirectory() as directory:
-        catalog = Path(directory) / "monsters.en.dat"
-        subprocess.run([str(compiler.resolve()), str(catalog), str(po or source / "en.po")], check=True)
-        files["monsters.en.dat"] = catalog.read_bytes()
+        directory = Path(directory)
+        catalogs = []
+        # Avoid TranslationManager's development override from ScummVM's GUI po/ directory.
+        for path in sorted(po or source.glob("*.po")):
+            catalog_source = directory / f"monsters-{path.stem}.po"
+            catalog_source.write_bytes(path.read_bytes())
+            catalogs.append(str(catalog_source))
+        if not catalogs:
+            raise ValueError("No PO catalogs found")
+        catalog = directory / "monsters.dat"
+        subprocess.run([str(compiler.resolve()), str(catalog), *catalogs], check=True)
+        files["monsters.dat"] = catalog.read_bytes()
     with zipfile.ZipFile(output, "w") as destination:
         for name, data in sorted(files.items()):
             destination.writestr(zipfile.ZipInfo(name), data, compress_type=zipfile.ZIP_DEFLATED, compresslevel=9)
@@ -398,7 +407,7 @@ def main():
     pack = commands.add_parser("pack", help="Compile PO text and rebuild hollywood.dat as a ZIP archive")
     pack.add_argument("source", type=Path, help="Directory produced by extract")
     pack.add_argument("output", type=Path, help="Output hollywood.dat (replaced if it exists)")
-    pack.add_argument("--po", type=Path, help="PO file to compile instead of SOURCE/en.po")
+    pack.add_argument("--po", type=Path, nargs="+", help="PO files to compile instead of SOURCE/*.po")
     pack.add_argument("--compiler", type=Path,
                       default=Path(__file__).resolve().parent / "create_translations/create_translations")
     args = parser.parse_args()
diff --git a/dists/engine-data/README b/dists/engine-data/README
index 38c3a41e44e..ea4cca5a6e0 100644
--- a/dists/engine-data/README
+++ b/dists/engine-data/README
@@ -72,8 +72,11 @@ This file contains images for Help Dialog.
 hollywood.dat:
 This ZIP archive contains the Hollywood Monsters English fan translation and
 translated image overlays by Nikos Daskos (ShinjiGR), used with permission.
-The text catalog is compiled from engines/hollywood/monsters/po/en.po.
+The text catalog is compiled from engines/hollywood/monsters/po/*.po.
 Retain this attribution in derivative works. Rebuild it with 'make hollywood.dat'.
+Select the text language in ScummVM's Edit Game dialog before starting the game,
+or switch it using the language button in the game's options menu. Speech stays
+in the original language; translated images change when their resources reload.
 
 hugo.dat:
 This file contains all the hardcoded logic, strings and fonts used by Hugo
diff --git a/dists/engine-data/hollywood.dat b/dists/engine-data/hollywood.dat
index 08e99f894c0..24d48847834 100644
Binary files a/dists/engine-data/hollywood.dat and b/dists/engine-data/hollywood.dat differ
diff --git a/engines/hollywood/image_translation.h b/engines/hollywood/image_translation.h
index da0165e8c16..835a516c794 100644
--- a/engines/hollywood/image_translation.h
+++ b/engines/hollywood/image_translation.h
@@ -64,7 +64,7 @@ private:
 	bool applyImage(const Overlay &overlay, Common::SeekableReadStream &file,
 		const ResourceChunkTable &table, Common::Array<byte> &data) const;
 
-	Common::ScopedPtr<Common::Archive> _archive;
+	Common::Archive *_archive; // Owned by TextTranslation.
 	Common::StringMap _sources;
 	Common::Array<Overlay> _overlays;
 };
diff --git a/engines/hollywood/monsters/detection.cpp b/engines/hollywood/monsters/detection.cpp
index acd3f4e1eea..47b13278f7c 100644
--- a/engines/hollywood/monsters/detection.cpp
+++ b/engines/hollywood/monsters/detection.cpp
@@ -34,7 +34,7 @@ const ADGameDescription fallbackWindowsDescription = {
 	Common::UNK_LANG,
 	Common::kPlatformWindows,
 	ADGF_UNSTABLE,
-	GUIO3(GAMEOPTION_RESTORED_CONTENT, GAMEOPTION_ALTERNATIVE_SUBTITLES, GUIO_NOMIDI)
+	GUIO2(GAMEOPTION_RESTORED_CONTENT, GUIO_NOMIDI)
 };
 
 const ADGameDescription fallbackDosDescription = {
@@ -44,7 +44,7 @@ const ADGameDescription fallbackDosDescription = {
 	Common::UNK_LANG,
 	Common::kPlatformDOS,
 	ADGF_UNSTABLE,
-	GUIO3(GAMEOPTION_RESTORED_CONTENT, GAMEOPTION_ALTERNATIVE_SUBTITLES, GUIO_NOMIDI)
+	GUIO2(GAMEOPTION_RESTORED_CONTENT, GUIO_NOMIDI)
 };
 
 
diff --git a/engines/hollywood/monsters/detection.h b/engines/hollywood/monsters/detection.h
index 6b1823ce0c6..4401268e9c8 100644
--- a/engines/hollywood/monsters/detection.h
+++ b/engines/hollywood/monsters/detection.h
@@ -25,14 +25,15 @@
 #include "engines/advancedDetector.h"
 
 #define GAMEOPTION_RESTORED_CONTENT GUIO_GAMEOPTIONS1
+
+namespace Hollywood {
+
 #ifdef USE_TRANSLATION
-#define GAMEOPTION_ALTERNATIVE_SUBTITLES GUIO_GAMEOPTIONS2
+const uint32 kMonstersTranslationFlags = ADGF_ADDENGLISH;
 #else
-#define GAMEOPTION_ALTERNATIVE_SUBTITLES ""
+const uint32 kMonstersTranslationFlags = 0;
 #endif
 
-namespace Hollywood {
-
 extern const ADFileBasedFallback monstersFileBasedFallback[];
 const ADGameDescription *detectMonstersVariant(const AdvancedMetaEngineBase::FileMap &allFiles);
 
diff --git a/engines/hollywood/monsters/detection_tables.h b/engines/hollywood/monsters/detection_tables.h
index eeab22c8a90..b601ca3e37f 100644
--- a/engines/hollywood/monsters/detection_tables.h
+++ b/engines/hollywood/monsters/detection_tables.h
@@ -61,8 +61,8 @@
 			"RESOURCE.004", "a79d937879665b899c255957c7310d42", 265002432),
 		Common::ES_ESP,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
-		GUIO3(GAMEOPTION_RESTORED_CONTENT, GAMEOPTION_ALTERNATIVE_SUBTITLES, GUIO_NOMIDI)
+		ADGF_UNSTABLE | kMonstersTranslationFlags,
+		GUIO2(GAMEOPTION_RESTORED_CONTENT, GUIO_NOMIDI)
 	},
 
 	// Italian Windows full game, installed Monsters directory.
@@ -88,8 +88,8 @@
 			"RESOURCE.003", "352126965c51832ce970faece65cc2f8", 9444153),
 		Common::ES_ESP,
 		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
-		GUIO3(GAMEOPTION_RESTORED_CONTENT, GAMEOPTION_ALTERNATIVE_SUBTITLES, GUIO_NOMIDI)
+		ADGF_UNSTABLE | kMonstersTranslationFlags,
+		GUIO2(GAMEOPTION_RESTORED_CONTENT, GUIO_NOMIDI)
 	},
 
 	// English fan translation v1.0.0 by ShinjiGR, patched by A.P.$lasH for the Spanish Windows release.
@@ -116,8 +116,8 @@
 			"RESOURCE.003", "352126965c51832ce970faece65cc2f8", 9444153),
 		Common::ES_ESP,
 		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
-		GUIO3(GAMEOPTION_RESTORED_CONTENT, GAMEOPTION_ALTERNATIVE_SUBTITLES, GUIO_NOMIDI)
+		ADGF_UNSTABLE | kMonstersTranslationFlags,
+		GUIO2(GAMEOPTION_RESTORED_CONTENT, GUIO_NOMIDI)
 	},
 
 #endif // HOLLYWOOD_MONSTERS_DETECTION_TABLES_H
diff --git a/engines/hollywood/monsters/game_strings.cpp b/engines/hollywood/monsters/game_strings.cpp
index 11a046dee52..e050cdbb69a 100644
--- a/engines/hollywood/monsters/game_strings.cpp
+++ b/engines/hollywood/monsters/game_strings.cpp
@@ -53,6 +53,7 @@ const HollywoodGameStrings kSpanishGameStrings = {
 	"\xa8" "Est\xa0s seguro?",
 	"S",
 	"N",
+	"Cambiar idioma",
 
 	" pasadizo",
 	" ata\xa3" "d ancho",
@@ -91,6 +92,7 @@ const HollywoodGameStrings kItalianGameStrings = {
 	"Sei sicuro?",
 	"S",
 	"N",
+	"Cambia lingua",
 
 	" passaggio",
 	" cassa da morto larga", // WORKAROUND: The Italian executable leaves this variant in Spanish.
@@ -129,6 +131,7 @@ const HollywoodGameStrings kEnglishGameStrings = {
 	"Are you sure?",
 	"Y",
 	"N",
+	"Change language",
 
 	" passage",
 	" wide coffin",
@@ -172,6 +175,7 @@ void HollywoodGameStrings::applyTranslation(const TextTranslation &translation)
 		{ "optionsQuitPrompt", &optionsQuitPrompt },
 		{ "optionsQuitYes", &optionsQuitYes },
 		{ "optionsQuitNo", &optionsQuitNo },
+		{ "optionsChangeLanguage", &optionsChangeLanguage },
 		{ "passageName", &passageName },
 		{ "wideCoffinName", &wideCoffinName },
 		{ "recordsName", &recordsName },
@@ -181,10 +185,12 @@ void HollywoodGameStrings::applyTranslation(const TextTranslation &translation)
 	};
 	for (uint i = 0; i < ARRAYSIZE(fields); ++i)
 		*fields[i].value = translation.interfaceText(fields[i].key, *fields[i].value);
+	for (uint i = 0; i < ARRAYSIZE(mineDestinationLabels); ++i)
+		mineDestinationLabels[i] = translation.interfaceText(Common::String::format("mineDestination%u", i), mineDestinationLabels[i]);
 }
 
-const HollywoodGameStrings &getGameStrings(Common::Language language) {
-	if (ConfMan.hasKey("language")) {
+const HollywoodGameStrings &getGameStrings(Common::Language language, bool useConfiguredLanguage) {
+	if (useConfiguredLanguage && ConfMan.hasKey("language")) {
 		const Common::Language selectedLanguage = Common::parseLanguage(ConfMan.get("language"));
 		if (selectedLanguage == Common::EN_ANY || selectedLanguage == Common::EN_GRB ||
 				selectedLanguage == Common::EN_USA)
diff --git a/engines/hollywood/monsters/game_strings.h b/engines/hollywood/monsters/game_strings.h
index ec392d311ca..c951591deb7 100644
--- a/engines/hollywood/monsters/game_strings.h
+++ b/engines/hollywood/monsters/game_strings.h
@@ -35,9 +35,7 @@ enum {
 /**
  * In-game text not supplied by RESOURCE.003, including localized executable strings.
  *
- * These strings follow the detected game language unless English is explicitly
- * selected for a fan translation. The external catalog is independent of the
- * launcher language.
+ * These strings follow the detected game language or the selected external catalog.
  */
 struct HollywoodGameStrings {
 	const char *actionCaptions[kGameActionCaptionCount];
@@ -67,6 +65,7 @@ struct HollywoodGameStrings {
 	const char *optionsQuitPrompt;
 	const char *optionsQuitYes;
 	const char *optionsQuitNo;
+	const char *optionsChangeLanguage;
 
 	const char *passageName;
 	const char *wideCoffinName;
@@ -79,7 +78,7 @@ struct HollywoodGameStrings {
 	void applyTranslation(const TextTranslation &translation);
 };
 
-const HollywoodGameStrings &getGameStrings(Common::Language language);
+const HollywoodGameStrings &getGameStrings(Common::Language language, bool useConfiguredLanguage = true);
 
 } // End of namespace Hollywood
 
diff --git a/engines/hollywood/monsters/gameplay/game_loop.cpp b/engines/hollywood/monsters/gameplay/game_loop.cpp
index 8cc49beeb0f..c0c9e204b9b 100644
--- a/engines/hollywood/monsters/gameplay/game_loop.cpp
+++ b/engines/hollywood/monsters/gameplay/game_loop.cpp
@@ -104,6 +104,9 @@ bool GameplayLoopDelegate::optionsMenuSpeechPreviewSampleId(uint16 &sampleId) co
 void GameplayLoopDelegate::suspendAudioForOptionsMenu() {
 }
 
+void GameplayLoopDelegate::refreshTranslatedText() {
+}
+
 bool GameplayLoopDelegate::shouldExitGameplayLoop() const {
 	return false;
 }
@@ -557,6 +560,7 @@ void GameplayLoop::closeInventoryPanel() {
 }
 
 void GameplayLoop::openOptionsMenu() {
+	const Common::String previousLanguage = _vm->textTranslation()->language();
 	const bool restoreInventoryPanel = _panelState.inventoryPanelVisible;
 	const bool restoreVerbPanel = _panelState.verbPanelVisible && !restoreInventoryPanel;
 
@@ -582,6 +586,8 @@ void GameplayLoop::openOptionsMenu() {
 		return;
 	if (_vm->isSceneRestartRequested())
 		return;
+	if (previousLanguage != _vm->textTranslation()->language())
+		_delegate->refreshTranslatedText();
 	_delegate->invalidatePresentationPalette();
 
 	_leftButtonDown = false;
@@ -597,6 +603,7 @@ void GameplayLoop::openOptionsMenu() {
 	} else if (restoreVerbPanel) {
 		_panelState.verbPanelVisible = true;
 		_panelState.inventoryPanelVisible = false;
+		_panelState.itemName = _delegate->hotspots().itemName(_panelState.resolvedItem);
 		updatePanelCaption();
 	} else {
 		_panelState.verbPanelVisible = false;
diff --git a/engines/hollywood/monsters/gameplay/game_loop.h b/engines/hollywood/monsters/gameplay/game_loop.h
index 7638d729c19..8785a38476d 100644
--- a/engines/hollywood/monsters/gameplay/game_loop.h
+++ b/engines/hollywood/monsters/gameplay/game_loop.h
@@ -97,6 +97,7 @@ public:
 	virtual Common::Path optionsMenuSoundBank0ArchiveName() const;
 	virtual bool optionsMenuSpeechPreviewSampleId(uint16 &sampleId) const;
 	virtual void suspendAudioForOptionsMenu();
+	virtual void refreshTranslatedText();
 	virtual bool shouldExitGameplayLoop() const;
 	virtual bool isInventoryPanelAvailable() const;
 	virtual Common::String inventoryItemName(byte owner, byte itemId) const;
diff --git a/engines/hollywood/monsters/gameplay/options_menu.cpp b/engines/hollywood/monsters/gameplay/options_menu.cpp
index a3dd4c2781d..88601e90247 100644
--- a/engines/hollywood/monsters/gameplay/options_menu.cpp
+++ b/engines/hollywood/monsters/gameplay/options_menu.cpp
@@ -95,6 +95,10 @@ const int kOptionsToggleSquareX[2] = { 0x13a, 0x236 };
 const int kOptionsToggleSquareY[4] = { 0x75, 0xc8, 0x11b, 0x16e };
 const int kOptionsToggleSquareSize = 0x10;
 const uint kOptionsMaximumLevel = 200;
+const int kOptionsLanguageButtonLeft = 0x1d2;
+const int kOptionsLanguageButtonRight = 0x22d;
+const int kOptionsLanguageButtonTop = 0x13a;
+const int kOptionsLanguageButtonBottom = 0x155;
 
 GameplayOptionsMenu::GameplayOptionsMenu(HollywoodEngine *vm) :
 		_vm(vm),
@@ -438,6 +442,9 @@ void GameplayOptionsMenu::handleLeftClick(uint16 cursorX, uint16 cursorY, bool &
 		syncSettings = true;
 		refreshTestAudio = true;
 		break;
+	case kHitLanguage:
+		_vm->cycleSubtitleLanguage();
+		break;
 	case kHitConfirmQuit:
 		disableTestAudio();
 		Engine::quitGame();
@@ -475,6 +482,10 @@ GameplayOptionsMenu::HitAction GameplayOptionsMenu::hitActionAt(uint16 cursorX,
 		return kHitQuit;
 	if (pointInGlobalRect(cursorX, cursorY, 0x200, 0x0f1, 0x25c, 0x10c))
 		return kHitPlay;
+	if (!_vm->textTranslation()->languages().empty() &&
+			pointInGlobalRect(cursorX, cursorY, kOptionsLanguageButtonLeft, kOptionsLanguageButtonTop,
+				kOptionsLanguageButtonRight, kOptionsLanguageButtonBottom))
+		return kHitLanguage;
 
 	if (pointInGlobalRect(cursorX, cursorY, 0x28b, 0x020, 0x312, 0x033))
 		return kHitMusicToggle;
@@ -814,6 +825,16 @@ void GameplayOptionsMenu::drawControls(Graphics::Surface &surface) {
 	drawText(surface, strings.optionsLoad, 0x22e, 0xd7, kOptionsTextActiveColor, true);
 	drawText(surface, strings.optionsQuit, 0x1d1, 0xf4, kOptionsTextActiveColor, true);
 	drawText(surface, strings.optionsPlay, 0x22e, 0xf4, kOptionsTextActiveColor, true);
+	if (!_vm->textTranslation()->languages().empty()) {
+		_screen.copyRectToSurface(_menuFramebuffer.surface(), kOptionsLanguageButtonLeft - kOptionsViewportXOffset,
+			kOptionsLanguageButtonTop, Common::Rect(kOptionsQuitMainButtonLeft, kOptionsQuitMainButtonTop,
+				kOptionsQuitMainButtonRight, kOptionsQuitMainButtonBottom));
+		const int center = (kOptionsLanguageButtonLeft + kOptionsLanguageButtonRight) / 2;
+		drawText(surface, strings.optionsChangeLanguage, center, kOptionsLanguageButtonTop - 28,
+			kOptionsTextActiveColor, true);
+		drawText(surface, _vm->nextSubtitleLanguageName(), center, kOptionsLanguageButtonTop + 3,
+			kOptionsTextActiveColor, true);
+	}
 
 	drawText(surface, state.musicEnabled ? strings.optionsMusicOn : strings.optionsMusicOff, 0x2a3, 0x20,
 		state.musicEnabled ? kOptionsTextActiveColor : kOptionsTextDisabledColor, false);
diff --git a/engines/hollywood/monsters/gameplay/options_menu.h b/engines/hollywood/monsters/gameplay/options_menu.h
index ff3c31c6ecd..4032b9f6635 100644
--- a/engines/hollywood/monsters/gameplay/options_menu.h
+++ b/engines/hollywood/monsters/gameplay/options_menu.h
@@ -68,6 +68,7 @@ private:
 		kHitSpeechText,
 		kHitSpeechVoice,
 		kHitSpeechBoth,
+		kHitLanguage,
 		kHitConfirmQuit,
 		kHitCancelQuit
 	};
diff --git a/engines/hollywood/monsters/hollywood.cpp b/engines/hollywood/monsters/hollywood.cpp
index 4a55e9654c8..0d5da86c200 100644
--- a/engines/hollywood/monsters/hollywood.cpp
+++ b/engines/hollywood/monsters/hollywood.cpp
@@ -23,6 +23,7 @@
 #include "common/archive.h"
 #include "common/config-manager.h"
 #include "common/debug.h"
+#include "common/file.h"
 #include "common/random.h"
 #include "engines/advancedDetector.h"
 #include "engines/util.h"
@@ -216,11 +217,19 @@ bool HollywoodEngine::consumeDebugSceneSolveRequest(uint16 sceneNumber) {
 Common::Error HollywoodEngine::run() {
 	setDebugger(new Console(this));
 
-	if (!isDemo() && ConfMan.getBool("alternative_subtitles") &&
-			_translation.load("hollywood.dat", "RESOURCE.003")) {
-		_gameStrings = getGameStrings(Common::EN_ANY);
-		_gameStrings.applyTranslation(_translation);
+#ifdef USE_TRANSLATION
+	if (!isDemo() && (getLanguage() == Common::ES_ESP || getLanguage() == Common::UNK_LANG) &&
+			Common::File::exists("hollywood.dat") && _translation.load("hollywood.dat", "RESOURCE.003")) {
+		const Common::Language language = ConfMan.hasKey("language") ?
+			Common::parseLanguage(ConfMan.get("language")) : Common::UNK_LANG;
+		if (language != Common::UNK_LANG && language != Common::ES_ESP) {
+			const char *code = (language == Common::EN_GRB || language == Common::EN_USA) ?
+				"en" : Common::getLanguageCode(language);
+			if (!setSubtitleLanguage(code))
+				warning("No Hollywood Monsters translation for %s", code);
+		}
 	}
+#endif
 
 	const Graphics::PixelFormat screenFormat = Graphics::PixelFormat::createFormatCLUT8();
 	initGraphics(kScreenWidth, kScreenHeight, &screenFormat);
@@ -432,6 +441,41 @@ Common::Language HollywoodEngine::getLanguage() const {
 	return _gameDescription->language;
 }
 
+bool HollywoodEngine::setSubtitleLanguage(const Common::String &language) {
+	if (!_translation.setLanguage(language))
+		return false;
+	_gameStrings = getGameStrings(language.empty() ? getLanguage() : Common::EN_ANY, false);
+	_gameStrings.applyTranslation(_translation);
+	return true;
+}
+
+uint HollywoodEngine::nextSubtitleLanguageIndex() const {
+	const Common::Array<TextTranslation::Language> &languages = _translation.languages();
+	for (uint i = 0; i < languages.size(); ++i) {
+		if (languages[i].code == _translation.language())
+			return i + 1;
+	}
+	return 0;
+}
+
+void HollywoodEngine::cycleSubtitleLanguage() {
+	const Common::Array<TextTranslation::Language> &languages = _translation.languages();
+	if (languages.empty())
+		return;
+	const uint next = nextSubtitleLanguageIndex();
+	const Common::String language = next < languages.size() ? languages[next].code : Common::String();
+	if (setSubtitleLanguage(language)) {
+		ConfMan.set("language", language.empty() ? "es" : language);
+		ConfMan.flushToDisk();
+	}
+}
+
+Common::String HollywoodEngine::nextSubtitleLanguageName() const {
+	const Common::Array<TextTranslation::Language> &languages = _translation.languages();
+	const uint next = nextSubtitleLanguageIndex();
+	return next < languages.size() ? languages[next].name : "Espa\xa4ol";
+}
+
 Common::Platform HollywoodEngine::getPlatform() const {
 	return _gameDescription->platform;
 }
diff --git a/engines/hollywood/monsters/hollywood.h b/engines/hollywood/monsters/hollywood.h
index 839ab95183b..54235ad3cb8 100644
--- a/engines/hollywood/monsters/hollywood.h
+++ b/engines/hollywood/monsters/hollywood.h
@@ -67,6 +67,9 @@ public:
 	bool hasSpeechData() const;
 	const TextTranslation *textTranslation() const { return &_translation; }
 	const HollywoodGameStrings &gameStrings() const { return _gameStrings; }
+	bool setSubtitleLanguage(const Common::String &language);
+	void cycleSubtitleLanguage();
+	Common::String nextSubtitleLanguageName() const;
 
 	HollywoodFont *font() const { return _font; }
 	HollywoodCursor *cursor() { return &_cursor; }
@@ -99,6 +102,7 @@ public:
 	};
 
 private:
+	uint nextSubtitleLanguageIndex() const;
 	Common::Error syncGameStream(Common::Serializer &s);
 	void normalizeLoadedGameState();
 
diff --git a/engines/hollywood/monsters/metaengine.cpp b/engines/hollywood/monsters/metaengine.cpp
index a723ec5f0f8..56071f76f8b 100644
--- a/engines/hollywood/monsters/metaengine.cpp
+++ b/engines/hollywood/monsters/metaengine.cpp
@@ -42,20 +42,6 @@ const ADExtraGuiOptionsMap optionsList[] = {
 			0
 		}
 	},
-#ifdef USE_TRANSLATION
-	{
-		GAMEOPTION_ALTERNATIVE_SUBTITLES,
-		{
-			_s("Enable alternative English subtitles"),
-			_s("Use the English fan translation for subtitles, interface text and images"),
-			"alternative_subtitles",
-			false,
-			0,
-			0
-		}
-	},
-#endif
-
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
@@ -67,7 +53,6 @@ const ADExtraGuiOptionsMap *getMonstersExtraGuiOptions() {
 
 void registerMonstersDefaultSettings() {
 	ConfMan.registerDefault("restored_content", true);
-	ConfMan.registerDefault("alternative_subtitles", false);
 }
 
 void getMonstersSavegameThumbnail(Graphics::Surface &thumb) {
diff --git a/engines/hollywood/monsters/po/en.po b/engines/hollywood/monsters/po/en.po
index 07c7db16b1a..81ba5e63a51 100644
--- a/engines/hollywood/monsters/po/en.po
+++ b/engines/hollywood/monsters/po/en.po
@@ -74,6 +74,10 @@ msgstr "N"
 msgid "interface.optionsQuitPrompt"
 msgstr "Are you sure?"
 
+#. ScummVM's in-game language selector.
+msgid "interface.optionsChangeLanguage"
+msgstr "Change language"
+
 msgid "interface.savePosition"
 msgstr "Choose a position to SAVE"
 
diff --git a/engines/hollywood/monsters/scenes/playable/playable_scene.cpp b/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
index 519eba02e82..8f0a04e6623 100644
--- a/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
+++ b/engines/hollywood/monsters/scenes/playable/playable_scene.cpp
@@ -2088,6 +2088,16 @@ void PlayableScene::suspendAudioForOptionsMenu() {
 	_residentSoundEffects.stop();
 }
 
+void PlayableScene::refreshTranslatedText() {
+	const SceneTextStore previousText = _textStore;
+	if (!loadStage003SceneRows()) {
+		_textStore = previousText;
+		warning("Unable to refresh %s text after changing language", sceneDebugName());
+		return;
+	}
+	applySceneStateToHotspotsAndPatches(0xff);
+}
+
 bool PlayableScene::shouldExitGameplayLoop() const {
 	if (_vm->isSceneRestartRequested())
 		return true;
diff --git a/engines/hollywood/monsters/scenes/playable/playable_scene.h b/engines/hollywood/monsters/scenes/playable/playable_scene.h
index 3e6170d9176..c7aa2a8098f 100644
--- a/engines/hollywood/monsters/scenes/playable/playable_scene.h
+++ b/engines/hollywood/monsters/scenes/playable/playable_scene.h
@@ -406,6 +406,7 @@ protected:
 	Common::Path optionsMenuSoundBank0ArchiveName() const override;
 	bool optionsMenuSpeechPreviewSampleId(uint16 &sampleId) const override;
 	void suspendAudioForOptionsMenu() override;
+	void refreshTranslatedText() override;
 	bool shouldExitGameplayLoop() const override;
 	Common::String inventoryItemName(byte owner, byte itemId) const override;
 	void beginSharedInventorySpeechLine(uint16 rowIndex, byte frameIndex) override;
diff --git a/engines/hollywood/monsters/scenes/playable/scene4030.cpp b/engines/hollywood/monsters/scenes/playable/scene4030.cpp
index 87aae5cb4db..f1cf86ac5d9 100644
--- a/engines/hollywood/monsters/scenes/playable/scene4030.cpp
+++ b/engines/hollywood/monsters/scenes/playable/scene4030.cpp
@@ -397,6 +397,11 @@ bool Scene4030::adjustCustomWalkTargetToFloorMask(int &targetX, int &targetY) co
 	return true;
 }
 
+void Scene4030::refreshTranslatedText() {
+	_originalStageSmallRows.clear();
+	PlayableScene::refreshTranslatedText();
+}
+
 bool Scene4030::applyCustomSceneStateToHotspotsAndPatches(byte selector) {
 	(void)selector;
 	if (_paletteMaskOriginal.empty())
diff --git a/engines/hollywood/monsters/scenes/playable/scene4030.h b/engines/hollywood/monsters/scenes/playable/scene4030.h
index f653028d54d..ecb513e66b3 100644
--- a/engines/hollywood/monsters/scenes/playable/scene4030.h
+++ b/engines/hollywood/monsters/scenes/playable/scene4030.h
@@ -46,6 +46,7 @@ private:
 	bool dispatchCustomSceneAction(uint16 handlerId) override;
 	bool adjustCustomWalkTargetToFloorMask(int &targetX, int &targetY) const override;
 	bool applyCustomSceneStateToHotspotsAndPatches(byte selector) override;
+	void refreshTranslatedText() override;
 	AmbientAudioProfile ambientAudioProfile() const override;
 
 	void initializeSpriteLayers();
diff --git a/engines/hollywood/text_translation.cpp b/engines/hollywood/text_translation.cpp
index baa4d34918d..1c371790ac8 100644
--- a/engines/hollywood/text_translation.cpp
+++ b/engines/hollywood/text_translation.cpp
@@ -34,36 +34,50 @@ TextTranslation::TextTranslation() : _loaded(false) {
 }
 
 TextTranslation::~TextTranslation() {
+	SearchMan.remove("monsters-translated-graphics");
 }
 
 bool TextTranslation::load(const Common::Path &fileName, const Common::Path &originalArchive) {
 	_loaded = false;
 	_text.clear();
+	_language.clear();
+	_languages.clear();
+	SearchMan.remove("monsters-translated-graphics");
 #ifdef USE_TRANSLATION
 	_catalog.reset();
+	_graphics.reset();
+	_archive.reset();
 	Common::ScopedPtr<Common::Archive> archive(Common::makeZipArchive(fileName));
-	if (!archive || !archive->hasFile("monsters.en.dat")) {
+	if (!archive || !archive->hasFile("monsters.dat")) {
 		warning("Unable to open text translation: %s", fileName.toString().c_str());
 		return false;
 	}
 
 	SearchMan.add("monsters-translated-text", archive.get(), 1, false);
-	Common::ScopedPtr<Common::TranslationManager> catalog(new Common::TranslationManager("monsters.en.dat"));
-	catalog->setLanguage("en");
+	Common::ScopedPtr<Common::TranslationManager> catalog(new Common::TranslationManager("monsters.dat"));
 	SearchMan.remove("monsters-translated-text");
-	if (catalog->currentIsBuiltinLanguage() || catalog->getContexts().empty()) {
-		warning("Missing English catalog in %s", fileName.toString().c_str());
-		return false;
-	}
-	Common::ScopedPtr<ImageTranslationArchive> graphics(new ImageTranslationArchive(archive.release()));
+	Common::ScopedPtr<ImageTranslationArchive> graphics(new ImageTranslationArchive(archive.get()));
 	if (!graphics->load(originalArchive)) {
 		warning("Invalid image translation in %s", fileName.toString().c_str());
 		return false;
 	}
 
+	const Common::TLangArray languages = catalog->getSupportedLanguageNames();
+	for (uint i = 0; i < languages.size(); ++i) {
+		const Common::String code = catalog->getLangById(languages[i].id);
+		if (!code.hasPrefix("monsters-") || code.size() == 9)
+			continue;
+		Language language;
+		language.code = code.substr(9);
+		if (!decodeText(languages[i].name, language.name))
+			language.name = language.code;
+		_languages.push_back(language);
+	}
+	if (_languages.empty())
+		return false;
+	_archive.reset(archive.release());
+	_graphics.reset(graphics.release());
 	_catalog.reset(catalog.release());
-	_loaded = true;
-	SearchMan.add("monsters-translated-graphics", graphics.release(), 1);
 	return true;
 #else
 	warning("Alternative subtitles require translation support in this build");
@@ -71,6 +85,35 @@ bool TextTranslation::load(const Common::Path &fileName, const Common::Path &ori
 #endif
 }
 
+bool TextTranslation::setLanguage(const Common::String &language) {
+	if (language == _language)
+		return true;
+#ifdef USE_TRANSLATION
+	if (!language.empty()) {
+		if (!_catalog || _catalog->parseLanguage("monsters-" + language) == Common::kTranslationBuiltinId)
+			return false;
+		SearchMan.add("monsters-translated-text", _archive.get(), 1, false);
+		Common::ScopedPtr<Common::TranslationManager> catalog(new Common::TranslationManager("monsters.dat"));
+		catalog->setLanguage("monsters-" + language);
+		SearchMan.remove("monsters-translated-text");
+		if (catalog->currentIsBuiltinLanguage() || catalog->getContexts().empty()) {
+			warning("Unable to load Hollywood subtitles for %s", language.c_str());
+			return false;
+		}
+		_catalog.reset(catalog.release());
+	}
+	SearchMan.remove("monsters-translated-graphics");
+	if (language == "en")
+		SearchMan.add("monsters-translated-graphics", _graphics.get(), 1, false);
+	_text.clear();
+	_language = language;
+	_loaded = !language.empty();
+	return true;
+#else
+	return false;
+#endif
+}
+
 const Common::String *TextTranslation::findText(const Common::String &key) const {
 	if (!_loaded)
 		return nullptr;
diff --git a/engines/hollywood/text_translation.h b/engines/hollywood/text_translation.h
index f63650d317d..625eb6114e7 100644
--- a/engines/hollywood/text_translation.h
+++ b/engines/hollywood/text_translation.h
@@ -28,20 +28,29 @@
 #include "common/ptr.h"
 #include "common/ustr.h"
 
-#ifdef USE_TRANSLATION
 namespace Common {
+class Archive;
 class TranslationManager;
 }
-#endif
 
 namespace Hollywood {
 
+class ImageTranslationArchive;
+
 class TextTranslation {
 public:
+	struct Language {
+		Common::String code;
+		Common::String name;
+	};
+
 	TextTranslation();
 	~TextTranslation();
 
 	bool load(const Common::Path &fileName, const Common::Path &originalArchive);
+	bool setLanguage(const Common::String &language);
+	const Common::String &language() const { return _language; }
+	const Common::Array<Language> &languages() const { return _languages; }
 	void applyRows(const Common::String &section, Common::Array<byte> &rows,
 		uint rowSize, uint firstRow, uint firstRecord) const;
 	const char *interfaceText(const Common::String &key, const char *fallback) const;
@@ -51,8 +60,12 @@ private:
 	bool decodeText(const Common::U32String &value, Common::String &text) const;
 
 #ifdef USE_TRANSLATION
+	Common::ScopedPtr<Common::Archive> _archive;
+	Common::ScopedPtr<ImageTranslationArchive> _graphics;
 	Common::ScopedPtr<Common::TranslationManager> _catalog;
 #endif
+	Common::String _language;
+	Common::Array<Language> _languages;
 	mutable Common::StringMap _text;
 	bool _loaded;
 };




More information about the Scummvm-git-logs mailing list