diff --git a/src/app/app.cpp b/src/app/app.cpp index 42e4a074..d0e783dc 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -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 modes; GetVideoResolutionList(modes, true, true); - if (static_cast(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 ) diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 40bec525..aeccc0f9 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -5034,13 +5034,13 @@ void CMainDialog::SetupMemorize() pl = static_cast(pw->SearchControl(EVENT_LIST2)); if ( pl != 0 ) { - GetProfile().SetIntProperty("Setup", "Resolution", m_setupSelMode); + std::vector 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 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) )