diff options
-rw-r--r-- | common/util.cpp | 21 | ||||
-rw-r--r-- | common/util.h | 4 | ||||
-rw-r--r-- | engines/advancedDetector.cpp | 1 | ||||
-rw-r--r-- | engines/game.cpp | 4 | ||||
-rw-r--r-- | engines/game.h | 1 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 1 | ||||
-rw-r--r-- | gui/PopUpWidget.h | 1 | ||||
-rw-r--r-- | gui/launcher.cpp | 20 | ||||
-rw-r--r-- | gui/options.cpp | 12 | ||||
-rw-r--r-- | gui/options.h | 1 |
10 files changed, 49 insertions, 17 deletions
diff --git a/common/util.cpp b/common/util.cpp index 895bcebef7..b8bd327a0a 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -322,9 +322,26 @@ bool checkGameGUIOption(GameGUIOption option, const String &str) { return false; } +bool checkGameGUIOptionLanguage(Language lang, const String &str) { + if (!str.contains("lang_")) // If no languages are specified + return true; + + if (str.contains(getGameGUIOptionsDescriptionLanguage(lang))) + return true; + + return false; +} + +const String getGameGUIOptionsDescriptionLanguage(Language lang) { + if (lang == UNK_LANG) + return ""; + + return String(String("lang_") + getLanguageDescription(lang)); +} + uint32 parseGameGUIOptions(const String &str) { uint32 res = 0; - + for (int i = 0; g_gameOptions[i].desc; i++) if (str.contains(g_gameOptions[i].desc)) res |= g_gameOptions[i].option; @@ -332,7 +349,7 @@ uint32 parseGameGUIOptions(const String &str) { return res; } -String getGameGUIOptionsDescription(uint32 options) { +const String getGameGUIOptionsDescription(uint32 options) { String res = ""; for (int i = 0; g_gameOptions[i].desc; i++) diff --git a/common/util.h b/common/util.h index 62c8f0d1fb..71456353c7 100644 --- a/common/util.h +++ b/common/util.h @@ -228,8 +228,10 @@ enum GameGUIOption { }; bool checkGameGUIOption(GameGUIOption option, const String &str); +bool checkGameGUIOptionLanguage(Language lang, const String &str); uint32 parseGameGUIOptions(const String &str); -String getGameGUIOptionsDescription(uint32 options); +const String getGameGUIOptionsDescription(uint32 options); +const String getGameGUIOptionsDescriptionLanguage(Language lang); /** * Updates the GUI options of the current config manager diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 061eec2faf..ee0c5c7c62 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -208,6 +208,7 @@ static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription * desc["extra"] = realDesc->extra; desc.setGUIOptions(realDesc->guioptions | params.guioptions); + desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language)); } GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const { diff --git a/engines/game.cpp b/engines/game.cpp index c7f26019d6..dea6d37485 100644 --- a/engines/game.cpp +++ b/engines/game.cpp @@ -73,6 +73,10 @@ void GameDescriptor::setGUIOptions(uint32 guioptions) { erase("guioptions"); } +void GameDescriptor::appendGUIOptions(const Common::String &str) { + setVal("guioptions", getVal("guioptions", "") + " " + str); +} + void GameDescriptor::updateDesc(const char *extra) { // TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone. // We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or diff --git a/engines/game.h b/engines/game.h index 49136ecf5a..b125421ff6 100644 --- a/engines/game.h +++ b/engines/game.h @@ -83,6 +83,7 @@ public: void updateDesc(const char *extra = 0); void setGUIOptions(uint32 options); + void appendGUIOptions(const Common::String &str); Common::String &gameid() { return getVal("gameid"); } Common::String &description() { return getVal("description"); } diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 667dab91de..21da732064 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -884,6 +884,7 @@ GameList ScummMetaEngine::detectGames(const Common::FSList &fslist) const { } dg.setGUIOptions(x->game.guioptions | MidiDriver::midiDriverFlags2GUIO(x->game.midi)); + dg.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language)); detectedGames.push_back(dg); } diff --git a/gui/PopUpWidget.h b/gui/PopUpWidget.h index d1c89e45ae..f2c1728b52 100644 --- a/gui/PopUpWidget.h +++ b/gui/PopUpWidget.h @@ -66,6 +66,7 @@ public: void appendEntry(const String &entry, uint32 tag = (uint32)-1); void clearEntries(); + int numEntries() { return _entries.size(); } /** Select the entry at the given index. */ void setSelected(int item); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 176fb45214..1daf9ffd50 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -180,11 +180,12 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc) // Language popup _langPopUpDesc = new StaticTextWidget(tab, "GameOptions_Game.LangPopupDesc", _("Language:"), _("Language of the game. This will not turn your Spanish game version into English")); _langPopUp = new PopUpWidget(tab, "GameOptions_Game.LangPopup", _("Language of the game. This will not turn your Spanish game version into English")); - _langPopUp->appendEntry(_("<default>")); - _langPopUp->appendEntry(""); + _langPopUp->appendEntry(_("<default>"), 0); + _langPopUp->appendEntry("", 0); const Common::LanguageDescription *l = Common::g_languages; for (; l->code; ++l) { - _langPopUp->appendEntry(l->description, l->id); + if (checkGameGUIOptionLanguage(l->id, _guioptionsString)) + _langPopUp->appendEntry(l->description, l->id); } // Platform popup @@ -311,17 +312,16 @@ void EditGameDialog::open() { // TODO: game path - const Common::LanguageDescription *l = Common::g_languages; const Common::Language lang = Common::parseLanguage(ConfMan.get("language", _domain)); - sel = 0; if (ConfMan.hasKey("language", _domain)) { - for (i = 0; l->code; ++l, ++i) { - if (lang == l->id) - sel = i + 2; - } + _langPopUp->setSelectedTag(lang); + } + + if (_langPopUp->numEntries() <= 3) { // If only one language is avaliable + _langPopUpDesc->setEnabled(false); + _langPopUp->setEnabled(false); } - _langPopUp->setSelected(sel); const Common::PlatformDescription *p = Common::g_platforms; diff --git a/gui/options.cpp b/gui/options.cpp index b00886b40e..bee06a4dce 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -126,8 +126,10 @@ void OptionsDialog::init() { // Retrieve game GUI options _guioptions = 0; - if (ConfMan.hasKey("guioptions", _domain)) - _guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain)); + if (ConfMan.hasKey("guioptions", _domain)) { + _guioptionsString = ConfMan.get("guioptions", _domain); + _guioptions = parseGameGUIOptions(_guioptionsString); + } } void OptionsDialog::open() { @@ -138,8 +140,10 @@ void OptionsDialog::open() { // Retrieve game GUI options _guioptions = 0; - if (ConfMan.hasKey("guioptions", _domain)) - _guioptions = parseGameGUIOptions(ConfMan.get("guioptions", _domain)); + if (ConfMan.hasKey("guioptions", _domain)) { + _guioptionsString = ConfMan.get("guioptions", _domain); + _guioptions = parseGameGUIOptions(_guioptionsString); + } // Graphic options if (_fullscreenCheckbox) { diff --git a/gui/options.h b/gui/options.h index 48282a7fd7..fab25ebaed 100644 --- a/gui/options.h +++ b/gui/options.h @@ -156,6 +156,7 @@ protected: // Game GUI options // uint32 _guioptions; + Common::String _guioptionsString; }; |