summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-01 14:41:34 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-01 14:53:49 +0300
commit222748a7e0c79225c66485898b913aa60f56cfe2 (patch)
tree38e27f08cec39bf8cca26df8caade81c112245e8 /src/gui
parentf4df2a0fd2d9c01b6f756c4b00ed9848f319a1b0 (diff)
downloadmanaverse-222748a7e0c79225c66485898b913aa60f56cfe2.tar.gz
manaverse-222748a7e0c79225c66485898b913aa60f56cfe2.tar.bz2
manaverse-222748a7e0c79225c66485898b913aa60f56cfe2.tar.xz
manaverse-222748a7e0c79225c66485898b913aa60f56cfe2.zip
add way to map render mode selection to actual modes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/setup_video.cpp62
-rw-r--r--src/gui/setup_video.h2
-rw-r--r--src/gui/widgets/widget2.h5
4 files changed, 24 insertions, 47 deletions
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 4f3d22463..fdd68092a 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -40,8 +40,6 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
-#include "render/renderers.h"
-
#include "resources/imagehelper.h"
#include "net/packetcounters.h"
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 594d5ff4d..f9a7535d0 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -45,6 +45,7 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/dropdown.h"
+#include "render/rendererslist.h"
#include "resources/image.h"
#include "utils/gettext.h"
@@ -164,20 +165,6 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
return -1;
}
-const char *OPENGL_NAME[4] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
-#ifndef ANDROID
- // TRANSLATORS: draw backend
- N_("Fast OpenGL"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
-#endif
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL"),
-};
-
class OpenGLListModel final : public gcn::ListModel
{
public:
@@ -185,11 +172,7 @@ public:
{ }
virtual int getNumberOfElements() override
-#ifdef ANDROID
- { return 2; }
-#else
- { return 4; }
-#endif
+ { return renderModesListSize; }
virtual std::string getElementAt(int i) override
{
@@ -203,7 +186,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
SetupTab(widget),
gcn::KeyListener(),
mFullScreenEnabled(config.getBoolValue("screen")),
- mOpenGLEnabled(config.getIntValue("opengl")),
+ mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
mModeListModel(new ModeListModel),
@@ -250,15 +233,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
scrollArea->setWidth(150);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
-#ifdef USE_OPENGL
-#ifdef ANDROID
- if (mOpenGLEnabled == 1 || mOpenGLEnabled == 2)
- mOpenGLEnabled = 3;
-#endif
- mOpenGLDropDown->setSelected(mOpenGLEnabled);
-#else
- mOpenGLDropDown->setSelected(0);
-#endif
+ mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
mModeList->setEnabled(true);
@@ -362,7 +337,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
// checks for opengl usage
- if (!config.getIntValue("opengl"))
+ if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
{
#endif
if (!mainGraphics->setFullscreen(fullscreen))
@@ -401,16 +376,15 @@ void Setup_Video::apply()
config.setValue("screen", fullscreen);
}
- int mode = mOpenGLDropDown->getSelected();
-#ifdef ANDROID
- if (mode == 1 || mode == 2)
- mode = 3;
-#endif
+ const int sel = mOpenGLDropDown->getSelected();
+ RenderType mode = RENDER_SOFTWARE;
+ if (sel >= 0 && static_cast<unsigned int>(sel) < sizeof(indexToRender))
+ mode = indexToRender[mOpenGLDropDown->getSelected()];
// OpenGL change
if (mode != mOpenGLEnabled)
{
- config.setValue("opengl", mode);
+ config.setValue("opengl", static_cast<int>(mode));
// OpenGL can currently only be changed by restarting, notify user.
// TRANSLATORS: video settings warning
@@ -436,7 +410,7 @@ void Setup_Video::apply()
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
- mOpenGLEnabled = config.getIntValue("opengl");
+ mOpenGLEnabled = intToRenderType(config.getIntValue("opengl"));
mEnableResize = config.getBoolValue("enableresize");
mNoFrame = config.getBoolValue("noframe");
}
@@ -445,7 +419,7 @@ void Setup_Video::cancel()
{
mFpsCheckBox->setSelected(mFps > 0);
mFsCheckBox->setSelected(mFullScreenEnabled);
- mOpenGLDropDown->setSelected(mOpenGLEnabled);
+ mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
mFpsSlider->setValue(mFps);
mFpsSlider->setEnabled(mFps > 0);
@@ -469,7 +443,7 @@ void Setup_Video::cancel()
config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("opengl", mOpenGLEnabled);
+ config.setValue("opengl", static_cast<int>(mOpenGLEnabled));
config.setValue("enableresize", mEnableResize);
config.setValue("noframe", mNoFrame);
}
@@ -510,7 +484,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (width != mainGraphics->mWidth || height != mainGraphics->mHeight)
{
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- if (!config.getIntValue("opengl"))
+ if (intToRenderType(config.getIntValue("opengl"))
+ == RENDER_SOFTWARE)
{
client->resizeVideo(width, height);
}
@@ -598,8 +573,11 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (test)
{
const int val = test->getConfig().getValueInt("opengl", -1);
- if (val >= 0 && val <= 3)
- mOpenGLDropDown->setSelected(val);
+ if (val >= 0 && static_cast<unsigned int>(val)
+ < sizeof(renderToIndex))
+ {
+ mOpenGLDropDown->setSelected(renderToIndex[val]);
+ }
delete test;
}
}
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 7974e8e3d..b7c54e2af 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -56,7 +56,7 @@ class Setup_Video final : public SetupTab, public gcn::KeyListener
private:
bool mFullScreenEnabled;
- int mOpenGLEnabled;
+ RenderType mOpenGLEnabled;
int mFps;
int mAltFps;
ModeListModel *mModeListModel;
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index 94cc7760e..9e164046b 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -21,9 +21,10 @@
#ifndef GUI_WIDGETS_WIDGET2_H
#define GUI_WIDGETS_WIDGET2_H
+#include "gui/gui.h"
#include "gui/theme.h"
-#include "gui/gui.h"
+#include "render/renderers.h"
class Widget2
{
@@ -94,6 +95,6 @@ class Widget2
gcn::Color mForegroundColor2;
};
-extern int openGLMode;
+extern RenderType openGLMode;
#endif // GUI_WIDGETS_WIDGET2_H