summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertram <yohanndotferreiraatorange.fr>2010-04-25 21:35:52 +0200
committerBertram <yohanndotferreiraatorange.fr>2010-04-25 21:51:20 +0200
commitf07260b4a1c43611c0839b5adf735a2c13ad8348 (patch)
treee727a8bec0b956f6124d8b0da8d7d096cf6e7034
parent7070be634b756cb98659cd788d64ef8a912b1858 (diff)
downloadmana-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.gz
mana-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.bz2
mana-f07260b4a1c43611c0839b5adf735a2c13ad8348.tar.xz
mana-f07260b4a1c43611c0839b5adf735a2c13ad8348.zip
Fixed the VideoMode listBox logic in the setup window.
Reviewed by: Jaxad0127
-rw-r--r--src/gui/setup_video.cpp34
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);