diff options
author | Eugene Sandulenko | 2012-03-17 03:51:27 -0700 |
---|---|---|
committer | Eugene Sandulenko | 2012-03-17 03:51:27 -0700 |
commit | 34198fda35cc3daf848ded9ddf6d64949ed36f39 (patch) | |
tree | 7268ce152f9ce3440c5b3039b414559a4cc4dcac | |
parent | 56252909f5bebfa9cfd43cf092effb0111fdabef (diff) | |
parent | c0d54bdd8dcd2235a0258af145fe2528c07c9fc2 (diff) | |
download | scummvm-rg350-34198fda35cc3daf848ded9ddf6d64949ed36f39.tar.gz scummvm-rg350-34198fda35cc3daf848ded9ddf6d64949ed36f39.tar.bz2 scummvm-rg350-34198fda35cc3daf848ded9ddf6d64949ed36f39.zip |
Merge pull request #203 from fingolfin/guio-cleanup
COMMON: GuiOptions cleanup
-rw-r--r-- | common/gui_options.cpp | 17 | ||||
-rw-r--r-- | common/gui_options.h | 5 | ||||
-rw-r--r-- | common/language.cpp | 18 | ||||
-rw-r--r-- | common/language.h | 6 | ||||
-rw-r--r-- | common/rendermode.cpp | 41 | ||||
-rw-r--r-- | common/rendermode.h | 6 | ||||
-rw-r--r-- | gui/options.cpp | 29 | ||||
-rw-r--r-- | gui/options.h | 2 |
8 files changed, 74 insertions, 50 deletions
diff --git a/common/gui_options.cpp b/common/gui_options.cpp index 5b7d939dc4..32a7cc9c41 100644 --- a/common/gui_options.cpp +++ b/common/gui_options.cpp @@ -79,23 +79,6 @@ bool checkGameGUIOption(const String &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("lang_") + getLanguageDescription(lang); -} - String parseGameGUIOptions(const String &str) { String res; diff --git a/common/gui_options.h b/common/gui_options.h index 5649f1103d..33ecccad63 100644 --- a/common/gui_options.h +++ b/common/gui_options.h @@ -23,8 +23,6 @@ #ifndef COMMON_GUI_OPTIONS_H #define COMMON_GUI_OPTIONS_H -#include "common/language.h" - #define GUIO_NONE "\000" #define GUIO_NOSUBTITLES "\001" #define GUIO_NOMUSIC "\002" @@ -68,12 +66,11 @@ namespace Common { +class String; bool checkGameGUIOption(const String &option, const String &str); -bool checkGameGUIOptionLanguage(Common::Language lang, const String &str); String parseGameGUIOptions(const String &str); const String getGameGUIOptionsDescription(const String &options); -const String getGameGUIOptionsDescriptionLanguage(Common::Language lang); /** * Updates the GUI options of the current config manager diff --git a/common/language.cpp b/common/language.cpp index 1de01b0207..898adf8d0e 100644 --- a/common/language.cpp +++ b/common/language.cpp @@ -20,6 +20,7 @@ */ #include "common/language.h" +#include "common/gui_options.h" #include "common/str.h" namespace Common { @@ -104,4 +105,21 @@ const char *getLanguageDescription(Language id) { return 0; } +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("lang_") + getLanguageDescription(lang); +} + } // End of namespace Common diff --git a/common/language.h b/common/language.h index b83f0d34fd..db552fc9c4 100644 --- a/common/language.h +++ b/common/language.h @@ -75,6 +75,12 @@ extern const char *getLanguageCode(Language id); extern const char *getLanguageLocale(Language id); extern const char *getLanguageDescription(Language id); +// TODO: Document this GUIO related function +const String getGameGUIOptionsDescriptionLanguage(Common::Language lang); + +// TODO: Document this GUIO related function +bool checkGameGUIOptionLanguage(Common::Language lang, const String &str); + } // End of namespace Common #endif diff --git a/common/rendermode.cpp b/common/rendermode.cpp index 62b67faee5..1ca67c1878 100644 --- a/common/rendermode.cpp +++ b/common/rendermode.cpp @@ -22,6 +22,7 @@ #include "common/rendermode.h" +#include "common/gui_options.h" #include "common/str.h" #include "common/translation.h" @@ -43,6 +44,26 @@ const RenderModeDescription g_renderModes[] = { {0, 0, kRenderDefault} }; +struct RenderGUIOMapping { + RenderMode id; + const char *guio; +}; + +// TODO: Merge s_renderGUIOMapping into g_renderModes? the kRenderDefault +// could be used to indicate "any" mode when passed to renderMode2GUIO (if +// we wanted to merge allRenderModesGUIOs back into) +static const RenderGUIOMapping s_renderGUIOMapping[] = { + { kRenderHercG, GUIO_RENDERHERCGREEN }, + { kRenderHercA, GUIO_RENDERHERCAMBER }, + { kRenderCGA, GUIO_RENDERCGA }, + { kRenderEGA, GUIO_RENDEREGA }, + { kRenderVGA, GUIO_RENDERVGA }, + { kRenderAmiga, GUIO_RENDERAMIGA }, + { kRenderFMTowns, GUIO_RENDERFMTOWNS }, + { kRenderPC9821, GUIO_RENDERPC9821 }, + { kRenderPC9801, GUIO_RENDERPC9801 } +}; + DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Green", "lowres") DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Hercules Amber", "lowres") @@ -77,5 +98,25 @@ const char *getRenderModeDescription(RenderMode id) { return 0; } +String renderMode2GUIO(RenderMode id) { + Common::String res; + + for (int i = 0; i < ARRAYSIZE(s_renderGUIOMapping); i++) { + if (id == s_renderGUIOMapping[i].id) + res += s_renderGUIOMapping[i].guio; + } + + return res; +} + +String allRenderModesGUIOs() { + Common::String res; + + for (int i = 0; i < ARRAYSIZE(s_renderGUIOMapping); i++) { + res += s_renderGUIOMapping[i].guio; + } + + return res; +} } // End of namespace Common diff --git a/common/rendermode.h b/common/rendermode.h index c2fece77ee..945c4e7d9d 100644 --- a/common/rendermode.h +++ b/common/rendermode.h @@ -61,6 +61,12 @@ extern RenderMode parseRenderMode(const String &str); extern const char *getRenderModeCode(RenderMode id); extern const char *getRenderModeDescription(RenderMode id); +// TODO: Rename the following to something better; also, document it +extern String renderMode2GUIO(RenderMode id); + +// TODO: Rename the following to something better; also, document it +extern String allRenderModesGUIOs(); + } // End of namespace Common diff --git a/gui/options.cpp b/gui/options.cpp index 3a16bddd7c..6747195a1b 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -750,7 +750,7 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr } // RenderMode popup - const Common::String allFlags = renderType2GUIO((uint32)-1); + const Common::String allFlags = Common::allRenderModesGUIOs(); bool renderingTypeDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL); _renderModePopUpDesc = new StaticTextWidget(boss, prefix + "grRenderPopupDesc", _("Render mode:"), _("Special dithering modes supported by some games")); @@ -759,7 +759,7 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr _renderModePopUp->appendEntry(""); const Common::RenderModeDescription *rm = Common::g_renderModes; for (; rm->code; ++rm) { - Common::String renderGuiOption = renderType2GUIO(rm->id); + Common::String renderGuiOption = Common::renderMode2GUIO(rm->id); if ((_domain == Common::ConfigManager::kApplicationDomain) || (_domain != Common::ConfigManager::kApplicationDomain && !renderingTypeDefined) || (_guioptions.contains(renderGuiOption))) _renderModePopUp->appendEntry(_c(rm->description, context), rm->id); } @@ -1040,31 +1040,6 @@ void OptionsDialog::saveMusicDeviceSetting(PopUpWidget *popup, Common::String se ConfMan.removeKey(setting, _domain); } -Common::String OptionsDialog::renderType2GUIO(uint32 renderType) { - static const struct { - Common::RenderMode type; - const char *guio; - } renderGUIOMapping[] = { - { Common::kRenderHercG, GUIO_RENDERHERCGREEN }, - { Common::kRenderHercA, GUIO_RENDERHERCAMBER }, - { Common::kRenderCGA, GUIO_RENDERCGA }, - { Common::kRenderEGA, GUIO_RENDEREGA }, - { Common::kRenderVGA, GUIO_RENDERVGA }, - { Common::kRenderAmiga, GUIO_RENDERAMIGA }, - { Common::kRenderFMTowns, GUIO_RENDERFMTOWNS }, - { Common::kRenderPC9821, GUIO_RENDERPC9821 }, - { Common::kRenderPC9801, GUIO_RENDERPC9801 } - }; - Common::String res; - - for (int i = 0; i < ARRAYSIZE(renderGUIOMapping); i++) { - if (renderType == renderGUIOMapping[i].type || renderType == (uint32)-1) - res += renderGUIOMapping[i].guio; - } - - return res; -} - int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) { if (_guioptions.contains(GUIO_NOSUBTITLES)) return kSubtitlesSpeech; // Speech only diff --git a/gui/options.h b/gui/options.h index 83c9d60d59..05b3cac617 100644 --- a/gui/options.h +++ b/gui/options.h @@ -85,8 +85,6 @@ protected: bool loadMusicDeviceSetting(PopUpWidget *popup, Common::String setting, MusicType preferredType = MT_AUTO); void saveMusicDeviceSetting(PopUpWidget *popup, Common::String setting); - Common::String renderType2GUIO(uint32 renderType); - TabWidget *_tabWidget; int _graphicsTabId; int _midiTabId; |