diff options
author | Jared Adams <jaxad0127@gmail.com> | 2010-02-08 15:39:02 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-02-08 15:39:02 -0700 |
commit | a4007a7f8f253e90bb189cfb22b3e0c798440bdc (patch) | |
tree | 0b04750b4e108496f58490edd0e91c3d313c34a3 /src | |
parent | 40e1928f3f20efe1be383c4c9a55dffc5506d56f (diff) | |
download | mana-client-a4007a7f8f253e90bb189cfb22b3e0c798440bdc.tar.gz mana-client-a4007a7f8f253e90bb189cfb22b3e0c798440bdc.tar.bz2 mana-client-a4007a7f8f253e90bb189cfb22b3e0c798440bdc.tar.xz mana-client-a4007a7f8f253e90bb189cfb22b3e0c798440bdc.zip |
Fix some bugs in party handling and add HP to AvatarListBox
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 16 | ||||
-rw-r--r-- | src/guild.cpp | 18 | ||||
-rw-r--r-- | src/guild.h | 2 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 7 | ||||
-rw-r--r-- | src/party.cpp | 15 | ||||
-rw-r--r-- | src/party.h | 2 | ||||
-rw-r--r-- | src/player.cpp | 5 |
7 files changed, 62 insertions, 3 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 566cd9de..69c3dfde 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -100,10 +100,22 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (a->getDisplayBold()) graphics->setFont(boldFont); + std::string text; + + if (a->getMaxHp() > 0) + { + text = strprintf("%s %d/%d", a->getName().c_str(), + a->getHp(), a->getMaxHp()); + } + else + { + text = a->getName(); + } + // Draw Name - graphics->drawText(a->getName(), 15, y); + graphics->drawText(text, 15, y); - width = getFont()->getWidth(a->getName()) + 17; // Extra right padding + width = getFont()->getWidth(text) + 17; // Extra right padding if (width > newWidth) { diff --git a/src/guild.cpp b/src/guild.cpp index b8b277e5..8e89a133 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -21,6 +21,9 @@ #include "guild.h" +#include "beingmanager.h" +#include "player.h" + GuildMember::GuildMember(int guildId, int id, const std::string &name): Avatar(name), mId(id) { @@ -131,6 +134,21 @@ void Guild::removeMember(const std::string &name) } } +void Guild::removeFromMembers() +{ + MemberList::iterator itr = mMembers.begin(), + itr_end = mMembers.end(); + while(itr != itr_end) + { + Player *p = dynamic_cast<Player*>(beingManager->findBeing((*itr)->getID())); + if (p) + { + p->removeGuild(getId()); + } + ++itr; + } +} + Avatar *Guild::getAvatarAt(int index) { return mMembers[index]; diff --git a/src/guild.h b/src/guild.h index 11ba6e14..f1e6694d 100644 --- a/src/guild.h +++ b/src/guild.h @@ -118,6 +118,8 @@ public: */ void removeMember(const std::string &name); + void removeFromMembers(); + void clearMembers() { mMembers.clear(); } /** diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 6934dde0..030914b4 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -236,8 +236,8 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // fail if (id == player_node->getId()) { + eaParty->removeFromMembers(); eaParty->clearMembers(); - player_node->setParty(NULL); localChatTab->chatLog(_("You have left the party."), BY_SERVER); if (partyTab) @@ -251,6 +251,11 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) { partyTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), BY_SERVER); + Player *p = dynamic_cast<Player*>(beingManager->findBeing(id)); + if (p) + { + p->setParty(NULL); + } eaParty->removeMember(id); } break; diff --git a/src/party.cpp b/src/party.cpp index 6bbd0f6b..9a661e5b 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -145,6 +145,21 @@ void Party::removeMember(const std::string &name) } } +void Party::removeFromMembers() +{ + MemberList::iterator itr = mMembers.begin(), + itr_end = mMembers.end(); + while(itr != itr_end) + { + Player *p = dynamic_cast<Player*>(beingManager->findBeing((*itr)->getID())); + if (p) + { + p->setParty(NULL); + } + ++itr; + } +} + Avatar *Party::getAvatarAt(int index) { return mMembers[index]; diff --git a/src/party.h b/src/party.h index 22a768de..5918d4bd 100644 --- a/src/party.h +++ b/src/party.h @@ -125,6 +125,8 @@ public: void clearMembers() { mMembers.clear(); } + void removeFromMembers(); + /** * Get size of members list. * @return Returns the number of members in the party. diff --git a/src/player.cpp b/src/player.cpp index 3dc0a6df..1d0556a6 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -307,4 +307,9 @@ void Player::updateColors() { mNameColor = &guiPalette->getColor(Palette::PC); } + + if (mDispName) + { + mDispName->setColor(mNameColor); + } } |