KYRA: (LOK/Mac) - priorize resource files that match the selected language

The talkie version seems to have file versions for all supported languages in the game folder. So we try the ones that match our language first.
This commit is contained in:
athrxx
2022-08-13 16:51:33 +02:00
parent eb6a769085
commit 4a28783478
4 changed files with 25 additions and 6 deletions
+18
View File
@@ -95,6 +95,24 @@ KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags)
_malcolmFrame = 0;
_malcolmTimer1 = _malcolmTimer2 = 0;
// Determine search order for resource files with language specific file endings. Some versions have multiple
// versions in the folder, so we make sure that the one that matches the selected language gets tried first.
static const Common::Language langOrder[] = {
Common::EN_ANY, Common::FR_FRA, Common::DE_DEU, Common::ES_ESP, Common::IT_ITA, Common::HE_ISR, Common::KO_KOR
};
static const char *pattern[] = { "15", "_ENG", "_FRE", "_GER", "_SPA", "_ITA", "_HEB", "_HAN", "" };
uint8 _langFileExtIndex[ARRAYSIZE(pattern)];
memset(_langFileExtIndex, 0, sizeof(_langFileExtIndex));
for (int i = 0; i < ARRAYSIZE(langOrder); ++i) {
if (_flags.lang == langOrder[i])
_langFileExtIndex[0] = i + 1;
}
for (int i = 1; i < ARRAYSIZE(_langFileExtIndex); ++i)
_langFileExtIndex[i] = (i <= _langFileExtIndex[0]) ? i - 1 : i;
for (int i = 0; i < ARRAYSIZE(_langFileExtIndex); ++i)
_langFileExt.push_back(pattern[_langFileExtIndex[i]]);
_defaultFont = Screen::FID_8_FNT;
_noteFont = (_flags.isTalkie || flags.platform == Common::kPlatformAmiga) ? _defaultFont : Screen::FID_6_FNT;
_defaultLineSpacing = 0;
+2
View File
@@ -528,6 +528,8 @@ protected:
static const int8 _macLQTrackMap[];
static const int _macLQTrackMapSize;
Common::Array<Common::String> _langFileExt;
// TODO: get rid of all variables having pointers to the static resources if possible
// i.e. let them directly use the _staticres functions
void initStaticResource();
+3 -3
View File
@@ -998,9 +998,9 @@ void KyraEngine_LoK::loadMainScreen(int page) {
_screen->clearPage(page);
bool success = false;
static const char *pattern[] = { "15", "_ENG", "_FRE", "_GER", "_SPA", "_ITA", "_HEB", "_HAN", "" };
for (int i = 0; i < ARRAYSIZE(pattern) && !success; ++i) {
Common::String tryFile = Common::String::format("MAIN%s.CPS", pattern[i]);
for (int i = 0; i < _langFileExt.size() && !success; ++i) {
Common::String tryFile = Common::String::format("MAIN%s.CPS", _langFileExt[i].c_str());
if ((success = _res->exists(tryFile.c_str())))
_screen->loadBitmap(tryFile.c_str(), page, page, i == 0 ? &_screen->getPalette(0) : 0);
}
+2 -3
View File
@@ -252,9 +252,8 @@ bool KyraEngine_LoK::seq_introStory() {
return false;
bool success = false;
static const char *pattern[] = { "", "_ENG", "_FRE", "_GER", "_SPA", "_ITA", "_HEB", "_HAN" };
for (int i = 0; i < ARRAYSIZE(pattern) && !success; ++i) {
Common::String tryFile = Common::String::format("TEXT%s.CPS", pattern[i]);
for (int i = 0; i < _langFileExt.size() && !success; ++i) {
Common::String tryFile = Common::String::format("TEXT%s.CPS", _langFileExt[i].c_str());
if ((success = _res->exists(tryFile.c_str())))
_screen->loadBitmap(tryFile.c_str(), 3, 3, &_screen->getPalette(0));
}