summaryrefslogtreecommitdiff
path: root/src/party.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/party.cpp')
-rw-r--r--src/party.cpp83
1 files changed, 43 insertions, 40 deletions
diff --git a/src/party.cpp b/src/party.cpp
index a4f1b940..51a86360 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -1,8 +1,8 @@
/*
- * Aethyra
- * Copyright 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
+ * The Mana World
+ * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
*
- * This file is part of Aethyra.
+ * This file is part of The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,17 +23,17 @@
#include "localplayer.h"
#include "party.h"
+#include "gui/widgets/chattab.h"
#include "gui/chat.h"
#include "gui/confirm_dialog.h"
#include "net/messageout.h"
-#include "net/protocol.h"
+#include "net/ea/protocol.h"
#include "utils/gettext.h"
#include "utils/strprintf.h"
-Party::Party(ChatWindow *chat, Network *network) :
- mChat(chat),
+Party::Party(Network *network) :
mNetwork(network),
mInviteListener(network, &mInParty)
{
@@ -53,7 +53,7 @@ void Party::respond(const std::string &command, const std::string &args)
}
if (command == "settings")
{
- mChat->chatLog(_("Not yet implemented!"), BY_SERVER);
+ localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER);
return;
/*
MessageOut outMsg(mNetwork);
@@ -62,14 +62,14 @@ void Party::respond(const std::string &command, const std::string &args)
outMsg.writeInt16(0); // Item
*/
}
- mChat->chatLog(_("Party command not known."), BY_SERVER);
+ localChatTab->chatLog(_("Party command not known."), BY_SERVER);
}
void Party::create(const std::string &party)
{
if (party.empty())
{
- mChat->chatLog(_("Party name is missing."), BY_SERVER);
+ localChatTab->chatLog(_("Party name is missing."), BY_SERVER);
return;
}
MessageOut outMsg(mNetwork);
@@ -82,7 +82,7 @@ void Party::leave(const std::string &args)
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_PARTY_LEAVE);
- mChat->chatLog(_("Left party."), BY_SERVER);
+ localChatTab->chatLog(_("Left party."), BY_SERVER);
mInParty = false;
}
@@ -90,12 +90,12 @@ void Party::createResponse(bool ok)
{
if (ok)
{
- mChat->chatLog(_("Party successfully created."), BY_SERVER);
+ localChatTab->chatLog(_("Party successfully created."), BY_SERVER);
mInParty = true;
}
else
{
- mChat->chatLog(_("Could not create party."), BY_SERVER);
+ localChatTab->chatLog(_("Could not create party."), BY_SERVER);
}
}
@@ -104,15 +104,15 @@ void Party::inviteResponse(const std::string &nick, int status)
switch (status)
{
case 0:
- mChat->chatLog(strprintf(_("%s is already a member of a party."),
+ localChatTab->chatLog(strprintf(_("%s is already a member of a party."),
nick.c_str()), BY_SERVER);
break;
case 1:
- mChat->chatLog(strprintf(_("%s refused your invitation."),
+ localChatTab->chatLog(strprintf(_("%s refused your invitation."),
nick.c_str()), BY_SERVER);
break;
case 2:
- mChat->chatLog(strprintf(_("%s is now a member of your party."),
+ localChatTab->chatLog(strprintf(_("%s is now a member of your party."),
nick.c_str()), BY_SERVER);
break;
}
@@ -124,7 +124,7 @@ void Party::invitedAsk(const std::string &nick, int gender,
mPartyName = partyName; /* Quick and nasty - needs redoing */
if (nick.empty())
{
- mChat->chatLog(_("You can\'t have a blank party name!"), BY_SERVER);
+ localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER);
return;
}
mCreating = false;
@@ -147,7 +147,7 @@ void Party::InviteListener::action(const gcn::ActionEvent &event)
void Party::leftResponse(const std::string &nick)
{
- mChat->chatLog(strprintf(_("%s has left your party."), nick.c_str()),
+ localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()),
BY_SERVER);
}
@@ -159,47 +159,50 @@ void Party::receiveChat(Being *being, const std::string &msg)
}
if (being->getType() != Being::PLAYER)
{
- mChat->chatLog(_("Party chat received, but being is not a player"),
+ localChatTab->chatLog(_("Party chat received, but being is not a player"),
BY_SERVER);
return;
}
being->setSpeech(msg, SPEECH_TIME);
- mChat->chatLog(being->getName() + " : " + msg, BY_PARTY);
+ localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY);
}
-void Party::help(const std::string &msg)
+void Party::help(const std::string &args)
{
+ // Strip "party " from the front
+ std::string msg = args.substr(6, args.length());
+
if (msg.empty())
{
- mChat->chatLog(_("Command: /party <command> <args>"), BY_SERVER);
- mChat->chatLog(_("where <command> can be one of:"), BY_SERVER);
- mChat->chatLog(_(" /new"), BY_SERVER);
- mChat->chatLog(_(" /create"), BY_SERVER);
- mChat->chatLog(_(" /prefix"), BY_SERVER);
- mChat->chatLog(_(" /leave"), BY_SERVER);
- mChat->chatLog(_("This command implements the partying function."),
+ localChatTab->chatLog(_("Command: /party <command> <args>"), BY_SERVER);
+ localChatTab->chatLog(_("where <command> can be one of:"), BY_SERVER);
+ localChatTab->chatLog(_(" /new"), BY_SERVER);
+ localChatTab->chatLog(_(" /create"), BY_SERVER);
+ localChatTab->chatLog(_(" /prefix"), BY_SERVER);
+ localChatTab->chatLog(_(" /leave"), BY_SERVER);
+ localChatTab->chatLog(_("This command implements the partying function."),
BY_SERVER);
- mChat->chatLog(_("Type /help party <command> for further help."),
+ localChatTab->chatLog(_("Type /help party <command> for further help."),
BY_SERVER);
return;
}
if (msg == "new" || msg == "create")
{
- mChat->chatLog(_("Command: /party new <party-name>"), BY_SERVER);
- mChat->chatLog(_("Command: /party create <party-name>"), BY_SERVER);
- mChat->chatLog(_("These commands create a new party <party-name."),
+ localChatTab->chatLog(_("Command: /party new <party-name>"), BY_SERVER);
+ localChatTab->chatLog(_("Command: /party create <party-name>"), BY_SERVER);
+ localChatTab->chatLog(_("These commands create a new party <party-name."),
BY_SERVER);
return;
}
if (msg == "prefix")
{
- mChat->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER);
- mChat->chatLog(_("This command sets the party prefix character."),
+ localChatTab->chatLog(_("Command: /party prefix <prefix-char>"), BY_SERVER);
+ localChatTab->chatLog(_("This command sets the party prefix character."),
BY_SERVER);
- mChat->chatLog(_("Any message preceded by <prefix-char> is sent to "
+ localChatTab->chatLog(_("Any message preceded by <prefix-char> is sent to "
"the party instead of everyone."), BY_SERVER);
- mChat->chatLog(_("Command: /party prefix"), BY_SERVER);
- mChat->chatLog(_("This command reports the current party prefix "
+ localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER);
+ localChatTab->chatLog(_("This command reports the current party prefix "
"character."), BY_SERVER);
return;
}
@@ -207,11 +210,11 @@ void Party::help(const std::string &msg)
//if (msg == "info")
if (msg == "leave")
{
- mChat->chatLog(_("Command: /party leave"), BY_SERVER);
- mChat->chatLog(_("This command causes the player to leave the party."),
+ localChatTab->chatLog(_("Command: /party leave"), BY_SERVER);
+ localChatTab->chatLog(_("This command causes the player to leave the party."),
BY_SERVER);
return;
}
- mChat->chatLog(_("Unknown /party command."), BY_SERVER);
- mChat->chatLog(_("Type /help party for a list of options."), BY_SERVER);
+ localChatTab->chatLog(_("Unknown /party command."), BY_SERVER);
+ localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER);
}