Store resolution as value instead of id on the list, closes #417

Also fixed a bug where after starting the game for the first time the "Apply changes" button would behave like you selected highest resolution possible (while the game is running at 800x600)
master
krzys-h 2015-03-19 19:42:01 +01:00
parent bb9e490316
commit f43acaa943
2 changed files with 43 additions and 10 deletions

View File

@ -499,12 +499,28 @@ bool CApplication::Create()
if(!m_headless) {
// load settings from profile
int iValue;
if ( GetProfile().GetIntProperty("Setup", "Resolution", iValue) && !m_resolutionOverride )
std::string sValue;
if ( GetProfile().GetStringProperty("Setup", "Resolution", sValue) && !m_resolutionOverride )
{
std::istringstream resolution(sValue);
std::string ws, hs;
std::getline(resolution, ws, 'x');
std::getline(resolution, hs, 'x');
int w = 800, h = 600;
if(!ws.empty() && !hs.empty()) {
w = atoi(ws.c_str());
h = atoi(hs.c_str());
}
// Why not just set m_deviceConfig.size to w,h? Because this way if the resolution is no longer supported (e.g. changimg monitor) defaults will be used instead
std::vector<Math::IntPoint> modes;
GetVideoResolutionList(modes, true, true);
if (static_cast<unsigned int>(iValue) < modes.size())
m_deviceConfig.size = modes.at(iValue);
for(auto it = modes.begin(); it != modes.end(); ++it) {
if(it->x == w && it->y == h) {
m_deviceConfig.size = *it;
break;
}
}
}
if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) && !m_resolutionOverride )

View File

@ -5034,13 +5034,13 @@ void CMainDialog::SetupMemorize()
pl = static_cast<CList *>(pw->SearchControl(EVENT_LIST2));
if ( pl != 0 )
{
GetProfile().SetIntProperty("Setup", "Resolution", m_setupSelMode);
std::vector<Math::IntPoint> modes;
m_app->GetVideoResolutionList(modes, true, true);
std::ostringstream ss;
ss << modes[m_setupSelMode].x << "x" << modes[m_setupSelMode].y;
GetProfile().SetStringProperty("Setup", "Resolution", ss.str());
}
}
else
{
// TODO: Default value
}
GetProfile().SetStringProperty("Setup", "KeyMap", CInput::GetInstancePointer()->SaveKeyBindings());
@ -5261,9 +5261,26 @@ void CMainDialog::SetupRecall()
m_bDeleteGamer = iValue;
}
if ( GetProfile().GetIntProperty("Setup", "Resolution", iValue) )
if ( GetProfile().GetStringProperty("Setup", "Resolution", key) )
{
m_setupSelMode = iValue;
std::istringstream resolution(key);
std::string ws, hs;
std::getline(resolution, ws, 'x');
std::getline(resolution, hs, 'x');
int w = 800, h = 600;
if(!ws.empty() && !hs.empty()) {
w = atoi(ws.c_str());
h = atoi(hs.c_str());
}
std::vector<Math::IntPoint> modes;
m_app->GetVideoResolutionList(modes, true, true);
for(auto it = modes.begin(); it != modes.end(); ++it) {
if(it->x == w && it->y == h) {
m_setupSelMode = it - modes.begin();
break;
}
}
}
if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) )