diff options
author | David Athay <ko2fan@gmail.com> | 2008-11-13 18:12:37 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-11-13 18:12:37 +0000 |
commit | 5624bb7719cbed3b0eaa93cf5b55906ab9ad83a5 (patch) | |
tree | 1f351bf23da992f97cfff4db38d0919090b5cf75 /src/gui/partywindow.cpp | |
parent | 218ab7cb408cee2148e87a15f8177b0a0a82c66a (diff) | |
download | mana-5624bb7719cbed3b0eaa93cf5b55906ab9ad83a5.tar.gz mana-5624bb7719cbed3b0eaa93cf5b55906ab9ad83a5.tar.bz2 mana-5624bb7719cbed3b0eaa93cf5b55906ab9ad83a5.tar.xz mana-5624bb7719cbed3b0eaa93cf5b55906ab9ad83a5.zip |
Added avatars to party window
Diffstat (limited to 'src/gui/partywindow.cpp')
-rw-r--r-- | src/gui/partywindow.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 484d81b0..1b963dae 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -24,51 +24,61 @@ #include "partywindow.h" #include "chat.h" +#include "widgets/avatar.h" + #include "../utils/gettext.h" #include "../net/chatserver/party.h" PartyWindow::PartyWindow() : Window(_("Party")) { setVisible(false); + setResizable(false); + setCaption(_("Party")); + setCloseButton(true); + setMinWidth(110); + setMinHeight(200); + setDefaultSize(620, 300, 110, 200); + + loadWindowState("Party"); } PartyWindow::~PartyWindow() { - PartyList::iterator itr = mPartyMembers.begin(), - itr_end = mPartyMembers.end(); - - while (itr != itr_end) - { - delete (*itr); - } - mPartyMembers.clear(); } void PartyWindow::draw(gcn::Graphics *graphics) { - + Window::draw(graphics); } void PartyWindow::addPartyMember(const std::string &memberName) { - PartyMember *player = new PartyMember; + // check to see if player is already in the party PartyList::iterator itr = mPartyMembers.begin(), itr_end = mPartyMembers.end(); while (itr != itr_end) { - if ((*itr)->name == memberName) + if ((*itr).name == memberName) { + // already in the party, dont add return; } ++itr; } - player->name = memberName; + // create new party member + PartyMember player; + player.name = memberName; mPartyMembers.push_back(player); - if (mPartyMembers.size() > 1) + // add avatar of the new member to window + Avatar *avatar = new Avatar(memberName); + add(avatar, 0, (mPartyMembers.size() - 1)*14); + + // show the window + if (mPartyMembers.size() > 0) { setVisible(true); } @@ -76,12 +86,13 @@ void PartyWindow::addPartyMember(const std::string &memberName) void PartyWindow::removePartyMember(const std::string &memberName) { + // remove the party member PartyList::iterator itr = mPartyMembers.begin(), itr_end = mPartyMembers.end(); while (itr != itr_end) { - if ((*itr)->name == memberName) + if ((*itr).name == memberName) { mPartyMembers.erase(itr); break; @@ -89,6 +100,7 @@ void PartyWindow::removePartyMember(const std::string &memberName) ++itr; } + // if no-one left, remove the party window if (mPartyMembers.size() < 1) { setVisible(false); @@ -97,15 +109,19 @@ void PartyWindow::removePartyMember(const std::string &memberName) void PartyWindow::showPartyInvite(const std::string &inviter) { + // check there isnt already an invite showing if (mPartyInviter != "") { chatWindow->chatLog("Received party request, but one already exists", BY_SERVER); return; } + + // log invite std::string msg = inviter + " has invited you to join their party"; chatWindow->chatLog(msg, BY_SERVER); + // show invite acceptDialog = new ConfirmDialog("Accept Party Invite", msg, this); acceptDialog->addActionListener(this); @@ -116,8 +132,10 @@ void PartyWindow::action(const gcn::ActionEvent &event) { const std::string &eventId = event.getId(); + // check if they accepted the invite if (eventId == "yes") { + chatWindow->chatLog("Accepted invite from " + mPartyInviter); Net::ChatServer::Party::acceptInvite(mPartyInviter); mPartyInviter = ""; } |