From e62ca47b5ec9c8e630933a674c1419d911722f85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 May 2017 00:26:25 +0300 Subject: Add chat command for move monster in attack list into one position up. --- src/actions/commands.cpp | 31 +++++++++++++++++++++++++++++++ src/actions/commands.h | 1 + src/dyetool/actions/commands.cpp | 1 + src/enums/input/inputaction.h | 1 + src/gui/popups/popupmenu.cpp | 32 +------------------------------- src/input/inputactionmap.h | 8 +++++++- 6 files changed, 42 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 35fd376cc..79ed06f3c 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1895,4 +1895,35 @@ impHandler0(outfitToChat) return true; } +impHandler(moveAttackUp) +{ + const std::string args = event.args; + const int idx = actorManager->getAttackMobIndex(args); + if (idx > 0) + { + std::list mobs + = actorManager->getAttackMobs(); + 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->setAttackMobs(mobs); + actorManager->rebuildAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + return true; + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 6295b7264..6b97f295e 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -153,6 +153,7 @@ namespace Actions decHandler(partyExpShare); decHandler(partyAutoItemShare); decHandler(outfitToChat); + decHandler(moveAttackUp); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index b0d90de6a..37076648f 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -153,5 +153,6 @@ impHandlerVoid(partyItemShare) impHandlerVoid(partyExpShare) impHandlerVoid(partyAutoItemShare) impHandlerVoid(outfitToChat) +impHandlerVoid(moveAttackUp) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 5fc37aa1f..6eb6c84f5 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -688,6 +688,7 @@ enumStart(InputAction) COPY_OUTFIT_TO_CHAT, COMMAND_TRANSLATE, COMMAND_SEND_GUI_KEY, + MOVE_ATTACK_UP, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index ff2b7cfa6..cdc6e7494 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1239,36 +1239,6 @@ void PopupMenu::handleLink(const std::string &link, dialog->setActionEventId("ok"); dialog->addActionListener(&mPlayerListener); } - else if (link == "attack moveup") - { - if (actorManager) - { - const int idx = actorManager->getAttackMobIndex(mName); - if (idx > 0) - { - std::list mobs - = actorManager->getAttackMobs(); - 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->setAttackMobs(mobs); - actorManager->rebuildAttackMobs(); - break; - } - ++ it; - ++ it2; - } - - if (socialWindow) - socialWindow->updateAttackFilter(); - } - } - } else if (link == "priority moveup") { if (actorManager) @@ -2146,7 +2116,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y, { // TRANSLATORS: popup menu item // TRANSLATORS: move attack target up - mBrowserBox->addRow("attack moveup", _("Move up")); + mBrowserBox->addRow("/moveattackup 'NAME'", _("Move up")); } if (idx + 1 < size) { diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index f4d8f5739..d368ff911 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5616,7 +5616,13 @@ static const InputActionData inputActionData defaultAction(&Actions::sendGuiKey), InputCondition::ENABLED, "guikey|sendguikey", - UseArgs_false, + UseArgs_true, + Protected_true}, + {"keyMoveAttackUp", + defaultAction(&Actions::moveAttackUp), + InputCondition::ENABLED, + "attackmoveup|moveattackup", + UseArgs_true, Protected_true}, }; -- cgit v1.2.3-70-g09d2