summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp20
1 files changed, 20 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();
+ }
+}