diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-09 13:10:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-09 13:10:54 +0300 |
commit | 4a6ffbd08067b64143e0535518a3822953943d80 (patch) | |
tree | 43121fb8f6690dbda227b9839aeb54837a6e53ad /src | |
parent | 9ea847e15b281dda88a4014010bc28e58befeb4c (diff) | |
download | mv-4a6ffbd08067b64143e0535518a3822953943d80.tar.gz mv-4a6ffbd08067b64143e0535518a3822953943d80.tar.bz2 mv-4a6ffbd08067b64143e0535518a3822953943d80.tar.xz mv-4a6ffbd08067b64143e0535518a3822953943d80.zip |
Add buy action.
New chat command: /buy [name]
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/commands.cpp | 31 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 9 | ||||
-rw-r--r-- | src/input/pages/basic.cpp | 6 |
5 files changed, 48 insertions, 0 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index c8d4f2b21..cd35ba9aa 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -37,9 +37,11 @@ #include "gui/widgets/tabs/chat/whispertab.h" #include "net/adminhandler.h" +#include "net/buysellhandler.h" #include "net/chathandler.h" #include "net/guildhandler.h" #include "net/homunculushandler.h" +#include "net/npchandler.h" #include "net/pethandler.h" #include "net/serverfeatures.h" @@ -711,4 +713,33 @@ impHandler0(fireHomunculus) return true; } +impHandler(buy) +{ + const std::string args = event.args; + Being *being = nullptr; + if (args.empty()) + { + being = localPlayer->getTarget(); + } + else + { + being = actorManager->findBeingByName( + args, ActorType::Unknown); + } + if (!being) + return false; + + if (being->getType() == ActorType::Npc) + { + npcHandler->buy(being->getId()); + return true; + } + else if (being->getType() == ActorType::Player) + { + buySellHandler->requestSellList(being->getName()); + return true; + } + return false; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 085b89663..29fa6ef27 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -76,6 +76,7 @@ namespace Actions decHandler(setPetName); decHandler(setHomunculusName); decHandler(fireHomunculus); + decHandler(buy); } // namespace Actions #undef decHandler diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 91c49ebc6..7187e2914 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -490,6 +490,7 @@ namespace InputAction PREV_INV_TAB, NEXT_INV_TAB, CONTEXT_MENU, + BUY, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 585334713..2a8904503 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -4153,6 +4153,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { | InputCondition::NOMODAL | InputCondition::INGAME, "contextmenu", false}, + {"keyBuy", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::buy, + InputAction::NO_VALUE, 50, + InputCondition::GAME, + "buy", + false}, }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/input/pages/basic.cpp b/src/input/pages/basic.cpp index c4b0db2d3..f514d388b 100644 --- a/src/input/pages/basic.cpp +++ b/src/input/pages/basic.cpp @@ -237,6 +237,12 @@ SetupActionData setupActionDataBasic[] = }, { // TRANSLATORS: input action name + N_("Buy"), + InputAction::BUY, + "", + }, + { + // TRANSLATORS: input action name N_("Open context menu"), InputAction::CONTEXT_MENU, "", |