From d9c05f7121f6d3cdd800f295c2ec33783babdee2 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 19 Feb 2012 16:26:09 +0100 Subject: COMMON: add gui options for rendering modes The purpose is the same as for the sound gui options: users shouldn't be offered modes that the engine doesn't support. --- gui/options.cpp | 35 ++++++++++++++++++++++++++++++++--- gui/options.h | 2 ++ 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'gui') diff --git a/gui/options.cpp b/gui/options.cpp index 4fa5a821fb..bfad81c07b 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -191,9 +191,9 @@ void OptionsDialog::open() { int sel = 0; for (int i = 0; p->code; ++p, ++i) { if (renderMode == p->id) - sel = i + 2; + sel = p->id; } - _renderModePopUp->setSelected(sel); + _renderModePopUp->setSelectedTag(sel); } #ifdef SMALL_SCREEN_DEVICE @@ -748,13 +748,18 @@ void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &pr } // RenderMode popup + const Common::String allFlags = renderType2GUIO((uint32)-1); + 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")); _renderModePopUp = new PopUpWidget(boss, prefix + "grRenderPopup", _("Special dithering modes supported by some games")); _renderModePopUp->appendEntry(_(""), Common::kRenderDefault); _renderModePopUp->appendEntry(""); const Common::RenderModeDescription *rm = Common::g_renderModes; for (; rm->code; ++rm) { - _renderModePopUp->appendEntry(_c(rm->description, context), rm->id); + Common::String renderGuiOption = renderType2GUIO(rm->id); + if ((_domain == Common::ConfigManager::kApplicationDomain) || (_domain != Common::ConfigManager::kApplicationDomain && !renderingTypeDefined) || (_guioptions.contains(renderGuiOption))) + _renderModePopUp->appendEntry(_c(rm->description, context), rm->id); } // Fullscreen checkbox @@ -1033,6 +1038,30 @@ 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::kRenderPC98, GUIO_RENDERPC98 } + }; + 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 92ce3e5df4..4e0187f50f 100644 --- a/gui/options.h +++ b/gui/options.h @@ -85,6 +85,8 @@ 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; -- cgit v1.2.3