diff options
author | Stefan Dombrowski <stefan@uni-bonn.de> | 2010-10-03 22:53:09 +0200 |
---|---|---|
committer | Stefan Dombrowski <stefan@uni-bonn.de> | 2010-10-03 22:53:09 +0200 |
commit | 671ae4cd0e26618c0662123d4b9c0d1c63acb4f6 (patch) | |
tree | 4f1c89f92838e2f2468eaf06a1306d7bb1b66c0d /src | |
parent | e6acf6e2f17b4177f3f8292f52d83b46822ab9c5 (diff) | |
download | mana-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')
-rw-r--r-- | src/gui/viewport.cpp | 13 | ||||
-rw-r--r-- | src/gui/viewport.h | 5 |
2 files changed, 18 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()) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 9658f934..616b88be 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -182,6 +182,11 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void _followMouse(); + /** + * Updates the cursor type + */ + void updateCursorType(); + Map *mMap; /**< The current map. */ int mScrollRadius; |