Skip to content

Commit c524fee

Browse files
committed
VCRUISE: Add support for Steam release subtitles
1 parent 5e8aeaa commit c524fee

File tree

3 files changed

+64
-10
lines changed

3 files changed

+64
-10
lines changed

engines/vcruise/detection.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ class VCruiseMetaEngineDetection : public AdvancedMetaEngineDetection {
8888
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
8989
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::EL_GRC));
9090
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::RU_RUS));
91+
92+
// Steam version languages
93+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::BG_BUL));
94+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ZH_TWN));
95+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::JA_JPN));
96+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::HU_HUN));
97+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ZH_CHN));
98+
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::CS_CZE));
9199
}
92100

93101
return game;

engines/vcruise/runtime.cpp

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
10451045
_panoramaState(kPanoramaStateInactive),
10461046
_listenerX(0), _listenerY(0), _listenerAngle(0), _soundCacheIndex(0),
10471047
_isInGame(false),
1048-
_subtitleFont(nullptr), _isDisplayingSubtitles(false), _isSubtitleSourceAnimation(false), _languageIndex(0), _defaultLanguage(defaultLanguage),
1048+
_subtitleFont(nullptr), _isDisplayingSubtitles(false), _isSubtitleSourceAnimation(false), _languageIndex(0), _defaultLanguageIndex(0), _defaultLanguage(defaultLanguage),
10491049
_isCDVariant(false) {
10501050

10511051
for (uint i = 0; i < kNumDirections; i++) {
@@ -1294,6 +1294,7 @@ bool Runtime::bootGame(bool newGame) {
12941294
Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
12951295

12961296
_languageIndex = 1;
1297+
_defaultLanguageIndex = 1;
12971298

12981299
if (_gameID == GID_REAH) {
12991300
_animSpeedRotation = Fraction(21, 1); // Probably accurate
@@ -1312,6 +1313,11 @@ bool Runtime::bootGame(bool newGame) {
13121313

13131314
uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
13141315

1316+
for (uint li = 0; li < langCount; li++) {
1317+
if (langIndexes[li] == _defaultLanguage)
1318+
_defaultLanguageIndex = li;
1319+
}
1320+
13151321
for (uint li = 0; li < langCount; li++) {
13161322
if (langIndexes[li] == lang) {
13171323
_languageIndex = li;
@@ -1336,10 +1342,23 @@ bool Runtime::bootGame(bool newGame) {
13361342
Common::RU_RUS,
13371343
Common::EL_GRC,
13381344
Common::EN_USA,
1345+
1346+
// Additional subs present in Steam release
1347+
Common::BG_BUL,
1348+
Common::ZH_TWN,
1349+
Common::JA_JPN,
1350+
Common::HU_HUN,
1351+
Common::ZH_CHN,
1352+
Common::CS_CZE,
13391353
};
13401354

13411355
uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
13421356

1357+
for (uint li = 0; li < langCount; li++) {
1358+
if (langIndexes[li] == _defaultLanguage)
1359+
_defaultLanguageIndex = li;
1360+
}
1361+
13431362
for (uint li = 0; li < langCount; li++) {
13441363
if (langIndexes[li] == lang) {
13451364
_languageIndex = li;
@@ -1350,19 +1369,23 @@ bool Runtime::bootGame(bool newGame) {
13501369
}
13511370
}
13521371

1353-
Common::CodePage codePage = Common::CodePage::kWindows1252;
1372+
Common::CodePage codePage = resolveCodePageForLanguage(lang);
13541373

1355-
if (lang == Common::PL_POL)
1356-
codePage = Common::CodePage::kWindows1250;
1357-
else if (lang == Common::RU_RUS)
1358-
codePage = Common::CodePage::kWindows1251;
1359-
else if (lang == Common::EL_GRC)
1360-
codePage = Common::CodePage::kWindows1253;
1374+
bool subtitlesLoadedOK = loadSubtitles(codePage);
13611375

1362-
if (loadSubtitles(codePage)) {
1363-
debug(1, "Subtitles loaded OK");
1376+
if (!loadSubtitles(codePage)) {
1377+
lang = _defaultLanguage;
1378+
_languageIndex = _defaultLanguageIndex;
1379+
1380+
warning("Localization data failed to load, retrying with default language");
1381+
1382+
codePage = resolveCodePageForLanguage(lang);
1383+
subtitlesLoadedOK = loadSubtitles(codePage);
13641384
}
13651385

1386+
if (subtitlesLoadedOK)
1387+
debug(1, "Subtitles loaded OK");
1388+
13661389
_uiGraphics.resize(24);
13671390
for (uint i = 0; i < _uiGraphics.size(); i++) {
13681391
if (_gameID == GID_REAH) {
@@ -1388,6 +1411,27 @@ bool Runtime::bootGame(bool newGame) {
13881411
return true;
13891412
}
13901413

1414+
Common::CodePage Runtime::resolveCodePageForLanguage(Common::Language lang) {
1415+
switch (lang) {
1416+
case Common::PL_POL:
1417+
case Common::CS_CZE:
1418+
return Common::CodePage::kWindows1250;
1419+
case Common::RU_RUS:
1420+
case Common::BG_BUL:
1421+
return Common::CodePage::kWindows1251;
1422+
case Common::EL_GRC:
1423+
return Common::CodePage::kWindows1253;
1424+
case Common::ZH_TWN:
1425+
return Common::CodePage::kBig5;
1426+
case Common::JA_JPN:
1427+
return Common::CodePage::kWindows932; // Uses Shift-JIS, which Windows 932 is an extension of
1428+
case Common::ZH_CHN:
1429+
return Common::CodePage::kGBK;
1430+
default:
1431+
return Common::CodePage::kWindows1252;
1432+
}
1433+
}
1434+
13911435
void Runtime::drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect) {
13921436
Common::HashMap<Common::String, UILabelDef>::const_iterator labelDefIt = _locUILabels.find(labelID);
13931437
if (labelDefIt == _locUILabels.end())

engines/vcruise/runtime.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ class Runtime {
594594
LoadGameOutcome loadGame(Common::ReadStream *stream);
595595

596596
bool bootGame(bool newGame);
597+
static Common::CodePage resolveCodePageForLanguage(Common::Language lang);
597598

598599
void drawLabel(Graphics::ManagedSurface *surface, const Common::String &labelID, const Common::Rect &contentRect);
599600
void getLabelDef(const Common::String &labelID, const Graphics::Font *&outFont, const Common::String *&outTextUTF8, uint32 &outColor, uint32 &outShadowColor, uint32 &outShadowOffset);
@@ -1323,6 +1324,7 @@ class Runtime {
13231324

13241325
const Graphics::Font *_subtitleFont;
13251326
Common::SharedPtr<Graphics::Font> _subtitleFontKeepalive;
1327+
uint _defaultLanguageIndex;
13261328
uint _languageIndex;
13271329
bool _isCDVariant;
13281330
StartConfigDef _startConfigs[kNumStartConfigs];

0 commit comments

Comments
 (0)