From 051b5fc10eaec4f4aec1de8e79f2feae60f0e084 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 Aug 2014 20:34:25 +0300 Subject: Move chat command /where into actions. --- src/actions/actions.cpp | 13 +++++++++++++ src/actions/actions.h | 1 + src/commands.cpp | 10 ---------- src/commands.h | 5 +---- src/input/inputaction.h | 1 + src/input/inputactionmap.h | 9 +++++++++ src/input/pages/other.cpp | 6 ++++++ 7 files changed, 31 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 9273de8ab..6a8ba0d5a 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -522,4 +522,17 @@ impHandler0(ipcToggle) return true; } +impHandler(where) +{ + ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab; + if (!tab) + return false; + std::ostringstream where; + where << Game::instance()->getCurrentMapName() << ", coordinates: " + << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize) + << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize); + tab->chatLog(where.str(), ChatMsgType::BY_SERVER); + return true; +} + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index 44812e826..21085ea48 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -55,6 +55,7 @@ namespace Actions decHandler(showWindows); decHandler(openTrade); decHandler(ipcToggle); + decHandler(where); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index 1d273c90a..6a1094b51 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -251,16 +251,6 @@ static void outStringNormal(ChatTab *const tab, } } -impHandler(where) -{ - std::ostringstream where; - where << Game::instance()->getCurrentMapName() << ", coordinates: " - << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize) - << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize); - event.tab->chatLog(where.str(), ChatMsgType::BY_SERVER); - return true; -} - impHandler0(who) { Net::getChatHandler()->who(); diff --git a/src/commands.h b/src/commands.h index c55b7af0f..f6d1d3f4f 100644 --- a/src/commands.h +++ b/src/commands.h @@ -51,7 +51,6 @@ struct CommandInfo final namespace Commands { - decHandler(where); decHandler(who); decHandler(msg); decHandler(query); @@ -139,8 +138,7 @@ namespace Commands enum { - COMMAND_WHERE = 0, - COMMAND_WHO, + COMMAND_WHO = 0, COMMAND_MSG, COMMAND_WHISPER, COMMAND_W, @@ -231,7 +229,6 @@ enum static const CommandInfo commands[] = { - {"where", &Commands::where, -1, false}, {"who", &Commands::who, -1, false}, {"msg", Commands::msg, -1, true}, {"whisper", Commands::msg, -1, true}, diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 365f11571..f0f999d2e 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -345,6 +345,7 @@ namespace InputAction IGNORE_ALL_WHISPERS, CHAT_ANNOUNCE, IPC_TOGGLE, + WHERE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index b1807760d..241ed632a 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -2874,6 +2874,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "ipctoggle", + false}, + {"keyWhere", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::where, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "where", false} }; diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp index 70b6b95d5..d1a7d0bfd 100644 --- a/src/input/pages/other.cpp +++ b/src/input/pages/other.cpp @@ -195,6 +195,12 @@ SetupActionData setupActionDataOther[] = InputAction::IPC_TOGGLE, "", }, + { + // TRANSLATORS: input action name + N_("Show information about position in chat"), + InputAction::WHERE, + "", + }, { // TRANSLATORS: input action name N_("Show onscreen keyboard"), -- cgit v1.2.3-60-g2f50