diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-19 09:01:46 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-19 09:01:46 -0600 |
commit | 822690170b501397b86626e13b5a542712a1719d (patch) | |
tree | 327bd24839195d677beca694b9a8fca7b18245ca /src/commandhandler.cpp | |
parent | 124865b5d67c8c7b199046d19380e1e154ee99e4 (diff) | |
download | mana-822690170b501397b86626e13b5a542712a1719d.tar.gz mana-822690170b501397b86626e13b5a542712a1719d.tar.bz2 mana-822690170b501397b86626e13b5a542712a1719d.tar.xz mana-822690170b501397b86626e13b5a542712a1719d.zip |
Flesh out eAtehan party handling
Diffstat (limited to 'src/commandhandler.cpp')
-rw-r--r-- | src/commandhandler.cpp | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 2f9969e8..81507791 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -56,7 +56,7 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) { // Nothing to do } - if (type == "announce") + else if (type == "announce") { handleAnnounce(args, tab); } @@ -114,6 +114,22 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) } } +char CommandHandler::parseBoolean(const std::string &value) +{ + std::string opt = value.substr(0, 1); + + if (opt == "1" || + opt == "y" || opt == "Y" || + opt == "t" || opt == "T") + return 1; + else if (opt == "0" || + opt == "n" || opt == "N" || + opt == "f" || opt == "F") + return 0; + else + return -1; +} + void CommandHandler::handleAnnounce(const std::string &args, ChatTab *tab) { Net::getAdminHandler()->announce(args); @@ -374,27 +390,21 @@ void CommandHandler::handleToggle(const std::string &args, ChatTab *tab) return; } - std::string opt = args.substr(0, 1); + char opt = parseBoolean(args); - if (opt == "1" || - opt == "y" || opt == "Y" || - opt == "t" || opt == "T") - { - tab->chatLog(_("Return now toggles chat.")); - chatWindow->setReturnTogglesChat(true); - return; - } - else if (opt == "0" || - opt == "n" || opt == "N" || - opt == "f" || opt == "F") + switch (opt) { - tab->chatLog(_("Message now closes chat.")); - chatWindow->setReturnTogglesChat(false); - return; + case 1: + tab->chatLog(_("Return now toggles chat.")); + chatWindow->setReturnTogglesChat(true); + return; + case 0: + tab->chatLog(_("Message now closes chat.")); + chatWindow->setReturnTogglesChat(false); + return; + case -1: + tab->chatLog(strprintf(BOOLEAN_OPTIONS, "toggle")); } - else - tab->chatLog(_("Options to /toggle are \"yes\", \"no\", \"true\", " - "\"false\", \"1\", \"0\".")); } void CommandHandler::handlePresent(const std::string &args, ChatTab *tab) |