From b20b11d9aab91df6860ca7de0fb50eac2b42e4f6 Mon Sep 17 00:00:00 2001 From: kervala Date: Thu, 5 Nov 2015 17:22:43 +0100 Subject: [PATCH] Fixed: Didn't initialize video modes frequencies --- .../src/interface_v3/action_handler_game.cpp | 21 ++++++++-- code/ryzom/client/src/login.cpp | 5 ++- code/ryzom/client/src/misc.cpp | 42 +++++++++++++++---- code/ryzom/client/src/misc.h | 2 +- 4 files changed, 57 insertions(+), 13 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index b76bbce21..ca0860c11 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -2990,12 +2990,15 @@ public: if (Driver == NULL) return; VideoModes.clear(); - vector stringModeList; + vector stringModeList, stringFreqList; + sint nFoundMode, nFoundFreq; - sint nFoundMode = getRyzomModes(VideoModes, stringModeList); + getRyzomModes(VideoModes, stringModeList, stringFreqList, nFoundMode, nFoundFreq); // Initialize interface combo box CInterfaceManager *pIM = CInterfaceManager::getInstance(); + + // resolutions CDBGroupComboBox *pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); if( pCB ) { @@ -3003,11 +3006,23 @@ public: for (sint j = 0; j < (sint)stringModeList.size(); j++) pCB->addText(ucstring(stringModeList[j])); } + + // frequencies + pCB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FREQS_COMBO )); + if( pCB ) + { + pCB->resetTexts(); + for (sint j = 0; j < (sint)stringFreqList.size(); j++) + pCB->addText(ucstring(stringFreqList[j])); + } + // -1 is important to indicate we set this value in edit mode NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(-1); - NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(-1); NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_MODE_DB )->setValue32(nFoundMode); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(-1); + NLGUI::CDBManager::getInstance()->getDbProp( GAME_CONFIG_VIDEO_FREQ_DB )->setValue32(nFoundFreq); + CCtrlBaseButton *pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); if (pBut) { diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 091e24a80..8d98d9fb6 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -1945,7 +1945,10 @@ class CAHInitResLod : public IActionHandler VideoModes.clear(); StringModeList.clear(); - CurrentMode = getRyzomModes(VideoModes, StringModeList); + std::vector stringFreqList; + sint currentFreq; + + getRyzomModes(VideoModes, StringModeList, stringFreqList, CurrentMode, currentFreq); // getRyzomModes() expects empty list, so we need to insert 'Windowed' after mode list is filled StringModeList.insert(StringModeList.begin(), "uiConfigWindowed"); diff --git a/code/ryzom/client/src/misc.cpp b/code/ryzom/client/src/misc.cpp index 7e018a576..0deb4b518 100644 --- a/code/ryzom/client/src/misc.cpp +++ b/code/ryzom/client/src/misc.cpp @@ -1392,12 +1392,19 @@ bool isWindowMaximized() screenMode.Width == width && screenMode.Height == height); } -sint getRyzomModes(std::vector &videoModes, std::vector &stringModeList) +bool getRyzomModes(std::vector &videoModes, std::vector &stringModeList, std::vector &stringFreqList, sint &nFoundStringMode, sint &nFoundStringFreq) { + // default values + nFoundStringMode = -1; + nFoundStringFreq = -1; + + // mode index in original video modes + sint nFoundMode = -1; + // **** Init Video Modes Driver->getModes(videoModes); // Remove modes under 800x600 and get the unique strings - sint i, j, nFoundMode = -1; + sint i, j; for (i=0; i < (sint)videoModes.size(); ++i) { if ((videoModes[i].Width < 800) || (videoModes[i].Height < 600)) @@ -1408,10 +1415,10 @@ sint getRyzomModes(std::vector &videoModes, std::vector &videoModes, std::vector &videoModes, std::vector 0 && freq == ClientCfg.Frequency) + { + nFoundStringFreq = stringFreqList.size(); + } + + stringFreqList.push_back(toString(freq)); + } + } + } + + return nFoundStringMode > -1; } diff --git a/code/ryzom/client/src/misc.h b/code/ryzom/client/src/misc.h index 7fba7204c..d7b86755d 100644 --- a/code/ryzom/client/src/misc.h +++ b/code/ryzom/client/src/misc.h @@ -228,7 +228,7 @@ uint getCurrentColorDepth(); bool isWindowMaximized(); // get all supported video modes -sint getRyzomModes(std::vector &videoModes, std::vector &stringModeList); +bool getRyzomModes(std::vector &videoModes, std::vector &stringModeList, std::vector &stringFreqList, sint &nFoundMode, sint &nFoundFreq); #endif // CL_MISC_H