diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-23 23:16:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-23 23:16:19 +0300 |
commit | c33d54dd45efd88f95014bd41813accb15e76f89 (patch) | |
tree | ec19b20b2f59bebde3afd4c6ef2920fff666b1a9 /src | |
parent | 81a7b06f2ff1fad4b012068b15975bdb5e86a0e4 (diff) | |
download | mv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.gz mv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.bz2 mv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.xz mv-c33d54dd45efd88f95014bd41813accb15e76f89.zip |
Move chat command /ignore into actions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/commands.cpp | 56 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/commands.cpp | 6 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/gui/widgets/tabs/whispertab.cpp | 4 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 11 |
7 files changed, 68 insertions, 16 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index c7607a2cd..7afc7efed 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -66,20 +66,74 @@ #include "gui/windows/shortcutwindow.h" #include "gui/windows/updaterwindow.h" -#include "gui/widgets/tabs/chattab.h" +#include "gui/widgets/tabs/whispertab.h" #include "net/adminhandler.h" #include "net/net.h" +#include "utils/gettext.h" + #include "debug.h" namespace Actions { +static void changeRelation(std::string args, + const PlayerRelation::Relation relation, + const std::string &relationText, + ChatTab *const tab) +{ + if (!tab) + return; + + if (args.empty()) + { + WhisperTab *const whisper = dynamic_cast<WhisperTab* const>(tab); + if (!whisper || whisper->getNick().empty()) + { + // TRANSLATORS: change relation + tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); + return; + } + args = whisper->getNick(); + } + + if (player_relations.getRelation(args) == relation) + { + // TRANSLATORS: change relation + tab->chatLog(strprintf(_("Player already %s!"), + relationText.c_str()), ChatMsgType::BY_SERVER); + return; + } + else + { + player_relations.setRelation(args, relation); + } + + if (player_relations.getRelation(args) == relation) + { + // TRANSLATORS: change relation + tab->chatLog(strprintf(_("Player successfully %s!"), + relationText.c_str()), ChatMsgType::BY_SERVER); + } + else + { + // TRANSLATORS: change relation + tab->chatLog(strprintf(_("Player could not be %s!"), + relationText.c_str()), ChatMsgType::BY_SERVER); + } +} + impHandler(chatAnnounce) { Net::getAdminHandler()->announce(event.args); return true; } +impHandler(chatIgnore) +{ + changeRelation(event.args, PlayerRelation::IGNORED, "ignored", event.tab); + return true; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 9b991ed8a..5f926c6ab 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -28,6 +28,7 @@ struct InputEvent; namespace Actions { decHandler(chatAnnounce); + decHandler(chatIgnore); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index 7491c678e..b4a18aaf2 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -384,12 +384,6 @@ impHandler0(present) return false; } -impHandler(ignore) -{ - changeRelation(event.args, PlayerRelation::IGNORED, "ignored", event.tab); - return true; -} - impHandler(beFriend) { // TRANSLATORS: adding friend command diff --git a/src/commands.h b/src/commands.h index 1dbd3a27d..cc10dfc45 100644 --- a/src/commands.h +++ b/src/commands.h @@ -59,7 +59,6 @@ namespace Commands decHandler(me); decHandler(toggle); decHandler(present); - decHandler(ignore); decHandler(unignore); decHandler(beFriend); decHandler(disregard); @@ -134,8 +133,7 @@ namespace Commands enum { - COMMAND_IGNORE = 0, - COMMAND_UNIGNORE, + COMMAND_UNIGNORE = 0, COMMAND_FRIEND, COMMAND_BEFRIEND, COMMAND_DISREGARD, @@ -218,7 +216,6 @@ enum static const CommandInfo commands[] = { - {"ignore", &Commands::ignore, -1, true}, {"unignore", &Commands::unignore, -1, true}, {"friend", Commands::beFriend, -1, true}, {"befriend", &Commands::beFriend, -1, true}, diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp index ed17bd652..04d390fe4 100644 --- a/src/gui/widgets/tabs/whispertab.cpp +++ b/src/gui/widgets/tabs/whispertab.cpp @@ -103,10 +103,6 @@ bool WhisperTab::handleCommand(const std::string &restrict type, if (chatWindow) chatWindow->defaultTab(); } - else if (type == "ignore") - { - CommandHandler::invokeCommand(COMMAND_IGNORE, mNick, this); - } else if (type == "unignore") { CommandHandler::invokeCommand(COMMAND_UNIGNORE, mNick, this); diff --git a/src/input/inputaction.h b/src/input/inputaction.h index 36adc4759..1f59fc288 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -350,6 +350,7 @@ namespace InputAction WHISPER, QUERY, CLEAR_CHAT_TAB, + IGNORE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index b5498427d..fc0e26755 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -2919,7 +2919,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "clear", - false} + false}, + {"keyIgnore", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::chatIgnore, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "ignore", + true} }; #endif // INPUT_INPUTACTIONMAP_H |