[colobot] 275/390: Store resolution as value instead of id on the list, closes #417
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:21:54 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit f43acaa94393ebe145b2c8a6b7e6456d116ec0fb
Author: krzys-h <krzys_h at interia.pl>
Date: Thu Mar 19 19:42:01 2015 +0100
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)
---
src/app/app.cpp | 22 +++++++++++++++++++---
src/ui/maindialog.cpp | 31 ++++++++++++++++++++++++-------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 42e4a07..d0e783d 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<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 )
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 40bec52..aeccc0f 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -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) )
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list