diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commandhandler.cpp | 68 | ||||
-rw-r--r-- | src/commandhandler.h | 15 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.cpp | 23 |
3 files changed, 105 insertions, 1 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 0af77398..d2a303e8 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -25,6 +25,7 @@ #include "channel.h" #include "game.h" #include "localplayer.h" +#include "playerrelations.h" #include "gui/widgets/channeltab.h" #include "gui/widgets/chattab.h" @@ -76,6 +77,14 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) { handleQuery(args, tab); } + else if (type == "ignore") + { + handleIgnore(args, tab); + } + else if (type == "unignore") + { + handleUnignore(args, tab); + } else if (type == "join") { handleJoin(args, tab); @@ -154,6 +163,9 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) tab->chatLog(_("/query > Makes a tab for private messages with another user")); tab->chatLog(_("/q > Alias of query")); + tab->chatLog(_("/ignore > ignore a player")); + tab->chatLog(_("/unignore > stop ignoring a player")); + tab->chatLog(_("/list > Display all public channels")); tab->chatLog(_("/join > Join or create a channel")); @@ -192,6 +204,12 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) tab->chatLog(_("Command: /clear")); tab->chatLog(_("This command clears the chat log of previous chat.")); } + else if (args == "ignore") + { + tab->chatLog(_("Command: /ignore <player>")); + tab->chatLog(_("This command ignores the given player reguardless of " + "current relations.")); + } else if (args == "join") { tab->chatLog(_("Command: /join <channel>")); @@ -257,6 +275,12 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) tab->chatLog(_("Command: /toggle")); tab->chatLog(_("This command displays the return toggle status.")); } + else if (args == "unignore") + { + tab->chatLog(_("Command: /unignore <player>")); + tab->chatLog(_("This command stops ignoring the given player if they " + "are being ignored")); + } else if (args == "where") { tab->chatLog(_("Command: /where")); @@ -416,3 +440,47 @@ void CommandHandler::handlePresent(const std::string &args, ChatTab *tab) { chatWindow->doPresent(); } + +void CommandHandler::handleIgnore(const std::string &args, ChatTab *tab) +{ + if (args.empty()) + { + tab->chatLog(_("Please specify a name."), BY_SERVER); + return; + } + + if (player_relations.getRelation(args) == PlayerRelation::IGNORED) + { + tab->chatLog(_("Player already ignored!"), BY_SERVER); + return; + } + else + player_relations.setRelation(args, PlayerRelation::IGNORED); + + if (player_relations.getRelation(args) == PlayerRelation::IGNORED) + tab->chatLog(_("Player successfully ignored!"), BY_SERVER); + else + tab->chatLog(_("Player could not be ignored!"), BY_SERVER); +} + +void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) +{ + if (args.empty()) + { + tab->chatLog(_("Please specify a name."), BY_SERVER); + return; + } + + if (player_relations.getRelation(args) == PlayerRelation::IGNORED) + player_relations.removePlayer(args); + else + { + tab->chatLog(_("Player wasn't ignored!"), BY_SERVER); + return; + } + + if (player_relations.getRelation(args) != PlayerRelation::IGNORED) + tab->chatLog(_("Player no longer ignored!"), BY_SERVER); + else + tab->chatLog(_("Player could not be unignored!"), BY_SERVER); +} diff --git a/src/commandhandler.h b/src/commandhandler.h index 783e400d..eb73f239 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -54,7 +54,10 @@ class CommandHandler static char parseBoolean(const std::string &value); - private: + protected: + friend class ChatTab; + friend class WhisperTab; + /** * Handle an announce command. */ @@ -124,6 +127,16 @@ class CommandHandler * Handle a present command. */ void handlePresent(const std::string &args, ChatTab *tab); + + /** + * Handle an ignore command. + */ + void handleIgnore(const std::string &args, ChatTab *tab); + + /** + * Handle an unignore command. + */ + void handleUnignore(const std::string &args, ChatTab *tab); }; extern CommandHandler *commandHandler; diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 23325108..43c63cc0 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -21,6 +21,7 @@ #include "whispertab.h" +#include "commandhandler.h" #include "localplayer.h" #include "gui/palette.h" @@ -65,6 +66,8 @@ void WhisperTab::handleCommand(const std::string &msg) void WhisperTab::showHelp() { + chatLog(_("/ignore > Ignore the other player")); + chatLog(_("/unignore > Stop ignoring the other player")); chatLog(_("/close > Close the whisper tab")); } @@ -78,6 +81,18 @@ bool WhisperTab::handleCommand(const std::string &type, chatLog(_("Command: /close")); chatLog(_("This command closes the current whisper tab.")); } + else if (args == "ignore") + { + chatLog(_("Command: /ignore")); + chatLog(_("This command ignores the other player reguardless of " + "current relations.")); + } + else if (args == "unignore") + { + chatLog(_("Command: /unignore <player>")); + chatLog(_("This command stops ignoring the other player if they " + "are being ignored")); + } else return false; } @@ -85,6 +100,14 @@ bool WhisperTab::handleCommand(const std::string &type, { delete this; } + else if (type == "ignore") + { + commandHandler->handleIgnore(mNick, this); + } + else if (type == "unignore") + { + commandHandler->handleUnignore(mNick, this); + } else return false; |