SCI: fix broken ADGF_ADDENGLISH flag handling

All languages have to be re-added after the customization
of the gui options. We only added the default language.
This commit is contained in:
athrxx
2026-03-28 01:22:57 +01:00
parent 11c2d0c1b2
commit 87549b4660
3 changed files with 24 additions and 1 deletions
+16
View File
@@ -184,6 +184,22 @@ const String getGameGUIOptionsDescriptionLanguage(Language lang) {
return String("lang_") + getLanguageDescription(lang);
}
List<Language> parseLanguagesFromGameGUIOptionsString(const String &optionsString) {
List<Language> result;
const char langPrefix[] = "lang_";
const size_t langPrefixLen = strlen(langPrefix);
for (size_t pos = optionsString.find(langPrefix); pos != String::npos; pos = optionsString.find(langPrefix, pos + langPrefixLen)) {
for (const LanguageDescription *it = g_languages; it < &g_languages[ARRAYSIZE(g_languages)] && it->id != UNK_LANG; ++it) {
if (optionsString.substr(pos + langPrefixLen, MIN<size_t>(optionsString.size() - (pos + langPrefixLen), strlen(it->description))).equals(it->description))
result.push_back(it->id);
}
}
return result;
}
List<String> getLanguageList() {
List<String> list;
+1
View File
@@ -106,6 +106,7 @@ extern const char *getLanguageDescription(Language id);
// TODO: Document this GUIO related function
const String getGameGUIOptionsDescriptionLanguage(Common::Language lang);
List<Language> parseLanguagesFromGameGUIOptionsString(const String &optionsString);
// TODO: Document this GUIO related function
bool checkGameGUIOptionLanguage(Common::Language lang, const String &str);
+7 -1
View File
@@ -235,8 +235,14 @@ DetectedGames SciMetaEngineDetection::detectGames(const Common::FSList &fslist,
break;
}
// Save the language info from the options string, since it will be overwritten in the next step.
Common::List<Common::Language> langList = Common::parseLanguagesFromGameGUIOptionsString(game.getGUIOptions());
game.setGUIOptions(customizeGuiOptions(fslist.begin()->getParent().getPath(), parseGameGUIOptions(game.getGUIOptions()), game.platform, g->gameidStr, g->version));
game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(game.language));
// Restore the language info to the options string.
for (const Common::Language &lang : langList)
game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(lang));
}
return games;