summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-10 23:42:45 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-11 00:05:30 +0300
commit9be7d0ac1127477a5ff5ffb3fb3dd45487eec213 (patch)
tree47433ccb0c1f7e4c71dea85647a642079948ad67
parenta3475e987b0e642b2b9aa9c6cbf74762c6c77d23 (diff)
downloadmanaverse-9be7d0ac1127477a5ff5ffb3fb3dd45487eec213.tar.gz
manaverse-9be7d0ac1127477a5ff5ffb3fb3dd45487eec213.tar.bz2
manaverse-9be7d0ac1127477a5ff5ffb3fb3dd45487eec213.tar.xz
manaverse-9be7d0ac1127477a5ff5ffb3fb3dd45487eec213.zip
Move untarget and stop attack actions to actionmanager from hardcoded place.
-rw-r--r--src/actionmanager.cpp20
-rw-r--r--src/actionmanager.h2
-rw-r--r--src/game.cpp10
-rw-r--r--src/keyboarddata.h6
4 files changed, 25 insertions, 13 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index d3e34daa8..bbfaf5430 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -929,4 +929,24 @@ impHandler0(talk)
return false;
}
+impHandler0(stopAttack)
+{
+ if (player_node)
+ {
+ player_node->stopAttack();
+ return true;
+ }
+ return false;
+}
+
+impHandler0(untarget)
+{
+ if (player_node)
+ {
+ player_node->untarget();
+ return true;
+ }
+ return false;
+}
+
}
diff --git a/src/actionmanager.h b/src/actionmanager.h
index 05d84b989..0950b4e3d 100644
--- a/src/actionmanager.h
+++ b/src/actionmanager.h
@@ -85,6 +85,8 @@ namespace ActionManager
decHandler(directLeft);
decHandler(directRight);
decHandler(talk);
+ decHandler(stopAttack);
+ decHandler(untarget);
decHandler(hideWindows);
decHandler(helpWindowShow);
diff --git a/src/game.cpp b/src/game.cpp
index b05cd6d28..68d637829 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -862,16 +862,6 @@ void Game::handleMoveAndAttack()
mLastTarget = ActorSprite::UNKNOWN; // Reset last target
}
}
-
- // Stop attacking if the right key is pressed
- if (!inputManager.isActionActive(Input::KEY_ATTACK)
- && !inputManager.isActionActive(Input::KEY_EMOTE))
- {
- if (inputManager.isActionActive(Input::KEY_STOP_ATTACK))
- player_node->stopAttack();
- else if (inputManager.isActionActive(Input::KEY_UNTARGET))
- player_node->untarget();
- }
}
}
diff --git a/src/keyboarddata.h b/src/keyboarddata.h
index 5ea1daba3..d1b77f3ea 100644
--- a/src/keyboarddata.h
+++ b/src/keyboarddata.h
@@ -123,16 +123,16 @@ static KeyData const keyData[Input::KEY_TOTAL] = {
INPUT_KEYBOARD, SDLK_LSHIFT,
INPUT_JOYSTICK, 4,
Input::GRP_DEFAULT,
- nullptr,
+ &ActionManager::stopAttack,
Input::KEY_NO_VALUE, 50,
COND_GAME},
{"keyUnTarget",
INPUT_UNKNOWN, Input::KEY_NO_VALUE,
INPUT_UNKNOWN, Input::KEY_NO_VALUE,
Input::GRP_DEFAULT,
- nullptr,
+ &ActionManager::untarget,
Input::KEY_NO_VALUE, 50,
- COND_DEFAULT},
+ COND_GAME},
{"keyTargetClosest",
INPUT_KEYBOARD, SDLK_a,
INPUT_UNKNOWN, Input::KEY_NO_VALUE,