void GameSettings::setOption(const ConfigOptionMap& configuration, const Ogre::String& option, Combobox* combobox) { ConfigOptionMap::const_iterator cfi = configuration.find(option); if (cfi != configuration.end()) { ConfigOption curOption = cfi->second; int delta = curOption.possibleValues.size() - combobox->getItemCount(); if (delta > 0) { for (int i = 0; i < delta; ++i) { combobox->addItem(new ListboxTextItem("")); } } else if (delta < 0) { for (int i = 0; i < -delta; ++i) { ListboxItem* item = combobox->getListboxItemFromIndex(combobox->getItemCount() - 1); combobox->removeItem(item); delete item; } } for (unsigned int i = 0; i < combobox->getItemCount(); ++i) { ListboxItem* item = combobox->getListboxItemFromIndex(i); item->setText(curOption.possibleValues[i]); } } }
void GameSettings::update() { Root* root = Ogre::Root::getSingletonPtr(); Ogre::RenderSystem* renderer = root->getRenderSystem(); #if OGRE_VERSION_MINOR == 7 || OGRE_VERSION_MINOR == 8 const RenderSystemList& renderers = root->getAvailableRenderers(); #else const RenderSystemList renderers = *root->getAvailableRenderers(); #endif createElements(mVideoRenderer, renderers.size()); for (unsigned int i = 0; i < renderers.size(); ++i) { Ogre::RenderSystem* cur = renderers[i]; ListboxItem* item = mVideoRenderer->getListboxItemFromIndex(i); item->setText(cur->getName()); if (cur == renderer) { mVideoRenderer->setItemSelectState(item, true); } } ConfigOptionMap config = renderer->getConfigOptions(); setOption(config, "Full Screen", mVideoFullscreen); std::vector<RadioButton*> videoColorDepth; videoColorDepth.push_back(mVideoColorDepth32); videoColorDepth.push_back(mVideoColorDepth16); setOption(config, "Colour Depth", videoColorDepth); std::vector<RadioButton*> videoAntiAliasing; videoAntiAliasing.push_back(mVideoFsaa0); videoAntiAliasing.push_back(mVideoFsaa2); videoAntiAliasing.push_back(mVideoFsaa4); videoAntiAliasing.push_back(mVideoFsaa8); setOption(config, "FSAA", videoAntiAliasing); std::vector<RadioButton*> videoRttMode; videoRttMode.push_back(mVideoRttModeFBO); videoRttMode.push_back(mVideoRttModePBuffer); videoRttMode.push_back(mVideoRttModeCopy); setOption(config, "RTT Preferred Mode", videoRttMode); setOption(config, "Video Mode", mVideoResolution); }