From d39c6b8e1ba65f28dd2a55afec88df7fed6865f1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 15 Sep 2013 02:14:38 +0200 Subject: [PATCH] Cleanup vr config interface --- .../gamedev/interfaces_v3/game_config.xml | 42 ++++++++++++----- .../src/interface_v3/action_handler_game.cpp | 46 +++++++++++++++++-- code/ryzom/client/src/main_loop_utilities.cpp | 32 +++++-------- 3 files changed, 84 insertions(+), 36 deletions(-) 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 ad5060a81..5e9072b93 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -2762,12 +2762,37 @@ x="0" y="0" hardtext="uiVRGeneral" /> - + + + + - VideoModes; #define GAME_CONFIG_VIDEO_DEPTH_REQ 32 // VR_CONFIG +#define GAME_CONFIG_VR_ENABLE_BUTTON "ui:interface:game_config:content:vr:enabler:c" #define GAME_CONFIG_VR_DEVICES_COMBO "ui:interface:game_config:content:vr:vr_devices" #define GAME_CONFIG_VR_DEVICE_DB "UI:TEMP:VR_DEVICE" @@ -2934,7 +2935,7 @@ enum TTextureMode {LowTextureMode= 0, NormalTextureMode= 1, HighTextureMode= 2}; void cacheStereoDisplayDevices(); // from init.cpp -void updateVRDevicesComboUI() +void updateVRDevicesComboUI(bool enable) { // VR_CONFIG nldebug("Init VR device name list from cache into UI"); @@ -2942,8 +2943,8 @@ void updateVRDevicesComboUI() CDBGroupComboBox *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_DEVICES_COMBO)); if (pCB) { - pCB->setActive(ClientCfg.VREnable); - if (ClientCfg.VREnable) + pCB->setActive(enable); + if (enable) { nldebug("pCB ok"); cacheStereoDisplayDevices(); @@ -3026,7 +3027,12 @@ public: } // VR_CONFIG - updateVRDevicesComboUI(); + pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); + if (pBut) + { + pBut->setPushed(ClientCfg.VREnable); + } + updateVRDevicesComboUI(ClientCfg.VREnable); // init the mode in DB TTextureMode texMode; @@ -3257,6 +3263,31 @@ class CHandlerGameConfigFullscreen : public IActionHandler }; REGISTER_ACTION_HANDLER (CHandlerGameConfigFullscreen, "game_config_change_vid_fullscreen"); +// *************************************************************************** +class CHandlerGameConfigVREnable : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &/* Params */) + { + // VR_CONFIG + + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); + if (pBut) + { + // hide or show device list depending on enabled or not + updateVRDevicesComboUI(pBut->getPushed()); + } + + if (pCaller) + { + CDDXManager *pDM = CDDXManager::getInstance(); + CInterfaceDDX *pDDX = pDM->get(GAME_CONFIG_DDX); + if(pDDX) + pDDX->validateApplyButton(); + } + } +}; +REGISTER_ACTION_HANDLER (CHandlerGameConfigVREnable, "game_config_change_vr_enable"); + // *************************************************************************** class CHandlerGameConfigVRDevice : public IActionHandler { @@ -3373,6 +3404,13 @@ class CHandlerGameConfigApply : public IActionHandler } } + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GAME_CONFIG_VR_ENABLE_BUTTON)); + if (pBut) + { + // store the new config variables + ClientCfg.VREnable = pBut->getPushed(); + ClientCfg.writeBool("VREnable", pBut->getPushed()); + } if (ClientCfg.VREnable) { // store the new config variables diff --git a/code/ryzom/client/src/main_loop_utilities.cpp b/code/ryzom/client/src/main_loop_utilities.cpp index e7b9a3d27..bca1ccad2 100644 --- a/code/ryzom/client/src/main_loop_utilities.cpp +++ b/code/ryzom/client/src/main_loop_utilities.cpp @@ -49,6 +49,17 @@ void updateFromClientCfg() { CClientConfig::setValues(); ClientCfg.IsInvalidated = false; + + if ((ClientCfg.VREnable != LastClientCfg.VREnable) + || (ClientCfg.VREnable && ( + ClientCfg.VRDisplayDevice != LastClientCfg.VRDisplayDevice + || ClientCfg.VRDisplayDeviceId != LastClientCfg.VRDisplayDeviceId + ))) + { + nldebug("Apply VR device change"); + releaseStereoDisplayDevice(); + initStereoDisplayDevice(); + } // GRAPHICS - GENERAL //--------------------------------------------------- @@ -79,27 +90,6 @@ void updateFromClientCfg() Driver->setSwapVBLInterval(0); } - if (ClientCfg.VREnable != LastClientCfg.VREnable) - { - // VR_CONFIG - - // switch visibility of list & reload - updateVRDevicesComboUI(); - } - else - { - if (((StereoDisplay != NULL) != ClientCfg.VREnable) - || (ClientCfg.VREnable && ( - ClientCfg.VRDisplayDevice != LastClientCfg.VRDisplayDevice - || ClientCfg.VRDisplayDeviceId != LastClientCfg.VRDisplayDeviceId - ))) - { - nldebug("Apply VR device change"); - releaseStereoDisplayDevice(); - initStereoDisplayDevice(); - } - } - // GRAPHICS - LANDSCAPE //--------------------------------------------------- if (ClientCfg.LandscapeThreshold != LastClientCfg.LandscapeThreshold)