diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-12-11 02:10:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-12-11 02:10:20 +0300 |
commit | f351cda87ca7dcfad1772e78ebdecd184a06e385 (patch) | |
tree | 340b6caec0106cb480afb7f7fb97ee78ab6516ae | |
parent | 48d66daa641c58d68a4150b1f6bf958dfb8ecb13 (diff) | |
download | plus-f351cda87ca7dcfad1772e78ebdecd184a06e385.tar.gz plus-f351cda87ca7dcfad1772e78ebdecd184a06e385.tar.bz2 plus-f351cda87ca7dcfad1772e78ebdecd184a06e385.tar.xz plus-f351cda87ca7dcfad1772e78ebdecd184a06e385.zip |
Add chat command for silent sendong whisper message.
New chat command: /w2 name message
Aliases: /whisper2
/msg2
-rw-r--r-- | src/actions/chat.cpp | 53 | ||||
-rw-r--r-- | src/actions/chat.h | 1 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 9 |
4 files changed, 48 insertions, 16 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index ac834c6f5..142f9000e 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -178,33 +178,32 @@ impHandler0(scrollChatDown) return false; } -impHandler(msg) +static bool splitWhisper(const std::string &args, + std::string &recvnick, + std::string &message) { - std::string recvnick; - std::string message; - - if (event.args.substr(0, 1) == "\"") + if (args.substr(0, 1) == "\"") { - const size_t pos = event.args.find('"', 1); + const size_t pos = args.find('"', 1); if (pos != std::string::npos) { - recvnick = event.args.substr(1, pos - 1); - if (pos + 2 < event.args.length()) - message = event.args.substr(pos + 2, event.args.length()); + recvnick = args.substr(1, pos - 1); + if (pos + 2 < args.length()) + message = args.substr(pos + 2, args.length()); } } else { - const size_t pos = event.args.find(" "); + const size_t pos = args.find(" "); if (pos != std::string::npos) { - recvnick = event.args.substr(0, pos); - if (pos + 1 < event.args.length()) - message = event.args.substr(pos + 1, event.args.length()); + recvnick = args.substr(0, pos); + if (pos + 1 < args.length()) + message = args.substr(pos + 1, args.length()); } else { - recvnick = std::string(event.args); + recvnick = std::string(args); message.clear(); } } @@ -219,9 +218,21 @@ impHandler(msg) toLower(playerName); toLower(tempNick); - if (tempNick.compare(playerName) == 0 || event.args.empty()) - return true; + if (tempNick.compare(playerName) == 0 || args.empty()) + return false; + + return true; + } + return false; +} +impHandler(msg) +{ + std::string recvnick; + std::string message; + + if (splitWhisper(event.args, recvnick, message)) + { chatWindow->addWhisper(recvnick, message, ChatMsgType::BY_PLAYER); } else @@ -233,6 +244,16 @@ impHandler(msg) return true; } +impHandler(msg2) +{ + std::string recvnick; + std::string message; + + if (splitWhisper(event.args, recvnick, message)) + chatHandler->privateMessage(recvnick, message); + return true; +} + impHandler(query) { const std::string &args = event.args; diff --git a/src/actions/chat.h b/src/actions/chat.h index 5bf689ac9..321357553 100644 --- a/src/actions/chat.h +++ b/src/actions/chat.h @@ -36,6 +36,7 @@ namespace Actions decHandler(scrollChatUp); decHandler(scrollChatDown); decHandler(msg); + decHandler(msg2); decHandler(query); decHandler(clearChatTab); decHandler(createParty); diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 7e8a15ab1..b3b95a8f7 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -492,6 +492,7 @@ namespace InputAction CONTEXT_MENU, BUY, SELL, + WHISPER2, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index f4579881c..8e14f911c 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -4171,6 +4171,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::GAME, "sell", false}, + {"keyWhisper2", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::msg2, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "w2|whisper2|msg2", + true}, }; #endif // INPUT_INPUTACTIONMAP_H |