diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-10 01:07:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-10 01:07:30 +0300 |
commit | 8ca5407776fa9c3038b608f9caf401952c2631d6 (patch) | |
tree | 1a30526373487e4c4a18b22a965b75ca369b0fdd | |
parent | e62ca47b5ec9c8e630933a674c1419d911722f85 (diff) | |
download | plus-8ca5407776fa9c3038b608f9caf401952c2631d6.tar.gz plus-8ca5407776fa9c3038b608f9caf401952c2631d6.tar.bz2 plus-8ca5407776fa9c3038b608f9caf401952c2631d6.tar.xz plus-8ca5407776fa9c3038b608f9caf401952c2631d6.zip |
Add chat command for move monster in attack list into one position down.
-rw-r--r-- | src/actions/commands.cpp | 38 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/dyetool/actions/commands.cpp | 1 | ||||
-rw-r--r-- | src/enums/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 36 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 6 |
6 files changed, 48 insertions, 35 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 79ed06f3c..d033413bd 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1897,6 +1897,8 @@ impHandler0(outfitToChat) impHandler(moveAttackUp) { + if (!actorManager) + return false; const std::string args = event.args; const int idx = actorManager->getAttackMobIndex(args); if (idx > 0) @@ -1926,4 +1928,40 @@ impHandler(moveAttackUp) return false; } +impHandler(moveAttackDown) +{ + if (!actorManager) + return false; + const std::string args = event.args; + const int idx = actorManager->getAttackMobIndex(args); + const int size = actorManager->getAttackMobsSize(); + if (idx + 1 < size) + { + std::list<std::string> mobs + = actorManager->getAttackMobs(); + std::list<std::string>::iterator it = mobs.begin(); + std::list<std::string>::iterator it2 = it; + while (it != mobs.end()) + { + if (*it == args) + { + ++ it2; + if (it2 == mobs.end()) + break; + + mobs.splice(it, mobs, it2); + actorManager->setAttackMobs(mobs); + actorManager->rebuildAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 6b97f295e..5340f1b5b 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -154,6 +154,7 @@ namespace Actions decHandler(partyAutoItemShare); decHandler(outfitToChat); decHandler(moveAttackUp); + decHandler(moveAttackDown); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 37076648f..40ada1494 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -154,5 +154,6 @@ impHandlerVoid(partyExpShare) impHandlerVoid(partyAutoItemShare) impHandlerVoid(outfitToChat) impHandlerVoid(moveAttackUp) +impHandlerVoid(moveAttackDown) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 6eb6c84f5..6e0a2560c 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -689,6 +689,7 @@ enumStart(InputAction) COMMAND_TRANSLATE, COMMAND_SEND_GUI_KEY, MOVE_ATTACK_UP, + MOVE_ATTACK_DOWN, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index cdc6e7494..d1d5ddd8a 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1270,40 +1270,6 @@ void PopupMenu::handleLink(const std::string &link, } } } - else if (link == "attack movedown") - { - if (actorManager) - { - const int idx = actorManager->getAttackMobIndex(mName); - const int size = actorManager->getAttackMobsSize(); - if (idx + 1 < size) - { - std::list<std::string> mobs - = actorManager->getAttackMobs(); - std::list<std::string>::iterator it = mobs.begin(); - std::list<std::string>::iterator it2 = it; - while (it != mobs.end()) - { - if (*it == mName) - { - ++ it2; - if (it2 == mobs.end()) - break; - - mobs.splice(it, mobs, it2); - actorManager->setAttackMobs(mobs); - actorManager->rebuildAttackMobs(); - break; - } - ++ it; - ++ it2; - } - - if (socialWindow) - socialWindow->updateAttackFilter(); - } - } - } else if (link == "priority movedown") { if (localPlayer && actorManager) @@ -2122,7 +2088,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y, { // TRANSLATORS: popup menu item // TRANSLATORS: move attack target down - mBrowserBox->addRow("attack movedown", _("Move down")); + mBrowserBox->addRow("/moveattackdown 'NAME'", _("Move down")); } break; } diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index d368ff911..7751bbaae 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5624,6 +5624,12 @@ static const InputActionData inputActionData "attackmoveup|moveattackup", UseArgs_true, Protected_true}, + {"keyMoveAttackDown", + defaultAction(&Actions::moveAttackDown), + InputCondition::ENABLED, + "attackmovedown|moveattackdown", + UseArgs_true, + Protected_true}, }; #undef defaultAction |