From b44ae759ff5a848b7c6d15dc80bba4e7a6948575 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 26 Aug 2014 15:05:48 +0300 Subject: Move chat command /trade into actions. --- src/actions/actions.cpp | 19 +++++++++++++++++++ src/actions/actions.h | 1 + src/commands.cpp | 17 ----------------- src/commands.h | 5 +---- src/defaults.cpp | 2 +- src/input/inputaction.h | 3 ++- src/input/inputactionmap.h | 9 +++++++++ src/input/pages/basic.cpp | 8 +++++++- 8 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 251204df4..9d1279e3f 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -596,4 +596,23 @@ impHandler0(cleanFonts) return true; } +impHandler(trade) +{ + if (!actorManager) + return false; + + const Being *being = actorManager->findBeingByName( + event.args, ActorType::PLAYER); + if (!being) + being = localPlayer->getTarget(); + if (being) + { + Net::getTradeHandler()->request(being); + tradePartnerName = being->getName(); + if (tradeWindow) + tradeWindow->clear(); + } + return true; +} + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index 92d293df4..ea9faadab 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -60,6 +60,7 @@ namespace Actions decHandler(cleanGraphics); decHandler(cleanFonts); decHandler(attackHuman); + decHandler(trade); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index 72ba9f6c1..52a9dbb2a 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -206,23 +206,6 @@ impHandler(attack) return true; } -impHandler(trade) -{ - if (!actorManager) - return false; - - const Being *const being = actorManager->findBeingByName( - event.args, ActorType::PLAYER); - if (being) - { - Net::getTradeHandler()->request(being); - tradePartnerName = being->getName(); - if (tradeWindow) - tradeWindow->clear(); - } - return true; -} - impHandler0(dirs) { if (!localPlayer || !debugChatTab) diff --git a/src/commands.h b/src/commands.h index b09979050..58f3bf176 100644 --- a/src/commands.h +++ b/src/commands.h @@ -54,7 +54,6 @@ namespace Commands decHandler(hack); decHandler(priceLoad); decHandler(priceSave); - decHandler(trade); decHandler(disconnect); decHandler(undress); decHandler(attack); @@ -103,8 +102,7 @@ namespace Commands enum { - COMMAND_TRADE = 0, - COMMAND_PRICELOAD, + COMMAND_PRICELOAD = 0, COMMAND_PRICESAVE, COMMAND_CACHEINFO, COMMAND_DISCONNECT, @@ -155,7 +153,6 @@ enum static const CommandInfo commands[] = { - {"trade", &Commands::trade, -1, true}, {"priceload", &Commands::priceLoad, -1, false}, {"pricesave", &Commands::priceSave, -1, false}, {"cacheinfo", &Commands::cacheInfo, -1, false}, diff --git a/src/defaults.cpp b/src/defaults.cpp index caaf69774..6e095a629 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -336,7 +336,7 @@ DefaultsData* getConfigDefaults() AddDEF("screenActionButton7", InputAction::WINDOW_SKILL); AddDEF("screenActionButton8", InputAction::WINDOW_SOCIAL); AddDEF("screenActionButton9", InputAction::WINDOW_DEBUG); - AddDEF("screenActionButton10", InputAction::TRADE); + AddDEF("screenActionButton10", InputAction::CHANGE_TRADE); AddDEF("screenActionButton11", InputAction::DIRECT_DOWN); AddDEF("screenButtonsFormat", 0); AddDEF("autoresizeminimaps", false); diff --git a/src/input/inputaction.h b/src/input/inputaction.h index dae8cbf53..d278e9799 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -57,7 +57,7 @@ namespace InputAction HIDE_WINDOWS, SIT, SCREENSHOT, - TRADE, + CHANGE_TRADE, PATHFIND, OK, QUIT, @@ -379,6 +379,7 @@ namespace InputAction NAVIGATE, IMITATION, SEND_MAIL, + TRADE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 6657b0909..58688fc27 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3180,6 +3180,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "mail", + true}, + {"keyTradeCommand", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::trade, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "trade", true} }; diff --git a/src/input/pages/basic.cpp b/src/input/pages/basic.cpp index 2c784d804..ee65d48fe 100644 --- a/src/input/pages/basic.cpp +++ b/src/input/pages/basic.cpp @@ -162,7 +162,7 @@ SetupActionData setupActionDataBasic[] = { // TRANSLATORS: input action name N_("Enable/Disable Trading"), - InputAction::TRADE, + InputAction::CHANGE_TRADE, "", }, { @@ -171,6 +171,12 @@ SetupActionData setupActionDataBasic[] = InputAction::OPEN_TRADE, "", }, + { + // TRANSLATORS: input action name + N_("Start trade with target"), + InputAction::TRADE, + "", + }, { // TRANSLATORS: input action name N_("Follow selected player"), -- cgit v1.2.3-70-g09d2