Fixed: Didn't initialize video modes frequencies

This commit is contained in:
kervala 2015-11-05 17:22:43 +01:00
parent 2f265295cc
commit b20b11d9aa
4 changed files with 57 additions and 13 deletions

View file

@ -2990,12 +2990,15 @@ public:
if (Driver == NULL) return; if (Driver == NULL) return;
VideoModes.clear(); VideoModes.clear();
vector<string> stringModeList; vector<string> stringModeList, stringFreqList;
sint nFoundMode, nFoundFreq;
sint nFoundMode = getRyzomModes(VideoModes, stringModeList); getRyzomModes(VideoModes, stringModeList, stringFreqList, nFoundMode, nFoundFreq);
// Initialize interface combo box // Initialize interface combo box
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
// resolutions
CDBGroupComboBox *pCB= dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO )); CDBGroupComboBox *pCB= dynamic_cast<CDBGroupComboBox*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_MODES_COMBO ));
if( pCB ) if( pCB )
{ {
@ -3003,11 +3006,23 @@ public:
for (sint j = 0; j < (sint)stringModeList.size(); j++) for (sint j = 0; j < (sint)stringModeList.size(); j++)
pCB->addText(ucstring(stringModeList[j])); pCB->addText(ucstring(stringModeList[j]));
} }
// frequencies
pCB= dynamic_cast<CDBGroupComboBox*>(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 // -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_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_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<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON )); CCtrlBaseButton *pBut = dynamic_cast<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON ));
if (pBut) if (pBut)
{ {

View file

@ -1945,7 +1945,10 @@ class CAHInitResLod : public IActionHandler
VideoModes.clear(); VideoModes.clear();
StringModeList.clear(); StringModeList.clear();
CurrentMode = getRyzomModes(VideoModes, StringModeList); std::vector<std::string> stringFreqList;
sint currentFreq;
getRyzomModes(VideoModes, StringModeList, stringFreqList, CurrentMode, currentFreq);
// getRyzomModes() expects empty list, so we need to insert 'Windowed' after mode list is filled // getRyzomModes() expects empty list, so we need to insert 'Windowed' after mode list is filled
StringModeList.insert(StringModeList.begin(), "uiConfigWindowed"); StringModeList.insert(StringModeList.begin(), "uiConfigWindowed");

View file

@ -1392,12 +1392,19 @@ bool isWindowMaximized()
screenMode.Width == width && screenMode.Height == height); screenMode.Width == width && screenMode.Height == height);
} }
sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList) bool getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList, std::vector<std::string> &stringFreqList, sint &nFoundStringMode, sint &nFoundStringFreq)
{ {
// default values
nFoundStringMode = -1;
nFoundStringFreq = -1;
// mode index in original video modes
sint nFoundMode = -1;
// **** Init Video Modes // **** Init Video Modes
Driver->getModes(videoModes); Driver->getModes(videoModes);
// Remove modes under 800x600 and get the unique strings // 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) for (i=0; i < (sint)videoModes.size(); ++i)
{ {
if ((videoModes[i].Width < 800) || (videoModes[i].Height < 600)) if ((videoModes[i].Width < 800) || (videoModes[i].Height < 600))
@ -1408,10 +1415,10 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
else else
{ {
bool bFound = false; bool bFound = false;
string tmp = toString(videoModes[i].Width)+" x "+toString(videoModes[i].Height); string res = toString(videoModes[i].Width)+" x "+toString(videoModes[i].Height);
for (j = 0; j < (sint)stringModeList.size(); ++j) for (j = 0; j < (sint)stringModeList.size(); ++j)
{ {
if (stringModeList[j] == tmp) if (stringModeList[j] == res)
{ {
bFound = true; bFound = true;
break; break;
@ -1419,7 +1426,8 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
} }
if (!bFound) if (!bFound)
{ {
stringModeList.push_back(tmp); stringModeList.push_back(res);
if ((videoModes[i].Width <= ClientCfg.Width) && (videoModes[i].Height <= ClientCfg.Height)) if ((videoModes[i].Width <= ClientCfg.Width) && (videoModes[i].Height <= ClientCfg.Height))
{ {
if (nFoundMode == -1) if (nFoundMode == -1)
@ -1438,12 +1446,30 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
} }
// If no modes are available, fallback to windowed mode // If no modes are available, fallback to windowed mode
if (nFoundMode == -1) if (nFoundStringMode == -1)
{ {
nlwarning("Mode %ux%u not found, fall back to windowed", (uint)ClientCfg.Width, (uint)ClientCfg.Height); nlwarning("Mode %ux%u not found, fall back to windowed", (uint)ClientCfg.Width, (uint)ClientCfg.Height);
ClientCfg.Windowed = true; ClientCfg.Windowed = true;
ClientCfg.writeInt("FullScreen", 0); ClientCfg.writeInt("FullScreen", 0);
} }
else
{
// add frequencies to frequencies list
for (i=0; i < (sint)videoModes.size(); ++i)
{
if (videoModes[i].Width == videoModes[nFoundMode].Width && videoModes[i].Height == videoModes[nFoundMode].Height)
{
uint freq = videoModes[i].Frequency;
return nFoundMode; if (ClientCfg.Frequency > 0 && freq == ClientCfg.Frequency)
{
nFoundStringFreq = stringFreqList.size();
}
stringFreqList.push_back(toString(freq));
}
}
}
return nFoundStringMode > -1;
} }

View file

@ -228,7 +228,7 @@ uint getCurrentColorDepth();
bool isWindowMaximized(); bool isWindowMaximized();
// get all supported video modes // get all supported video modes
sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList); bool getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList, std::vector<std::string> &stringFreqList, sint &nFoundMode, sint &nFoundFreq);
#endif // CL_MISC_H #endif // CL_MISC_H