summaryrefslogtreecommitdiff
path: root/src/gui/setup_video.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/setup_video.cpp')
-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);