summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-31 18:29:46 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-31 18:29:46 +0300
commiteac30a76badf24f580d8f9d525ee305568e68363 (patch)
tree30c63d304d5b83beed4529167531ba560a4d6465 /src/gui
parent6262c897a5dcbc95e534a54af99186ee7efb541d (diff)
downloadmv-eac30a76badf24f580d8f9d525ee305568e68363.tar.gz
mv-eac30a76badf24f580d8f9d525ee305568e68363.tar.bz2
mv-eac30a76badf24f580d8f9d525ee305568e68363.tar.xz
mv-eac30a76badf24f580d8f9d525ee305568e68363.zip
Fix move issue with mouse.
Diffstat (limited to 'src/gui')
-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