diff options
author | David Athay <ko2fan@gmail.com> | 2008-07-08 15:16:22 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-07-08 15:16:22 +0000 |
commit | 3be4300f12d4e936a1beea0021b14cf6313ee3b9 (patch) | |
tree | d7c7efab8b6e2c0920da42cc5fe01203e3aae044 /src/gui/chat.cpp | |
parent | 4ca8675700dfae625376c4afdd30b8590d68087e (diff) | |
download | mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.gz mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.bz2 mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.tar.xz mana-3be4300f12d4e936a1beea0021b14cf6313ee3b9.zip |
#359 patch by Scraggy
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 90 |
1 files changed, 83 insertions, 7 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5e3aaf60..2894bb70 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -275,13 +275,25 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (msg.substr(0, IS_HELP_LENGTH) == IS_HELP) { - chatLog("-- Help --", BY_SERVER); - chatLog("/help: Display this help.", BY_SERVER); - chatLog("/announce: Global announcement (GM only)", BY_SERVER); - chatLog("/where: Display map name", BY_SERVER); - chatLog("/who: Display number of online users", BY_SERVER); - chatLog("/clear: Clears this window", BY_SERVER); - chatLog("/whisper <nick> <message>: Sends a private <message> to <nick>", BY_SERVER); + msg.erase(0, IS_HELP_LENGTH + 1); + trim(msg); + std::size_t space = msg.find(" "); + std::string msg1; + if (space == std::string::npos) + { + msg1 = ""; + } + else + { + msg1 = msg.substr(space + 1, msg.length()); + msg = msg.substr(0, space); + } + if (msg != "" && msg.at(0) == '/') + { + msg.erase(0, 1); + } + trim(msg1); + help(msg, msg1); } else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE) { @@ -469,3 +481,67 @@ ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } +void ChatWindow::help(const std::string &msg1, const std::string &msg2) +{ + chatLog("-- Help --", BY_SERVER); + if (msg1 == "") + { + chatLog("/announce: Global announcement (GM only)", BY_SERVER); + chatLog("/clear: Clears this window", BY_SERVER); + chatLog("/help: Display this help.", BY_SERVER); + chatLog("/where: Display map name", BY_SERVER); + chatLog("/whisper <nick> <message>: Sends a private <message>" + " to <nick>", BY_SERVER); + chatLog("/who: Display number of online users", BY_SERVER); + chatLog("For more information, type /help <command>", BY_SERVER); + return; + } + if (msg1 == "announce") + { + chatLog("Command: /announce <msg>", BY_SERVER); + chatLog("*** only available to a GM ***", BY_SERVER); + chatLog("This command sends the message <msg> to " + "all players currently online.", BY_SERVER); + return; + } + if (msg1 == "clear") + { + chatLog("Command: /clear", BY_SERVER); + chatLog("This command clears the chat log of previous chat.", + BY_SERVER); + return; + } + if (msg1 == "help") + { + chatLog("Command: /help", BY_SERVER); + chatLog("This command displays a list of all commands available.", + BY_SERVER); + chatLog("Command: /help <command>", BY_SERVER); + chatLog("This command displays help on <command>.", BY_SERVER); + return; + } + if (msg1 == "where") + { + chatLog("Command: /where", BY_SERVER); + chatLog("This command displays the name of the current map.", + BY_SERVER); + return; + } + if (msg1 == "whisper") + { + chatLog("Command: /whisper <nick> <msg>", BY_SERVER); + chatLog("This command sends the message <msg> to <nick.", BY_SERVER); + chatLog("If the <nick> has spaces in it, enclose it in " + "double quotes (\").", BY_SERVER); + return; + } + if (msg1 == "who") + { + chatLog("Command: /who", BY_SERVER); + chatLog("This command displays the number of players currently " + "online.", BY_SERVER); + return; + } + chatLog("Unknown command.", BY_SERVER); + chatLog("Type /help for a list of commands.", BY_SERVER); +} |