diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-12 23:10:37 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-07-12 23:10:37 +0200 |
commit | 55fc460429899df2d976a11d4521eb2f6ab56367 (patch) | |
tree | 7cecc9f16227dc31a46b3d043a7f356eb8d16f63 /src/gui | |
parent | 6fb4a7f6e0b793a0d3033e1ffdc31c115c8313eb (diff) | |
download | mana-client-55fc460429899df2d976a11d4521eb2f6ab56367.tar.gz mana-client-55fc460429899df2d976a11d4521eb2f6ab56367.tar.bz2 mana-client-55fc460429899df2d976a11d4521eb2f6ab56367.tar.xz mana-client-55fc460429899df2d976a11d4521eb2f6ab56367.zip |
Implemented scaling in OpenGL mode
The screen will be scaled up as much as possible, while keeping a
minimum 'virtual' resolution of 640x360.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/equipmentwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/gui.cpp | 3 | ||||
-rw-r--r-- | src/gui/sdlinput.cpp | 15 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 7 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 85a4c766..9df8c98c 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -254,6 +254,9 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event) int mouseX, mouseY; SDL_GetMouseState(&mouseX, &mouseY); + mouseX /= graphics->getScale(); + mouseY /= graphics->getScale(); + // Show ItemTooltip std::string slotName = getSlotName(x, y); if (!slotName.empty()) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 78fc42fb..e6e61f64 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -205,6 +205,9 @@ void Gui::draw() int mouseX, mouseY; Uint8 button = SDL_GetMouseState(&mouseX, &mouseY); + mouseX /= graphics->getScale(); + mouseY /= graphics->getScale(); + if ((Client::hasMouseFocus() || button & SDL_BUTTON(1)) && mCustomCursor && mMouseCursorAlpha > 0.0f) diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 4ccb7580..46636d52 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -60,6 +60,8 @@ #include <guichan/exception.hpp> +#include "graphics.h" + SDLInput::SDLInput() { mMouseInWindow = true; @@ -73,14 +75,12 @@ bool SDLInput::isKeyQueueEmpty() gcn::KeyInput SDLInput::dequeueKeyInput() { - gcn::KeyInput keyInput; - if (mKeyInputQueue.empty()) { throw GCN_EXCEPTION("The queue is empty."); } - keyInput = mKeyInputQueue.front(); + gcn::KeyInput keyInput = mKeyInputQueue.front(); mKeyInputQueue.pop(); return keyInput; @@ -93,16 +93,19 @@ bool SDLInput::isMouseQueueEmpty() gcn::MouseInput SDLInput::dequeueMouseInput() { - gcn::MouseInput mouseInput; - if (mMouseInputQueue.empty()) { throw GCN_EXCEPTION("The queue is empty."); } - mouseInput = mMouseInputQueue.front(); + gcn::MouseInput mouseInput = mMouseInputQueue.front(); mMouseInputQueue.pop(); + // Scale the mouse input by the graphics scale ratio + int scale = graphics->getScale(); + mouseInput.setX(mouseInput.getX() / scale); + mouseInput.setY(mouseInput.getY() / scale); + return mouseInput; } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1b5b00c3..0aab399c 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -286,6 +286,10 @@ void Viewport::logic() void Viewport::_followMouse() { Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY); + + mMouseX /= graphics->getScale(); + mMouseY /= graphics->getScale(); + // If the left button is dragged if (mPlayerFollowMouse && button & SDL_BUTTON(1)) { @@ -313,6 +317,9 @@ void Viewport::_drawDebugPath(Graphics *graphics) // Get the current mouse position SDL_GetMouseState(&mMouseX, &mMouseY); + mMouseX /= graphics->getScale(); + mMouseY /= graphics->getScale(); + // Prepare the walkmask corresponding to the protocol unsigned char walkMask; switch (Net::getNetworkType()) |