summaryrefslogtreecommitdiff
path: root/src/gui/partywindow.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-29 20:35:19 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-29 20:36:58 -0600
commitbbf4d657e77fd39887b9941af1fe75a5ec27d988 (patch)
treed03c2973cff4d11e2eddbb856483369255ee40af /src/gui/partywindow.cpp
parent985e65f31b9cc06f13b733ddd5c7a9daa1331e21 (diff)
downloadmana-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.gz
mana-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.bz2
mana-bbf4d657e77fd39887b9941af1fe75a5ec27d988.tar.xz
mana-bbf4d657e77fd39887b9941af1fe75a5ec27d988.zip
Fix up eAthena party handling some more
Diffstat (limited to 'src/gui/partywindow.cpp')
-rw-r--r--src/gui/partywindow.cpp86
1 files changed, 54 insertions, 32 deletions
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp
index f5cebdfd..d2fd7173 100644
--- a/src/gui/partywindow.cpp
+++ b/src/gui/partywindow.cpp
@@ -21,7 +21,6 @@
#include "gui/partywindow.h"
-#include "gui/widgets/avatar.h"
#include "gui/widgets/chattab.h"
#ifdef TMWSERV_SUPPORT
@@ -49,7 +48,7 @@ PartyWindow::PartyWindow() : Window(_("Party"))
PartyWindow::~PartyWindow()
{
- mPartyMembers.clear();
+ mMembers.clear();
}
void PartyWindow::draw(gcn::Graphics *graphics)
@@ -57,61 +56,84 @@ void PartyWindow::draw(gcn::Graphics *graphics)
Window::draw(graphics);
}
-void PartyWindow::addPartyMember(const std::string &memberName)
+PartyMember *PartyWindow::findMember2(int id)
{
- // check to see if player is already in the party
- PartyList::iterator itr = mPartyMembers.begin(),
- itr_end = mPartyMembers.end();
+ PartyMember *member = findMember(id);
+
+ if (!member)
+ {
+ member = new PartyMember;
+ member->avatar = new Avatar("");
+ add(member->avatar, 0, (mMembers.size() - 1) * 14);
+ mMembers[id] = member;
+ }
+
+ return member;
+}
+
+int PartyWindow::findMember(const std::string &name)
+{
+ PartyList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr).name == memberName)
+ if ((*itr).second->name == name)
{
- // already in the party, dont add
- return;
+ return (*itr).first;
}
++itr;
}
- // create new party member
- PartyMember player;
- player.name = memberName;
- mPartyMembers.push_back(player);
+ return -1;
+}
- // add avatar of the new member to window
- Avatar *avatar = new Avatar(memberName);
- add(avatar, 0, (mPartyMembers.size() - 1)*14);
+void PartyWindow::updateMember(int id, const std::string &memberName,
+ bool leader, bool online)
+{
+ // create new party member
+ PartyMember *player = findMember2(id);
+ player->id = id;
+ player->name = memberName;
+ player->leader = leader;
+ player->online = online;
+ player->avatar->setName(memberName);
+ player->avatar->setOnline(online);
// show the window
- if (mPartyMembers.size() > 0)
+ if (mMembers.size() > 0)
{
setVisible(true);
}
}
-void PartyWindow::removePartyMember(const std::string &memberName)
+void PartyWindow::removeMember(int id)
{
- // remove the party member
- PartyList::iterator itr = mPartyMembers.begin(),
- itr_end = mPartyMembers.end();
-
- while (itr != itr_end)
- {
- if ((*itr).name == memberName)
- {
- mPartyMembers.erase(itr);
- break;
- }
- ++itr;
- }
+ mMembers.erase(id);
// if no-one left, remove the party window
- if (mPartyMembers.size() < 1)
+ if (mMembers.size() < 1)
{
setVisible(false);
}
}
+void PartyWindow::removeMember(const std::string &name)
+{
+ removeMember(findMember(name));
+}
+
+void PartyWindow::updateOnlne(int id, bool online)
+{
+ PartyMember *player = findMember(id);
+
+ if (!player)
+ return;
+
+ player->online = online;
+ player->avatar->setOnline(online);
+}
+
void PartyWindow::showPartyInvite(const std::string &inviter,
const std::string &partyName)
{