summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 16:45:13 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-14 16:45:13 +0000
commitd1395845cdc678db2a71326f2e6f20253ed14cac (patch)
tree9a75fe0591fc7bd74f828aa048aa027f59a4ae66 /src/gui/viewport.cpp
parent6c3a2550813c14290307f2ad91e1d76eea3e6a02 (diff)
downloadMana-d1395845cdc678db2a71326f2e6f20253ed14cac.tar.gz
Mana-d1395845cdc678db2a71326f2e6f20253ed14cac.tar.bz2
Mana-d1395845cdc678db2a71326f2e6f20253ed14cac.tar.xz
Mana-d1395845cdc678db2a71326f2e6f20253ed14cac.zip
Merged 0.0 changes from revision 2988 to 3035 to trunk.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 75a16865..671ababa 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -47,6 +47,7 @@ Viewport::Viewport():
mCameraX(0),
mCameraY(0),
mShowDebugPath(false),
+ mPlayerFollowMouse(false),
mPopupActive(false)
{
setOpaque(false);
@@ -243,7 +244,7 @@ Viewport::logic()
}
void
-Viewport::mousePress(int mx, int my, int button)
+Viewport::mousePressed(gcn::MouseEvent &event)
{
// Check if we are alive and kickin'
if (!mMap || !player_node || player_node->mAction == Being::DEAD)
@@ -255,11 +256,11 @@ Viewport::mousePress(int mx, int my, int button)
mPlayerFollowMouse = false;
- int tilex = (mx + mCameraX) / 32;
- int tiley = (my + mCameraY) / 32;
+ int tilex = (event.getX() + mCameraX) / 32;
+ int tiley = (event.getY() + mCameraY) / 32;
// Right click might open a popup
- if (button == gcn::MouseInput::RIGHT)
+ if (event.getButton() == gcn::MouseEvent::RIGHT)
{
Being *being;
FloorItem *floorItem;
@@ -267,12 +268,12 @@ Viewport::mousePress(int mx, int my, int button)
if ((being = beingManager->findBeing(tilex, tiley)) &&
being->getType() != Being::LOCALPLAYER)
{
- showPopup(mx, my, being);
+ showPopup(event.getX(), event.getY(), being);
return;
}
else if((floorItem = floorItemManager->findByCoordinates(tilex, tiley)))
{
- showPopup(mx, my, floorItem);
+ showPopup(event.getX(), event.getY(), floorItem);
return;
}
}
@@ -286,7 +287,7 @@ Viewport::mousePress(int mx, int my, int button)
}
// Left click can cause different actions
- if (button == gcn::MouseInput::LEFT)
+ if (event.getButton() == gcn::MouseEvent::LEFT)
{
FloorItem *item;
@@ -302,13 +303,13 @@ Viewport::mousePress(int mx, int my, int button)
Uint8 *keys = SDL_GetKeyState(NULL);
if (!(keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]))
{
- player_node->setDestination(mx + mCameraX, my + mCameraY);
+ player_node->setDestination(event.getX() + mCameraX,
+ event.getY() + mCameraY);
}
mPlayerFollowMouse = true;
}
}
-
- if (button == gcn::MouseInput::MIDDLE)
+ else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
// Find the being nearest to the clicked position
Being *target = beingManager->findNearestLivingBeing(
@@ -323,19 +324,20 @@ Viewport::mousePress(int mx, int my, int button)
}
void
-Viewport::mouseMotion(int mx, int my)
+Viewport::mouseMoved(gcn::MouseEvent &event)
{
if (!mMap || !player_node)
return;
if (mPlayerFollowMouse && mWalkTime == player_node->mWalkTime)
{
- player_node->setDestination(mx + mCameraX, my + mCameraY);
+ player_node->setDestination(event.getX() + mCameraX,
+ event.getY() + mCameraY);
}
}
void
-Viewport::mouseRelease(int mx, int my, int button)
+Viewport::mouseReleased(gcn::MouseEvent &event)
{
mPlayerFollowMouse = false;
}