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/sdlinput.cpp | |
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/sdlinput.cpp')
-rw-r--r-- | src/gui/sdlinput.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
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; } |