aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-10-29 20:45:28 +0000
committerJohannes Schickel2008-10-29 20:45:28 +0000
commit2ec5515e898eca84ea92ac970c63fe244c89982e (patch)
tree5c6970d393f68a6ad3018aa5cb0fbd0d05a0a99d
parentd8a76a6b595bce9cbfb45ec23149a5e4fb533479 (diff)
downloadscummvm-rg350-2ec5515e898eca84ea92ac970c63fe244c89982e.tar.gz
scummvm-rg350-2ec5515e898eca84ea92ac970c63fe244c89982e.tar.bz2
scummvm-rg350-2ec5515e898eca84ea92ac970c63fe244c89982e.zip
Store names for renderer configuration in config file instead of integers.
svn-id: r34867
-rw-r--r--gui/ThemeEngine.cpp34
-rw-r--r--gui/ThemeEngine.h19
-rw-r--r--gui/newgui.cpp10
-rw-r--r--gui/options.cpp18
4 files changed, 58 insertions, 23 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 9cecefc6cd..ddf346dc7b 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -45,14 +45,40 @@ namespace GUI {
using namespace Graphics;
-const char *ThemeEngine::rendererModeLabels[] = {
- "Disabled GFX",
- "Standard Renderer (16bpp)",
+const ThemeEngine::Renderer ThemeEngine::_rendererModes[] = {
+ { "Disabled GFX", "none", kGfxDisabled },
+ { "Standard Renderer (16bpp)", "normal_16bpp", kGfxStandard16bit },
#ifndef DISABLE_FANCY_THEMES
- "Antialiased Renderer (16bpp)"
+ { "Antialiased Renderer (16bpp)", "aa_16bpp", kGfxAntialias16bit }
#endif
};
+const uint ThemeEngine::_rendererModesSize = ARRAYSIZE(ThemeEngine::_rendererModes);
+
+const ThemeEngine::GraphicsMode ThemeEngine::_defaultRendererMode =
+#ifndef DISABLE_FANCY_THEMES
+ ThemeEngine::kGfxAntialias16bit;
+#else
+ ThemeEngine::kGfxStandard16bit;
+#endif
+
+ThemeEngine::GraphicsMode ThemeEngine::findMode(const Common::String &cfg) {
+ for (uint i = 0; i < _rendererModesSize; ++i) {
+ if (cfg.equalsIgnoreCase(_rendererModes[i].cfg))
+ return _rendererModes[i].mode;
+ }
+
+ return kGfxDisabled;
+}
+
+const char *ThemeEngine::findModeConfigName(GraphicsMode mode) {
+ for (uint i = 0; i < _rendererModesSize; ++i) {
+ if (mode == _rendererModes[i].mode)
+ return _rendererModes[i].cfg;
+ }
+
+ return findModeConfigName(kGfxDisabled);
+}
/**********************************************************
* ThemeItem functions for drawing queues.
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index f5173c015b..c36fe0828d 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -238,16 +238,25 @@ public:
enum GraphicsMode {
kGfxDisabled = 0, /** No GFX */
kGfxStandard16bit, /** 2BPP with the standard (aliased) renderer. */
-#ifndef DISABLE_FANCY_THEMES
- kGfxAntialias16bit, /** 2BPP with the optimized AA renderer. */
-#endif
- kGfxMAX
+ kGfxAntialias16bit /** 2BPP with the optimized AA renderer. */
};
/** Constant value to expand dirty rectangles, to make sure they are fully copied */
static const int kDirtyRectangleThreshold = 1;
- static const char *rendererModeLabels[];
+ struct Renderer {
+ const char *name;
+ const char *cfg;
+ GraphicsMode mode;
+ };
+
+ static const Renderer _rendererModes[];
+ static const uint _rendererModesSize;
+
+ static const GraphicsMode _defaultRendererMode;
+
+ static GraphicsMode findMode(const Common::String &cfg);
+ static const char *findModeConfigName(GraphicsMode mode);
/** Default constructor */
ThemeEngine(Common::String fileName, GraphicsMode mode);
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 6f3b2e28fd..a2b76606dd 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -93,12 +93,8 @@ NewGui::NewGui() : _redrawStatus(kRedrawDisabled),
if (themefile.compareToIgnoreCase("default") == 0)
themefile = "builtin";
-#ifndef DISABLE_FANCY_THEMES
- ConfMan.registerDefault("gui_renderer", 2);
-#else
- ConfMan.registerDefault("gui_renderer", 1);
-#endif
- ThemeEngine::GraphicsMode gfxMode = (ThemeEngine::GraphicsMode)ConfMan.getInt("gui_renderer");
+ ConfMan.registerDefault("gui_renderer", ThemeEngine::findModeConfigName(ThemeEngine::_defaultRendererMode));
+ ThemeEngine::GraphicsMode gfxMode = (ThemeEngine::GraphicsMode)ThemeEngine::findMode(ConfMan.get("gui_renderer"));
loadNewTheme(themefile, gfxMode);
_themeChange = false;
@@ -115,7 +111,7 @@ bool NewGui::loadNewTheme(Common::String filename, ThemeEngine::GraphicsMode gfx
Common::String oldTheme = (_theme != 0) ? _theme->getThemeFileName() : "";
if (gfx == ThemeEngine::kGfxDisabled)
- gfx = (ThemeEngine::GraphicsMode)ConfMan.getInt("gui_renderer");
+ gfx = ThemeEngine::_defaultRendererMode;
if (_theme)
_theme->disable();
diff --git a/gui/options.cpp b/gui/options.cpp
index 5a95101f3d..9b608e4adc 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -736,9 +736,8 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_rendererPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.Renderer", "GUI Renderer:", labelWidth);
- for (int i = 1; i < GUI::ThemeEngine::kGfxMAX; ++i) {
- _rendererPopUp->appendEntry(GUI::ThemeEngine::rendererModeLabels[i], i);
- }
+ for (uint i = 1; i < GUI::ThemeEngine::_rendererModesSize; ++i)
+ _rendererPopUp->appendEntry(GUI::ThemeEngine::_rendererModes[i].name, GUI::ThemeEngine::_rendererModes[i].mode);
_autosavePeriodPopUp = new PopUpWidget(tab, "GlobalOptions_Misc.AutosavePeriod", "Autosave:", labelWidth);
@@ -813,7 +812,10 @@ void GlobalOptionsDialog::open() {
_autosavePeriodPopUp->setSelected(i);
}
- _rendererPopUp->setSelected(ConfMan.getInt("gui_renderer") - 1);
+ ThemeEngine::GraphicsMode mode = ThemeEngine::findMode(ConfMan.get("gui_renderer"));
+ if (mode == ThemeEngine::kGfxDisabled)
+ mode = ThemeEngine::_defaultRendererMode;
+ _rendererPopUp->setSelectedTag(mode);
}
void GlobalOptionsDialog::close() {
@@ -844,9 +846,11 @@ void GlobalOptionsDialog::close() {
ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
- if ((int)_rendererPopUp->getSelectedTag() != ConfMan.getInt("gui_renderer")) {
- g_gui.loadNewTheme(g_gui.theme()->getThemeFileName(), (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag());
- ConfMan.setInt("gui_renderer", _rendererPopUp->getSelectedTag(), _domain);
+ GUI::ThemeEngine::GraphicsMode selected = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
+ const char *cfg = GUI::ThemeEngine::findModeConfigName(selected);
+ if (!ConfMan.get("gui_renderer").equalsIgnoreCase(cfg)) {
+ g_gui.loadNewTheme(g_gui.theme()->getThemeFileName(), selected);
+ ConfMan.set("gui_renderer", cfg, _domain);
}
}
OptionsDialog::close();