diff options
author | Bertram <yohanndotferreiraatorange.fr> | 2010-04-25 21:35:52 +0200 |
---|---|---|
committer | Bertram <yohanndotferreiraatorange.fr> | 2010-04-25 21:51:20 +0200 |
commit | f07260b4a1c43611c0839b5adf735a2c13ad8348 (patch) | |
tree | e727a8bec0b956f6124d8b0da8d7d096cf6e7034 /src | |
parent | 7070be634b756cb98659cd788d64ef8a912b1858 (diff) | |
download | mana-client-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.gz mana-client-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.bz2 mana-client-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.xz mana-client-f07260b4a1c43611c0839b5adf735a2c13ad8348.zip |
Fixed the VideoMode listBox logic in the setup window.
Reviewed by: Jaxad0127
Diffstat (limited to 'src')
-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); |