summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2010-10-03 22:53:09 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2010-10-03 22:53:09 +0200
commit671ae4cd0e26618c0662123d4b9c0d1c63acb4f6 (patch)
tree4f1c89f92838e2f2468eaf06a1306d7bb1b66c0d /src/gui/viewport.cpp
parente6acf6e2f17b4177f3f8292f52d83b46822ab9c5 (diff)
downloadmana-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.gz
mana-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.bz2
mana-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.xz
mana-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.zip
Fixing segmentation fault and updating the cursor type after mouse press
Until now the being was only set after a mouse move. If the mouse was pressed after the being was out of sight or dead, then a segmentation fault happened. Furthermore, pressing the mouse now updates the cursor type and sets the being popup invisible. Reviewed-by: Thorbjorn
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 99325db8..ce506ba1 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -349,10 +349,18 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
return;
mPlayerFollowMouse = false;
+ mBeingPopup->setVisible(false);
const int pixelX = event.getX() + (int) mPixelViewX;
const int pixelY = event.getY() + (int) mPixelViewY;
+ mHoverBeing = beingManager->findBeingByPixel(pixelX, pixelY);
+ mHoverItem = floorItemManager->
+ findByCoordinates(pixelX / mMap->getTileWidth(),
+ pixelY / mMap->getTileHeight());
+
+ updateCursorType();
+
// Right click might open a popup
if (event.getButton() == gcn::MouseEvent::RIGHT)
{
@@ -517,6 +525,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
mHoverItem = floorItemManager->findByCoordinates(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
+ updateCursorType();
+}
+
+void Viewport::updateCursorType()
+{
if (mHoverBeing)
{
switch (mHoverBeing->getType())