From 308302f858d24d2cc1b1601b100324e2baa50765 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 8 Feb 2010 16:20:39 -0700 Subject: Move party creation command from eA's PartyTab to CommandHandler Also fix party invite by name when you aren't in a party. --- src/commandhandler.cpp | 22 ++++++++++++++++++++++ src/commandhandler.h | 5 +++++ src/net/ea/gui/partytab.cpp | 10 +--------- src/net/ea/partyhandler.cpp | 12 +++++++++++- 4 files changed, 39 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 18844d74..3b527a37 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -98,6 +98,10 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) { handleClear(args, tab); } + else if (type == "createparty") + { + handleCreateParty(args, tab); + } else if (type == "party") { handleParty(args, tab); @@ -170,6 +174,7 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) tab->chatLog(_("/list > Display all public channels")); tab->chatLog(_("/join > Join or create a channel")); + tab->chatLog(_("/createparty > Create a new party")); tab->chatLog(_("/party > Invite a user to party")); tab->chatLog(_("/record > Start recording the chat to an external file")); @@ -243,6 +248,11 @@ void CommandHandler::handleHelp(const std::string &args, ChatTab *tab) tab->chatLog(_("This command tries to make a tab for whispers between" "you and .")); } + else if (args == "createparty") + { + tab->chatLog(_("Command: /createparty ")); + tab->chatLog(_("This command creates a new party called .")); + } else if (args == "party") { tab->chatLog(_("Command: /party ")); @@ -393,6 +403,18 @@ void CommandHandler::handleListChannels(const std::string &args, ChatTab *tab) Net::getChatHandler()->channelList(); } +void CommandHandler::handleCreateParty(const std::string &args, ChatTab *tab) +{ + if (args.empty()) + { + tab->chatLog(_("Party name is missing."), BY_SERVER); + } + else + { + Net::getPartyHandler()->create(args); + } +} + void CommandHandler::handleParty(const std::string &args, ChatTab *tab) { if (args != "") diff --git a/src/commandhandler.h b/src/commandhandler.h index 4c108816..0ad513ea 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -103,6 +103,11 @@ class CommandHandler */ void handleClear(const std::string &args, ChatTab *tab); + /** + * Handle a createparty command. + */ + void handleCreateParty(const std::string &args, ChatTab *tab); + /** * Handle a party command. */ diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index e6526a3a..bcb449ab 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -55,8 +55,6 @@ void PartyTab::handleInput(const std::string &msg) void PartyTab::showHelp() { chatLog(_("/help > Display this help.")); - chatLog(_("/create > Create a new party")); - chatLog(_("/new > Alias of create")); chatLog(_("/invite > Invite a player to your party")); chatLog(_("/leave > Leave the party you are in")); chatLog(_("/kick > Kick some one from the party you are in")); @@ -68,13 +66,7 @@ bool PartyTab::handleCommand(const std::string &type, const std::string &args) { if (type == "help") { - if (args == "create" || args == "new") - { - chatLog(_("Command: /new ")); - chatLog(_("Command: /create ")); - chatLog(_("These commands create a new party called .")); - } - else if (args == "invite") + if (args == "invite") { chatLog(_("Command: /invite ")); chatLog(_("This command invites to party with you.")); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 030914b4..ddbe567f 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -320,7 +320,17 @@ void PartyHandler::invite(Player *player) void PartyHandler::invite(const std::string &name) { - partyTab->chatLog(_("Inviting like this isn't supported at the moment."), BY_SERVER); + if (partyTab) + { + partyTab->chatLog(_("Inviting like this isn't supported at the moment."), + BY_SERVER); + } + else + { + localChatTab->chatLog(_("You can only inivte when you are in a party!"), + BY_SERVER); + } + // TODO? } -- cgit v1.2.3-70-g09d2