From 07af9a45c806f2adf293c9c2d0870fb07667f251 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 2 Dec 2015 19:25:24 +0100 Subject: [PATCH] Changed: Add Anisotropic Filtering in game config options --- .../gamedev/interfaces_v3/game_config.xml | 41 ++++++++- .../src/interface_v3/action_handler_game.cpp | 90 +++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml index 614b85dbf..bd0952277 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -429,6 +429,9 @@ + @@ -1237,10 +1240,41 @@ posref="BL TL" x="0" y="-12" /> - + + + + + + + + VideoModes; #define GAME_CONFIG_TEXTURE_MODE_COMBO "ui:interface:game_config:content:general:texture_mode:combo" #define GAME_CONFIG_TEXTURE_MODE_DB "UI:TEMP:TEXTURE_MODE" +// Anisotropic Filtering controls +#define GAME_CONFIG_ANISOTROPIC_COMBO "ui:interface:game_config:content:fx:anisotropic_gr:anisotropic" +#define GAME_CONFIG_ANISOTROPIC_DB "UI:TEMP:ANISOTROPIC" + // The 3 possible modes editable (NB: do not allow client.cfg HDEntityTexture==1 and DivideTextureSizeBy2=2 enum TTextureMode {LowTextureMode= 0, NormalTextureMode= 1, HighTextureMode= 2}; @@ -3044,6 +3048,37 @@ public: pCB->addText(CI18N::get("uigcHighTextureMode")); } + // Anisotropic Filtering + pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_ANISOTROPIC_COMBO)); + + sint nAnisotropic = 0; + + if (pCB) + { + uint maxAnisotropic = Driver->getAnisotropicFilterMaximum(); + + pCB->resetTexts(); + pCB->addText(CI18N::get("uigcFxAnisotropicFilterNone")); + + uint anisotropic = 2; + uint i = 1; + + while (anisotropic <= maxAnisotropic) + { + pCB->addText(ucstring(NLMISC::toString("%ux", anisotropic))); + + if (ClientCfg.AnisotropicFilter == anisotropic) + nAnisotropic = i; + + anisotropic <<= 1; + ++i; + } + } + + // -1 is important to indicate we set this value in edit mode + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_ANISOTROPIC_DB )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_ANISOTROPIC_DB )->setValue32(nAnisotropic); + // VR_CONFIG pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); if (pBut) @@ -3481,6 +3516,34 @@ class CHandlerGameConfigApply : public IActionHandler } } + // **** Apply Anisotropic Filtering + sint nAnisotropic = NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_ANISOTROPIC_DB )->getValue32(); + + if (nAnisotropic >= 0) + { + uint anisotropic = 0; + + // compute the real anisotropic value + if (nAnisotropic > 0) + { + anisotropic = 1; + + for(size_t i = 0; i < nAnisotropic; ++i) + { + anisotropic <<= 1; + } + } + + + if (ClientCfg.AnisotropicFilter != anisotropic) + { + ClientCfg.AnisotropicFilter = anisotropic; + ClientCfg.writeInt("AnisotropicFilter", anisotropic); + requestReboot = true; + } + } + + // *** Apply the Screen AR // since already set in the config file, need only to bkup the current version CHandlerGameConfigInit::BkupScreenAspectRatio= ClientCfg.ScreenAspectRatio; @@ -3597,6 +3660,33 @@ class CHandlerGameConfigChangeScreenRatioMode : public IActionHandler REGISTER_ACTION_HANDLER (CHandlerGameConfigChangeScreenRatioMode, "game_config_change_screen_ratio_mode"); +// *************************************************************************** +class CHandlerGameConfigChangeAnisotropic : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) + { + if (CInterfaceLink::isUpdatingAllLinks()) return; // don't want to trash the value in client.cfg at init, due to 'updateAllLinks' being called + + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + + // get values of anisotropic filtering + sint oldAnisotropic = NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_ANISOTROPIC_DB)->getOldValue32(); + sint anisotropic = NLGUI::CDBManager::getInstance()->getDbProp(GAME_CONFIG_ANISOTROPIC_DB)->getValue32(); + + // dirt the apply button of the DDX. + // don't do it at init! + if(oldAnisotropic != anisotropic && oldAnisotropic != -1 && anisotropic != -1) + { + CDDXManager *pDM = CDDXManager::getInstance(); + CInterfaceDDX *pDDX = pDM->get(GAME_CONFIG_DDX); + if(pDDX) + pDDX->validateApplyButton(); + } + } +}; +REGISTER_ACTION_HANDLER (CHandlerGameConfigChangeAnisotropic, "game_config_change_anisotropic"); + + // *************************************************************************** class CHandlerGameConfigChangeScreenRatioCustom : public IActionHandler {