diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/commandhandler.cpp | 117 | ||||
-rw-r--r-- | src/commandhandler.h | 30 |
3 files changed, 116 insertions, 36 deletions
@@ -1,3 +1,8 @@ +2008-07-07 David Athay <ko2fan@gmail.com> + + * src/commandhandler.hpp, src/commandhandler.cpp: Added help for each + command based on mantis bug #359, thanks to Scraggy. + 2008-07-05 David Athay <ko2fan@gmail.com> * src/game.cpp, src/gui/gui.cpp: Allow foreign keyboards to use alt key diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 465f572d..7e20deff 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -20,8 +20,8 @@ * * $Id$ */ - - + + #include "commandhandler.h" #include "channelmanager.h" #include "channel.h" @@ -42,7 +42,7 @@ void CommandHandler::handleCommand(const std::string &command) } else if (type == "help") { - handleHelp(); + handleHelp(args); } else if (type == "where") { @@ -56,19 +56,21 @@ void CommandHandler::handleCommand(const std::string &command) { handleMsg(args); } + /* else if (type == "channel") { handleChannel(args); } + */ else if (type == "join") { handleJoin(args); } - else if (type == "listchannels") + else if (type == "list") { handleListChannels(); } - else if (type == "listusers") + else if (type == "users") { handleListUsers(); } @@ -99,22 +101,95 @@ void CommandHandler::handleAnnounce(const std::string &args) Net::ChatServer::announce(args); } -void CommandHandler::handleHelp() +void CommandHandler::handleHelp(const std::string &args) { - chatWindow->chatLog("-- Help --"); - chatWindow->chatLog("/help > Display this help."); - chatWindow->chatLog("/announce > Global announcement (GM only)"); - chatWindow->chatLog("/where > Display map name"); - chatWindow->chatLog("/who > Display number of online users"); - chatWindow->chatLog("/msg > Send a private message to a user"); - chatWindow->chatLog("/listchannels > Display all public channels"); - chatWindow->chatLog("/listusers > Lists the users in the current channel"); - chatWindow->chatLog("/channel > Register a new channel"); - chatWindow->chatLog("/join > Join an already registered channel"); - chatWindow->chatLog("/topic > Set the topic of the current channel"); - chatWindow->chatLog("/quit > Leave a channel"); - chatWindow->chatLog("/admin > Send a command to the server (GM only)"); - chatWindow->chatLog("/clear > Clears this window"); + chatWindow->chatLog("-- Help --", BY_SERVER); + if (args == "") + { + chatWindow->chatLog("-- Help --"); + chatWindow->chatLog("/help > Display this help."); + chatWindow->chatLog("/announce > Global announcement (GM only)"); + chatWindow->chatLog("/where > Display map name"); + chatWindow->chatLog("/who > Display number of online users"); + chatWindow->chatLog("/msg > Send a private message to a user"); + chatWindow->chatLog("/list > Display all public channels"); + chatWindow->chatLog("/users > Lists the users in the current channel"); +// chatWindow->chatLog("/channel > Register a new channel"); + chatWindow->chatLog("/join > Join an already registered channel"); + chatWindow->chatLog("/topic > Set the topic of the current channel"); + chatWindow->chatLog("/quit > Leave a channel"); + chatWindow->chatLog("/admin > Send a command to the server (GM only)"); + chatWindow->chatLog("/clear > Clears this window"); + chatWindow->chatLog("For more information, type /help <command>"); + } + else if (args == "admin") + { + chatWindow->chatLog("Command: /admin <command>"); + chatWindow->chatLog("*** only available to a GM ***"); + chatWindow->chatLog("This command sends an admin command to the server."); + } + else if (args == "announce") + { + chatWindow->chatLog("Command: /announce <msg>"); + chatWindow->chatLog("*** only available to a GM ***"); + chatWindow->chatLog("This command sends the message <msg> to " + "all players currently online."); + } + else if (args == "clear") + { + chatWindow->chatLog("Command: /clear"); + chatWindow->chatLog("This command clears the chat log of previous chat."); + } + else if (args == "help") + { + chatWindow->chatLog("Command: /help"); + chatWindow->chatLog("This command displays a list of all commands available."); + chatWindow->chatLog("Command: /help <command>"); + chatWindow->chatLog("This command displays help on <command>."); + } + else if (args == "join") + { + chatWindow->chatLog("Command: /join <channel>"); + chatWindow->chatLog("This command makes you enter <channel>."); + } + else if (args == "list") + { + chatWindow->chatLog("Command: /list"); + chatWindow->chatLog("This command shows a list of all channels."); + } + else if (args == "msg") + { + chatWindow->chatLog("Command: /msg <nick> <message>"); + chatWindow->chatLog("This command sends the text <message> to <nick>."); + chatWindow->chatLog("If the <nick> has spaces in it, enclose it in " + "double quotes (\")."); + } + else if (args == "topic") + { + chatWindow->chatLog("Command: /topic <message>"); + chatWindow->chatLog("This command sets the topic to <message>."); + } + else if (args == "users") + { + chatWindow->chatLog("Command: /users <channel>"); + chatWindow->chatLog("This command shows the users in <channel>."); + } + else if (args == "where") + { + chatWindow->chatLog("Command: /where"); + chatWindow->chatLog("This command displays the name of the current map."); + } + else if (args == "who") + { + chatWindow->chatLog("Command: /who"); + chatWindow->chatLog("This command displays the number of players currently " + "online."); + } + else + { + chatWindow->chatLog("Unknown command."); + chatWindow->chatLog("Type /help for a list of commands."); + } } void CommandHandler::handleWhere() @@ -124,7 +199,7 @@ void CommandHandler::handleWhere() void CommandHandler::handleWho() { - + } void CommandHandler::handleMsg(const std::string &args) diff --git a/src/commandhandler.h b/src/commandhandler.h index c415ba4f..ef6da33d 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -20,7 +20,7 @@ * * $Id$ */ - + #ifndef _TMW_COMMANDHANDLER_H #define _TMW_COMMANDHANDLER_H @@ -36,63 +36,63 @@ class CommandHandler * Constructor */ CommandHandler() {} - + /** * Destructor */ ~CommandHandler() {} - + /** * Parse and handle the given command. */ void handleCommand(const std::string &command); - + private: /** * Handle an announce command. */ void handleAnnounce(const std::string &args); - + /** * Handle a help command. */ - void handleHelp(); - + void handleHelp(const std::string &args); + /** * Handle a where command. */ void handleWhere(); - + /** * Handle a who command. */ void handleWho(); - + /** * Handle a msg command. */ void handleMsg(const std::string &args); - + /** * Handle a channel command. */ void handleChannel(const std::string &args); - + /** * Handle a join command. */ void handleJoin(const std::string &args); - + /** * Handle a listchannels command. */ void handleListChannels(); - + /** * Handle a listusers command. */ void handleListUsers(); - + /** * Handle a topic command. */ @@ -102,7 +102,7 @@ class CommandHandler * Handle a quit command. */ void handleQuit(); - + /** * Handle a clear command. */ |