diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-28 00:30:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-28 23:35:20 +0300 |
commit | a0b2deb4192bddad4d061f5d5df86411a437f01f (patch) | |
tree | 4739472959d83045eac4d7f7ddf3dc265d37b45c /src/gui | |
parent | 226202ff807dc860991af0d6665ef9e9b48c1bed (diff) | |
download | plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.gz plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.bz2 plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.xz plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.zip |
add support for screen scale in OpenGL modes.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 6 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 47 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_video.cpp | 32 |
3 files changed, 54 insertions, 31 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index d016c0aa3..dcd4d82ea 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -942,5 +942,9 @@ void Gui::removeDragged(gcn::Widget *widget) uint32_t Gui::getMouseState(int *const x, int *const y) const { - return SDL_GetMouseState(x, y); + const uint32_t res = SDL_GetMouseState(x, y); + const int scale = mainGraphics->getScale(); + (*x) /= scale; + (*y) /= scale; + return res; } diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 653806491..193a35dfe 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -81,6 +81,8 @@ #include "input/inputmanager.h" +#include "render/graphics.h" + #ifdef USE_SDL2 #include "gui/gui.h" #endif @@ -210,14 +212,19 @@ void SDLInput::pushInput(const SDL_Event &event) #endif case SDL_MOUSEBUTTONDOWN: + { mMouseDown = true; - mouseInput.setX(event.button.x); - mouseInput.setY(event.button.y); + const int scale = mainGraphics->getScale(); + const int x = event.button.x / scale; + const int y = event.button.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.button.x, event.button.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.button.realx, event.button.realy); + mouseInput.setReal(event.button.realx / scale, + event.button.realy / scale); #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); @@ -233,16 +240,21 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } case SDL_MOUSEBUTTONUP: + { mMouseDown = false; - mouseInput.setX(event.button.x); - mouseInput.setY(event.button.y); + const int scale = mainGraphics->getScale(); + const int x = event.button.x / scale; + const int y = event.button.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.button.x, event.button.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.button.realx, event.button.realy); + mouseInput.setReal(event.button.realx / scale, + event.button.realy / scale); #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); @@ -250,15 +262,20 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } case SDL_MOUSEMOTION: - mouseInput.setX(event.motion.x); - mouseInput.setY(event.motion.y); + { + const int scale = mainGraphics->getScale(); + const int x = event.motion.x / scale; + const int y = event.motion.y / scale; + mouseInput.setX(x); + mouseInput.setY(y); #ifdef ANDROID #ifdef USE_SDL2 - mouseInput.setReal(event.motion.x, event.motion.y); + mouseInput.setReal(x, y); #else - mouseInput.setReal(event.motion.realx, event.motion.realy); + mouseInput.setReal(event.motion.realx / scale, + event.motion.realy / scale); #endif #endif mouseInput.setButton(gcn::MouseInput::EMPTY); @@ -266,7 +283,7 @@ void SDLInput::pushInput(const SDL_Event &event) mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; - + } #ifndef USE_SDL2 case SDL_ACTIVEEVENT: /* diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index feebb774a..c977318e6 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -122,8 +122,8 @@ ModeListModel::ModeListModel() : addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(mainGraphics->mWidth).append("x") - .append(toString(mainGraphics->mHeight))); + addCustomMode(toString(mainGraphics->mActualWidth).append("x") + .append(toString(mainGraphics->mActualHeight))); std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter); mVideoModes.push_back("custom"); @@ -243,8 +243,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - const std::string videoMode = toString(mainGraphics->mWidth).append("x") - .append(toString(mainGraphics->mHeight)); + const std::string videoMode = toString( + mainGraphics->mActualWidth).append("x").append( + toString(mainGraphics->mActualHeight)); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -428,11 +429,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(mainGraphics->mWidth).append("x") - .append(toString(mainGraphics->mHeight)); + std::string videoMode = toString(mainGraphics->mActualWidth).append("x") + .append(toString(mainGraphics->mActualHeight)); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", mainGraphics->mWidth); - config.setValue("screenheight", mainGraphics->mHeight); + config.setValue("screenwidth", mainGraphics->mActualWidth); + config.setValue("screenheight", mainGraphics->mActualHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("opengl", static_cast<int>(mOpenGLEnabled)); @@ -474,18 +475,19 @@ void Setup_Video::action(const gcn::ActionEvent &event) if (!width || !height) return; - if (width != mainGraphics->mWidth || height != mainGraphics->mHeight) + if (width != mainGraphics->mActualWidth + || height != mainGraphics->mActualHeight) { #if defined(WIN32) || defined(__APPLE__) || defined(ANDROID) if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE) { - client->resizeVideo(width, height); + client->resizeVideo(width, height, false); } else { - if (width < mainGraphics->mWidth - || height < mainGraphics->mHeight) + if (width < mainGraphics->mActualWidth + || height < mainGraphics->mActualHeight) { // TRANSLATORS: video settings warning new OkDialog(_("Screen Resolution Changed"), @@ -505,13 +507,13 @@ void Setup_Video::action(const gcn::ActionEvent &event) } #else mainGraphics->setWindowSize(width, height); - client->resizeVideo(width, height); + client->resizeVideo(width, height, false); #endif } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", mainGraphics->mWidth); - config.setValue("oldscreenheight", mainGraphics->mHeight); + config.setValue("oldscreenwidth", mainGraphics->mActualWidth); + config.setValue("oldscreenheight", mainGraphics->mActualHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } |