summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-01-25 22:05:36 +0100
committerReid <reidyaro@gmail.com>2012-01-25 22:05:36 +0100
commit8b612abb42853a22c1a9545e2c9280d154646543 (patch)
treef466167087c2b2de4b8aa9e6d1d1986f72f84147 /src/gui/viewport.cpp
parenta913dd41df61760de6ece552f941e002251ff54c (diff)
parentd340b5a27a8f3b05d1764da9c114f5f59bd0cd46 (diff)
downloadmanaverse-8b612abb42853a22c1a9545e2c9280d154646543.tar.gz
manaverse-8b612abb42853a22c1a9545e2c9280d154646543.tar.bz2
manaverse-8b612abb42853a22c1a9545e2c9280d154646543.tar.xz
manaverse-8b612abb42853a22c1a9545e2c9280d154646543.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp57
1 files changed, 53 insertions, 4 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b6c55f2c4..f4c6c315f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -2,7 +2,7 @@
* The ManaPlus Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011 The ManaPlus Developers
+ * Copyright (C) 2011-2012 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -481,6 +481,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (mHoverBeing->canTalk())
{
mHoverBeing->talkTo();
+ return;
}
else
{
@@ -490,6 +491,9 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
{
if (player_node != mHoverBeing || mSelfMouseHeal)
actorSpriteManager->heal(mHoverBeing);
+ if (player_node == mHoverBeing && mHoverItem)
+ player_node->pickUp(mHoverItem);
+ return;
}
}
else if (player_node->withinAttackRange(mHoverBeing) ||
@@ -499,17 +503,21 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
{
player_node->attack(mHoverBeing,
!keyboard.isKeyActive(keyboard.KEY_TARGET));
+ return;
}
}
else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
if (player_node != mHoverBeing)
+ {
player_node->setGotoTarget(mHoverBeing);
+ return;
+ }
}
}
- // Picks up a item if we clicked on one
}
- else if (mHoverItem)
+ // Picks up a item if we clicked on one
+ if (mHoverItem)
{
player_node->pickUp(mHoverItem);
}
@@ -739,7 +747,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
}
mHoverItem = nullptr;
- if (!mHoverBeing && actorSpriteManager)
+ if (actorSpriteManager)
{
mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
@@ -867,3 +875,44 @@ bool Viewport::isPopupMenuVisible()
{
return mPopupMenu ? mPopupMenu->isVisible() : false;
}
+
+void Viewport::moveCameraToActor(int actorId, int x, int y)
+{
+ if (!player_node)
+ return;
+
+ Actor *actor = actorSpriteManager->findBeing(actorId);
+ if (!actor)
+ return;
+ Vector actorPos = actor->getPosition();
+ Vector playerPos = player_node->getPosition();
+ mCameraMode = 1;
+ mCameraRelativeX = actorPos.x - playerPos.x + x;
+ mCameraRelativeY = actorPos.y - playerPos.y + y;
+}
+
+void Viewport::moveCameraToPosition(int x, int y)
+{
+ if (!player_node)
+ return;
+
+ Vector playerPos = player_node->getPosition();
+ mCameraMode = 1;
+
+ mCameraRelativeX = x - playerPos.x;
+ mCameraRelativeY = y - playerPos.y;
+}
+
+void Viewport::moveCameraRelative(int x, int y)
+{
+ mCameraMode = 1;
+ mCameraRelativeX += x;
+ mCameraRelativeY += y;
+}
+
+void Viewport::returnCamera()
+{
+ mCameraMode = 0;
+ mCameraRelativeX = 0;
+ mCameraRelativeY = 0;
+}