diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-05-21 21:56:41 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-05-21 21:56:41 +0200 |
commit | 63b4c9869b6256ed7644113cd23305b07cf9df03 (patch) | |
tree | aff0d99f5b58cbaf4195ac755ecfb79f97bf7b65 /src/gui/setup_video.cpp | |
parent | 8c4c5a58c256cce7beb21b68c8a7d6b6ff5c4a3a (diff) | |
parent | 2953a3f92c5097bd99ff21f4536fe167a32d90c5 (diff) | |
download | mana-63b4c9869b6256ed7644113cd23305b07cf9df03.tar.gz mana-63b4c9869b6256ed7644113cd23305b07cf9df03.tar.bz2 mana-63b4c9869b6256ed7644113cd23305b07cf9df03.tar.xz mana-63b4c9869b6256ed7644113cd23305b07cf9df03.zip |
Merge branch '1.0'
Conflicts:
src/beingmanager.cpp
src/beingmanager.h
src/client.cpp
src/localplayer.cpp
Diffstat (limited to 'src/gui/setup_video.cpp')
-rw-r--r-- | src/gui/setup_video.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 8ce6eebd..ebe53261 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -81,6 +81,13 @@ class ModeListModel : public gcn::ListModel */ std::string getElementAt(int i) { return mVideoModes[i]; } + /** + * Returns the index corresponding to the given video mode. + * E.g.: "800x600". + * or -1 if not found. + */ + int getIndexOf(const std::string &widthXHeightMode); + private: std::vector<std::string> mVideoModes; }; @@ -108,6 +115,20 @@ ModeListModel::ModeListModel() } } +int ModeListModel::getIndexOf(const std::string &widthXHeightMode) +{ + std::string currentMode = ""; + for (int i = 0; i < getNumberOfElements(); i++) + { + currentMode = getElementAt(i); + if (currentMode == widthXHeightMode) + { + return i; + } + } + return -1; +} + const char *SIZE_NAME[4] = { N_("Tiny"), @@ -256,6 +277,11 @@ Setup_Video::Setup_Video(): mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setSelected(mFps > 0); + // Pre-select the current video mode. + std::string videoMode = toString(graphics->getWidth()) + "x" + + toString(graphics->getHeight()); + mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); + mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mShowMonsterDamageCheckBox->setActionEventId("monsterdamage"); @@ -462,6 +488,14 @@ void Setup_Video::cancel() mFpsLabel->setCaption(text); config.setValue("screen", mFullScreenEnabled); + + // Set back to the current video mode. + std::string videoMode = toString(graphics->getWidth()) + "x" + + toString(graphics->getHeight()); + mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); + config.setValue("screenwidth", graphics->getWidth()); + config.setValue("screenheight", graphics->getHeight()); + config.setValue("customcursor", mCustomCursorEnabled); config.setValue("showMonstersTakedDamage", mShowMonsterDamageEnabled); config.setValue("visiblenames", mVisibleNamesEnabled); |