From 5ac88f3197be965804827751e8679cc6dd59b188 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 May 2017 01:21:18 +0300 Subject: Add chat command for move monster in priority attack list into one position up. --- src/actions/commands.cpp | 34 ++++++++++++++++++++++++++++++++++ src/actions/commands.h | 1 + src/dyetool/actions/commands.cpp | 1 + src/enums/input/inputaction.h | 1 + src/gui/popups/popupmenu.cpp | 38 ++++---------------------------------- src/input/inputactionmap.h | 6 ++++++ 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index d033413bd..13b88499b 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1960,8 +1960,42 @@ impHandler(moveAttackDown) if (socialWindow) socialWindow->updateAttackFilter(); + return true; } return false; } +impHandler(movePriorityAttackUp) +{ + if (!actorManager) + return false; + const std::string args = event.args; + const int idx = actorManager-> + getPriorityAttackMobIndex(args); + if (idx > 0) + { + std::list mobs + = actorManager->getPriorityAttackMobs(); + std::list::iterator it = mobs.begin(); + std::list::iterator it2 = it; + while (it != mobs.end()) + { + if (*it == args) + { + -- it2; + mobs.splice(it2, mobs, it); + actorManager->setPriorityAttackMobs(mobs); + actorManager->rebuildPriorityAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + return true; + } +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 5340f1b5b..26907f7ac 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -155,6 +155,7 @@ namespace Actions decHandler(outfitToChat); decHandler(moveAttackUp); decHandler(moveAttackDown); + decHandler(movePriorityAttackUp); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 40ada1494..87645ed4f 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -155,5 +155,6 @@ impHandlerVoid(partyAutoItemShare) impHandlerVoid(outfitToChat) impHandlerVoid(moveAttackUp) impHandlerVoid(moveAttackDown) +impHandlerVoid(movePriorityAttackUp) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 6e0a2560c..59d7cf59c 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -690,6 +690,7 @@ enumStart(InputAction) COMMAND_SEND_GUI_KEY, MOVE_ATTACK_UP, MOVE_ATTACK_DOWN, + MOVE_PRIORITY_ATTACK_UP, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index d1d5ddd8a..aa5a05625 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1239,37 +1239,6 @@ void PopupMenu::handleLink(const std::string &link, dialog->setActionEventId("ok"); dialog->addActionListener(&mPlayerListener); } - else if (link == "priority moveup") - { - if (actorManager) - { - const int idx = actorManager-> - getPriorityAttackMobIndex(mName); - if (idx > 0) - { - std::list mobs - = actorManager->getPriorityAttackMobs(); - std::list::iterator it = mobs.begin(); - std::list::iterator it2 = it; - while (it != mobs.end()) - { - if (*it == mName) - { - -- it2; - mobs.splice(it2, mobs, it); - actorManager->setPriorityAttackMobs(mobs); - actorManager->rebuildPriorityAttackMobs(); - break; - } - ++ it; - ++ it2; - } - - if (socialWindow) - socialWindow->updateAttackFilter(); - } - } - } else if (link == "priority movedown") { if (localPlayer && actorManager) @@ -2099,9 +2068,10 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y, const int size = actorManager->getPriorityAttackMobsSize(); if (idx > 0) { - // TRANSLATORS: popup menu item - // TRANSLATORS: move attack target up - mBrowserBox->addRow("priority moveup", _("Move up")); + mBrowserBox->addRow("/movepriorityattackup 'NAME'", + // TRANSLATORS: popup menu item + // TRANSLATORS: move attack target up + _("Move up")); } if (idx + 1 < size) { diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 7751bbaae..6ea9ea303 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5630,6 +5630,12 @@ static const InputActionData inputActionData "attackmovedown|moveattackdown", UseArgs_true, Protected_true}, + {"keyMovePriorityAttackUp", + defaultAction(&Actions::movePriorityAttackUp), + InputCondition::ENABLED, + "attackmovepriorityup|movepriorityattackup", + UseArgs_true, + Protected_true}, }; #undef defaultAction -- cgit v1.2.3-60-g2f50