summaryrefslogtreecommitdiff
path: root/src/actions
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-23 23:16:19 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-23 23:16:19 +0300
commitc33d54dd45efd88f95014bd41813accb15e76f89 (patch)
treeec19b20b2f59bebde3afd4c6ef2920fff666b1a9 /src/actions
parent81a7b06f2ff1fad4b012068b15975bdb5e86a0e4 (diff)
downloadmv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.gz
mv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.bz2
mv-c33d54dd45efd88f95014bd41813accb15e76f89.tar.xz
mv-c33d54dd45efd88f95014bd41813accb15e76f89.zip
Move chat command /ignore into actions.
Diffstat (limited to 'src/actions')
-rw-r--r--src/actions/commands.cpp56
-rw-r--r--src/actions/commands.h1
2 files changed, 56 insertions, 1 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