mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user