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

elasota noreply at scummvm.org
Tue May 30 00:58:41 UTC 2023


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:
c524fee2ff VCRUISE: Add support for Steam release subtitles


Commit: c524fee2ff57f797439b093c0ce30942ab45c3ed
    https://github.com/scummvm/scummvm/commit/c524fee2ff57f797439b093c0ce30942ab45c3ed
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-29T20:57:47-04:00

Commit Message:
VCRUISE: Add support for Steam release subtitles

Changed paths:
    engines/vcruise/detection.cpp
    engines/vcruise/runtime.cpp
    engines/vcruise/runtime.h


diff --git a/engines/vcruise/detection.cpp b/engines/vcruise/detection.cpp
index 5297415093c..b7419e147bd 100644
--- a/engines/vcruise/detection.cpp
+++ b/engines/vcruise/detection.cpp
@@ -88,6 +88,14 @@ public:
 			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
 			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::EL_GRC));
 			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::RU_RUS));
+
+			// Steam version languages
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::BG_BUL));
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ZH_TWN));
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::JA_JPN));
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::HU_HUN));
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ZH_CHN));
+			game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::CS_CZE));
 		}
 
 		return game;
diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp
index 3235c0ef5d3..e0b2334a823 100644
--- a/engines/vcruise/runtime.cpp
+++ b/engines/vcruise/runtime.cpp
@@ -1045,7 +1045,7 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
 	  _panoramaState(kPanoramaStateInactive),
 	  _listenerX(0), _listenerY(0), _listenerAngle(0), _soundCacheIndex(0),
 	  _isInGame(false),
-	  _subtitleFont(nullptr), _isDisplayingSubtitles(false), _isSubtitleSourceAnimation(false), _languageIndex(0), _defaultLanguage(defaultLanguage),
+	  _subtitleFont(nullptr), _isDisplayingSubtitles(false), _isSubtitleSourceAnimation(false), _languageIndex(0), _defaultLanguageIndex(0), _defaultLanguage(defaultLanguage),
 	  _isCDVariant(false) {
 
 	for (uint i = 0; i < kNumDirections; i++) {
@@ -1294,6 +1294,7 @@ bool Runtime::bootGame(bool newGame) {
 	Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
 
 	_languageIndex = 1;
+	_defaultLanguageIndex = 1;
 
 	if (_gameID == GID_REAH) {
 		_animSpeedRotation = Fraction(21, 1);	// Probably accurate
@@ -1312,6 +1313,11 @@ bool Runtime::bootGame(bool newGame) {
 
 		uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
 
+		for (uint li = 0; li < langCount; li++) {
+			if (langIndexes[li] == _defaultLanguage)
+				_defaultLanguageIndex = li;
+		}
+
 		for (uint li = 0; li < langCount; li++) {
 			if (langIndexes[li] == lang) {
 				_languageIndex = li;
@@ -1336,10 +1342,23 @@ bool Runtime::bootGame(bool newGame) {
 			Common::RU_RUS,
 			Common::EL_GRC,
 			Common::EN_USA,
+
+			// Additional subs present in Steam release
+			Common::BG_BUL,
+			Common::ZH_TWN,
+			Common::JA_JPN,
+			Common::HU_HUN,
+			Common::ZH_CHN,
+			Common::CS_CZE,
 		};
 
 		uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
 
+		for (uint li = 0; li < langCount; li++) {
+			if (langIndexes[li] == _defaultLanguage)
+				_defaultLanguageIndex = li;
+		}
+
 		for (uint li = 0; li < langCount; li++) {
 			if (langIndexes[li] == lang) {
 				_languageIndex = li;
@@ -1350,19 +1369,23 @@ bool Runtime::bootGame(bool newGame) {
 		}
 	}
 
-	Common::CodePage codePage = Common::CodePage::kWindows1252;
+	Common::CodePage codePage = resolveCodePageForLanguage(lang);
 
-	if (lang == Common::PL_POL)
-		codePage = Common::CodePage::kWindows1250;
-	else if (lang == Common::RU_RUS)
-		codePage = Common::CodePage::kWindows1251;
-	else if (lang == Common::EL_GRC)
-		codePage = Common::CodePage::kWindows1253;
+	bool subtitlesLoadedOK = loadSubtitles(codePage);
 
-	if (loadSubtitles(codePage)) {
-		debug(1, "Subtitles loaded OK");
+	if (!loadSubtitles(codePage)) {
+		lang = _defaultLanguage;
+		_languageIndex = _defaultLanguageIndex;
+
+		warning("Localization data failed to load, retrying with default language");
+
+		codePage = resolveCodePageForLanguage(lang);
+		subtitlesLoadedOK = loadSubtitles(codePage);
 	}
 
+	if (subtitlesLoadedOK)
+		debug(1, "Subtitles loaded OK");
+
 	_uiGraphics.resize(24);
 	for (uint i = 0; i < _uiGraphics.size(); i++) {
 		if (_gameID == GID_REAH) {
@@ -1388,6 +1411,27 @@ bool Runtime::bootGame(bool newGame) {
 	return true;
 }
 
+Common::CodePage Runtime::resolveCodePageForLanguage(Common::Language lang) {
+	switch (lang) {
+	case Common::PL_POL:
+	case Common::CS_CZE:
+		return Common::CodePage::kWindows1250;
+	case Common::RU_RUS:
+	case Common::BG_BUL:
+		return Common::CodePage::kWindows1251;
+	case Common::EL_GRC:
+		return Common::CodePage::kWindows1253;
+	case Common::ZH_TWN:
+		return Common::CodePage::kBig5;
+	case Common::JA_JPN:
+		return Common::CodePage::kWindows932; // Uses Shift-JIS, which Windows 932 is an extension of
+	case Common::ZH_CHN:
+		return Common::CodePage::kGBK;
+	default:
+		return Common::CodePage::kWindows1252;
+	}
+}
+
 void Runtime::drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect) {
 	Common::HashMap<Common::String, UILabelDef>::const_iterator labelDefIt = _locUILabels.find(labelID);
 	if (labelDefIt == _locUILabels.end())
diff --git a/engines/vcruise/runtime.h b/engines/vcruise/runtime.h
index 302e8cb9960..3c6e390cf7d 100644
--- a/engines/vcruise/runtime.h
+++ b/engines/vcruise/runtime.h
@@ -594,6 +594,7 @@ public:
 	LoadGameOutcome loadGame(Common::ReadStream *stream);
 
 	bool bootGame(bool newGame);
+	static Common::CodePage resolveCodePageForLanguage(Common::Language lang);
 
 	void drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect);
 	void getLabelDef(const Common::String &labelID, const Graphics::Font *&outFont, const Common::String *&outTextUTF8, uint32 &outColor, uint32 &outShadowColor, uint32 &outShadowOffset);
@@ -1323,6 +1324,7 @@ private:
 
 	const Graphics::Font *_subtitleFont;
 	Common::SharedPtr<Graphics::Font> _subtitleFontKeepalive;
+	uint _defaultLanguageIndex;
 	uint _languageIndex;
 	bool _isCDVariant;
 	StartConfigDef _startConfigs[kNumStartConfigs];




More information about the Scummvm-git-logs mailing list