From 5bbad4bc6bb8a6de5e259ad56a77ac34784fdb77 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 8 Dec 2014 23:15:04 +0300 Subject: Add open context menu action. No key assigned. New chat command: contextmenu --- src/actions/target.cpp | 14 ++++++++++++++ src/actions/target.h | 1 + src/input/inputaction.h | 1 + src/input/inputactionmap.h | 10 ++++++++++ src/input/pages/basic.cpp | 6 ++++++ 5 files changed, 32 insertions(+) (limited to 'src') diff --git a/src/actions/target.cpp b/src/actions/target.cpp index 8212a3a97..e59c2922d 100644 --- a/src/actions/target.cpp +++ b/src/actions/target.cpp @@ -26,6 +26,8 @@ #include "being/localplayer.h" +#include "gui/popups/popupmenu.h" + #include "debug.h" namespace Actions @@ -76,4 +78,16 @@ impHandler0(targetPet) return setTarget(ActorType::Pet, true); } +impHandler0(contextMenu) +{ + if (!localPlayer) + return false; + Being *const target = localPlayer->getTarget(); + if (!target) + return true; + + popupMenu->showPopup(target->getPixelX(), target->getPixelY(), target); + return true; +} + } // namespace Actions diff --git a/src/actions/target.h b/src/actions/target.h index 50ac1e63e..1506660a6 100644 --- a/src/actions/target.h +++ b/src/actions/target.h @@ -33,6 +33,7 @@ namespace Actions decHandler(targetNPC); decHandler(targetMercenary); decHandler(targetPet); + decHandler(contextMenu); } // namespace Actions #undef decHandler diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 7ab68911c..91c49ebc6 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -489,6 +489,7 @@ namespace InputAction WINDOW_BANK, PREV_INV_TAB, NEXT_INV_TAB, + CONTEXT_MENU, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index afa66df87..585334713 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -4143,6 +4143,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::NOINPUT | InputCondition::INGAME, "nextinvtab", false}, + {"keyContextMenu", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::contextMenu, + InputAction::NO_VALUE, 50, + InputCondition::NOINPUT | InputCondition::NOAWAY + | InputCondition::NOMODAL | InputCondition::INGAME, + "contextmenu", + false}, }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/input/pages/basic.cpp b/src/input/pages/basic.cpp index 13b3a770c..c4b0db2d3 100644 --- a/src/input/pages/basic.cpp +++ b/src/input/pages/basic.cpp @@ -235,6 +235,12 @@ SetupActionData setupActionDataBasic[] = InputAction::HOMUNCULUS_FIRE, "", }, + { + // TRANSLATORS: input action name + N_("Open context menu"), + InputAction::CONTEXT_MENU, + "", + }, { "", InputAction::NO_VALUE, -- cgit v1.2.3-70-g09d2