mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-24 17:58:45 +00:00
Fixed: Didn't initialize video modes frequencies
This commit is contained in:
parent
d0c869c64f
commit
ceac8b3918
4 changed files with 57 additions and 13 deletions
|
@ -2990,12 +2990,15 @@ public:
|
|||
if (Driver == NULL) return;
|
||||
|
||||
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
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
|
||||
// resolutions
|
||||
CDBGroupComboBox *pCB= dynamic_cast<CDBGroupComboBox*>(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<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
|
||||
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<CCtrlBaseButton*>(CWidgetManager::getInstance()->getElementFromId( GAME_CONFIG_VIDEO_FULLSCREEN_BUTTON ));
|
||||
if (pBut)
|
||||
{
|
||||
|
|
|
@ -1945,7 +1945,10 @@ class CAHInitResLod : public IActionHandler
|
|||
VideoModes.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
|
||||
StringModeList.insert(StringModeList.begin(), "uiConfigWindowed");
|
||||
|
|
|
@ -1392,12 +1392,19 @@ bool isWindowMaximized()
|
|||
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
|
||||
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<NL3D::UDriver::CMode> &videoModes, std::vector<st
|
|||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (stringModeList[j] == tmp)
|
||||
if (stringModeList[j] == res)
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
|
@ -1419,7 +1426,8 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
|
|||
}
|
||||
if (!bFound)
|
||||
{
|
||||
stringModeList.push_back(tmp);
|
||||
stringModeList.push_back(res);
|
||||
|
||||
if ((videoModes[i].Width <= ClientCfg.Width) && (videoModes[i].Height <= ClientCfg.Height))
|
||||
{
|
||||
if (nFoundMode == -1)
|
||||
|
@ -1436,14 +1444,32 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
ClientCfg.Windowed = true;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ uint getCurrentColorDepth();
|
|||
bool isWindowMaximized();
|
||||
|
||||
// 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
|
||||
|
||||
|
|
Loading…
Reference in a new issue