summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-28 16:14:15 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-28 16:14:15 +0300
commit226202ff807dc860991af0d6665ef9e9b48c1bed (patch)
treede0be738585f3ab2556865c206981d2d2842ac69 /src/gui
parenteb62e14c838788ae7691567a90bf7fe4940d5687 (diff)
downloadmanaplus-226202ff807dc860991af0d6665ef9e9b48c1bed.tar.gz
manaplus-226202ff807dc860991af0d6665ef9e9b48c1bed.tar.bz2
manaplus-226202ff807dc860991af0d6665ef9e9b48c1bed.tar.xz
manaplus-226202ff807dc860991af0d6665ef9e9b48c1bed.zip
Move direct SDL_GetMouseState calls into method in gui class.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp9
-rw-r--r--src/gui/gui.h2
-rw-r--r--src/gui/viewport.cpp8
-rw-r--r--src/gui/widgets/characterdisplay.cpp5
-rw-r--r--src/gui/widgets/textfield.cpp11
-rw-r--r--src/gui/windows/chatwindow.cpp5
-rw-r--r--src/gui/windows/equipmentwindow.cpp3
7 files changed, 29 insertions, 14 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index a8c31469a..d016c0aa3 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -494,7 +494,7 @@ void Gui::draw()
touchManager.draw();
int mouseX, mouseY;
- const uint8_t button = SDL_GetMouseState(&mouseX, &mouseY);
+ const uint8_t button = getMouseState(&mouseX, &mouseY);
if ((client->getMouseFocused() || button & SDL_BUTTON(1))
&& mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F)
@@ -787,7 +787,7 @@ MouseEvent *Gui::createMouseEvent(Window *const widget)
int mouseY = 0;
getAbsolutePosition(widget, x, y);
- SDL_GetMouseState(&mouseX, &mouseY);
+ getMouseState(&mouseX, &mouseY);
return new MouseEvent(widget, mShiftPressed,
mControlPressed, mAltPressed, mMetaPressed, 0, 0,
@@ -939,3 +939,8 @@ void Gui::removeDragged(gcn::Widget *widget)
if (mFocusHandler->getDraggedWidget() == widget)
mFocusHandler->setDraggedWidget(nullptr);
}
+
+uint32_t Gui::getMouseState(int *const x, int *const y) const
+{
+ return SDL_GetMouseState(x, y);
+}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 7c34fc5cf..033a71282 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -164,6 +164,8 @@ class Gui final : public gcn::Gui
int getLastMouseY() const
{ return mLastMouseY; }
+ uint32_t getMouseState(int *const x, int *const y) const;
+
protected:
void handleMouseMoved(const gcn::MouseInput &mouseInput);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 933c00040..5206b7424 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -275,7 +275,9 @@ void Viewport::logic()
void Viewport::_followMouse()
{
- const uint8_t button = SDL_GetMouseState(&mMouseX, &mMouseY);
+ if (!gui)
+ return;
+ const uint8_t button = gui->getMouseState(&mMouseX, &mMouseY);
// If the left button is dragged
if (mPlayerFollowMouse && (button & SDL_BUTTON(1)))
{
@@ -297,10 +299,10 @@ void Viewport::_followMouse()
void Viewport::_drawDebugPath(Graphics *const graphics)
{
- if (!player_node || !userPalette || !actorManager || !mMap)
+ if (!player_node || !userPalette || !actorManager || !mMap || !gui)
return;
- SDL_GetMouseState(&mMouseX, &mMouseY);
+ gui->getMouseState(&mMouseX, &mMouseY);
static Path debugPath;
static Vector lastMouseDestination = Vector(0.0F, 0.0F);
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 52f56ae69..bd3f042f9 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -122,9 +122,12 @@ void CharacterDisplay::mouseExited(gcn::MouseEvent &event A_UNUSED)
void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED)
{
+ if (!gui)
+ return;
+
int mouseX = 0;
int mouseY = 0;
- SDL_GetMouseState(&mouseX, &mouseY);
+ gui->getMouseState(&mouseX, &mouseY);
const std::string &name = mName->getCaption();
if (!name.empty())
{
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 07fde23cd..41084c867 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -741,10 +741,13 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent)
mPopupMenu = new PopupMenu();
mPopupMenu->postInit();
}
- int x = 0;
- int y = 0;
- SDL_GetMouseState(&x, &y);
- mPopupMenu->showTextFieldPopup(x, y, this);
+ if (gui)
+ {
+ int x = 0;
+ int y = 0;
+ gui->getMouseState(&x, &y);
+ mPopupMenu->showTextFieldPopup(x, y, this);
+ }
}
}
else
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 62a032341..6af18ff06 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1911,11 +1911,14 @@ void ChatWindow::draw(gcn::Graphics* graphics)
void ChatWindow::updateVisibility()
{
+ if (!gui)
+ return;
+
int mouseX = 0;
int mouseY = 0;
int x = 0;
int y = 0;
- SDL_GetMouseState(&mouseX, &mouseY);
+ gui->getMouseState(&mouseX, &mouseY);
getAbsolutePosition(x, y);
if (mChatInput->isVisible())
{
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index f521f4b9b..cd04aaf99 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -425,9 +425,6 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
if (item)
{
- int mouseX, mouseY;
- SDL_GetMouseState(&mouseX, &mouseY);
-
mItemPopup->setItem(item);
mItemPopup->position(x + getX(), y + getY());
}