summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-31 18:29:46 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-20 12:39:47 +0300
commit7f80748fb8a1b02702075c143750701656aa55e4 (patch)
treef610d6a5bf5d06a64b6f016c6071ee03a956d5d1
parent1ef5e2dc114fce7a698e3374c15b58d49aec9d8b (diff)
downloadplus-7f80748fb8a1b02702075c143750701656aa55e4.tar.gz
plus-7f80748fb8a1b02702075c143750701656aa55e4.tar.bz2
plus-7f80748fb8a1b02702075c143750701656aa55e4.tar.xz
plus-7f80748fb8a1b02702075c143750701656aa55e4.zip
Fix move issue with mouse.
-rw-r--r--src/gui/viewport.cpp20
-rw-r--r--src/gui/viewport.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 5c50836f6..f55385029 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -426,6 +426,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
mPlayerFollowMouse = false;
if (mHoverBeing)
{
+ validateSpeed();
if (actorSpriteManager)
{
std::vector<ActorSprite*> beings;
@@ -447,11 +448,13 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
else if (mHoverItem)
{
+ validateSpeed();
mPopupMenu->showPopup(event.getX(), event.getY(), mHoverItem);
return;
}
else if (mHoverSign)
{
+ validateSpeed();
mPopupMenu->showPopup(event.getX(), event.getY(), mHoverSign);
return;
}
@@ -483,6 +486,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (mHoverBeing->canTalk())
{
+ validateSpeed();
mHoverBeing->talkTo();
return;
}
@@ -490,6 +494,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
{
if (mHoverBeing->getType() == ActorSprite::PLAYER)
{
+ validateSpeed();
if (actorSpriteManager)
{
if (player_node != mHoverBeing || mSelfMouseHeal)
@@ -502,6 +507,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
else if (player_node->withinAttackRange(mHoverBeing) ||
keyboard.isActionActive(keyboard.KEY_ATTACK))
{
+ validateSpeed();
if (player_node != mHoverBeing)
{
player_node->attack(mHoverBeing,
@@ -511,6 +517,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
else if (!keyboard.isActionActive(keyboard.KEY_ATTACK))
{
+ validateSpeed();
if (player_node != mHoverBeing)
{
player_node->setGotoTarget(mHoverBeing);
@@ -522,11 +529,13 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
// Picks up a item if we clicked on one
if (mHoverItem)
{
+ validateSpeed();
player_node->pickUp(mHoverItem);
}
// Just walk around
else if (!keyboard.isActionActive(keyboard.KEY_ATTACK))
{
+ validateSpeed();
player_node->stopAttack();
player_node->cancelFollow();
mPlayerFollowMouse = true;
@@ -538,6 +547,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
mPlayerFollowMouse = false;
+ validateSpeed();
// Find the being nearest to the clicked position
if (actorSpriteManager)
{
@@ -924,3 +934,13 @@ void Viewport::returnCamera()
mCameraRelativeX = 0;
mCameraRelativeY = 0;
}
+
+void Viewport::validateSpeed()
+{
+ if (!keyboard.isActionActive(keyboard.KEY_TARGET_ATTACK)
+ && !keyboard.isActionActive(keyboard.KEY_ATTACK))
+ {
+ if (Game::instance())
+ Game::instance()->setValidSpeed();
+ }
+}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index ae6ff3d49..43f61bcfc 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -274,6 +274,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
/// Clears any matching hovers
void clearHover(ActorSprite *actor);
+ void validateSpeed();
+
private:
/**
* Finds a path from the player to the mouse, and draws it. This is for