summaryrefslogtreecommitdiff
path: root/src/gui/setup_video.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-21 22:18:08 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-21 22:18:08 +0300
commit109a9a97e598f10e673fc235000bcec415fe047d (patch)
tree6ddc0f51d31ca939f99aff59568dfde7a74fe7f5 /src/gui/setup_video.cpp
parent797d0ffbe3cb1871adc9c9bd0b315655f1973c74 (diff)
downloadmanaverse-109a9a97e598f10e673fc235000bcec415fe047d.tar.gz
manaverse-109a9a97e598f10e673fc235000bcec415fe047d.tar.bz2
manaverse-109a9a97e598f10e673fc235000bcec415fe047d.tar.xz
manaverse-109a9a97e598f10e673fc235000bcec415fe047d.zip
Add hardcoded modes to video modes list in settings.
Diffstat (limited to 'src/gui/setup_video.cpp')
-rw-r--r--src/gui/setup_video.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 59f3ccf34..d007bc275 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -53,6 +53,7 @@
#include <SDL.h>
+#include <algorithm>
#include <string>
#include <vector>
@@ -99,9 +100,33 @@ class ModeListModel : public gcn::ListModel
int getIndexOf(const std::string &widthXHeightMode);
private:
+ void addCustomMode(std::string mode);
+
std::vector<std::string> mVideoModes;
};
+bool modeSorter(std::string mode1, std::string mode2);
+
+bool modeSorter(std::string mode1, std::string mode2)
+{
+ const int width1 = atoi(mode1.substr(0, mode1.find("x")).c_str());
+ const int height1 = atoi(mode1.substr(mode1.find("x") + 1).c_str());
+ if (!width1 || !height1)
+ return false;
+
+ const int width2 = atoi(mode2.substr(0, mode2.find("x")).c_str());
+ const int height2 = atoi(mode2.substr(mode2.find("x") + 1).c_str());
+ if (!width2 || !height2)
+ return false;
+ if (width1 != width2)
+ return width1 < width2;
+
+ if (height1 != height2)
+ return height1 < height2;
+
+ return false;
+}
+
ModeListModel::ModeListModel()
{
/* Get available fullscreen/hardware modes */
@@ -126,9 +151,32 @@ ModeListModel::ModeListModel()
mVideoModes.push_back(modeString);
}
}
+ addCustomMode("640x480");
+ addCustomMode("800x600");
+ addCustomMode("1024x768");
+ addCustomMode("1280x1024");
+ addCustomMode("1400x900");
+ addCustomMode("1500x990");
+ addCustomMode(toString(graphics->getWidth()) + "x"
+ + toString(graphics->getHeight()));
+
+ std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter);
mVideoModes.push_back("custom");
}
+void ModeListModel::addCustomMode(std::string mode)
+{
+ std::vector<std::string>::iterator it = mVideoModes.begin();
+ std::vector<std::string>::iterator it_end = mVideoModes.end();
+ while (it != it_end)
+ {
+ if (*it == mode)
+ return;
+ ++ it;
+ }
+ mVideoModes.push_back(mode);
+}
+
int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
{
std::string currentMode = "";