Changed: Add Anisotropic Filtering in game config options

This commit is contained in:
kervala 2015-12-02 19:25:24 +01:00
parent 3e316cfdfd
commit e35db6756d
2 changed files with 130 additions and 1 deletions
code/ryzom/client
data/gamedev/interfaces_v3
src/interface_v3

View file

@ -429,6 +429,9 @@
<variable entry="UI:TEMP:PRESET_FX"
type="sint32"
value="0" />
<variable entry="UI:TEMP:ANISOTROPIC"
type="sint32"
value="0" />
<variable entry="UI:TEMP:VR_DEVICE"
type="sint32"
value="0" />
@ -1237,10 +1240,41 @@
posref="BL TL"
x="0"
y="-12" />
<group id="bloom_gr"
<group id="anisotropic_gr"
posparent="fxaa"
sizeparent="parent"
sizeref="w"
h="20"
posref="BL TL"
x="0"
y="-12">
<view type="text"
id="text"
posref="TL TL"
x="0"
y="-4"
color="255 255 255 192"
fontsize="12"
shadow="true"
hardtext="uigcFxAnisotropicFilter" />
<group type="combo_box"
id="anisotropic"
w="70"
h="20"
value="UI:TEMP:ANISOTROPIC"
posref="MR ML"
posparent="text"
x="4"
y="0">
<instance template="combo_box_def1" />
</group>
<link expr="@UI:TEMP:ANISOTROPIC"
action="game_config_change_anisotropic" />
</group>
<group id="bloom_gr"
posparent="anisotropic_gr"
sizeparent="parent"
sizeref="w"
h="100"
posref="BL TL"
x="0"
@ -3146,6 +3180,11 @@
realtime="true"
link="FXAA"
preset="UI:TEMP:PRESET_FX" />
<param ui="fx:anisotropic_gr:anisotropic:c"
type="db"
widget="boolbut"
realtime="true"
link="UI:TEMP:ANISOTROPIC" />
<param ui="fx:bloom_gr:bloom:c"
type="cfg"
widget="boolbut"

View file

@ -2933,6 +2933,10 @@ static vector<UDriver::CMode> 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<CDBGroupComboBox*>(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<CCtrlBaseButton*>(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
{