diff options
-rw-r--r-- | src/gui/partywindow.cpp | 32 | ||||
-rw-r--r-- | src/gui/partywindow.h | 16 | ||||
-rw-r--r-- | src/gui/widgets/avatar.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/avatar.h | 17 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 2 |
6 files changed, 49 insertions, 21 deletions
diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index d4b084ce..151e148c 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -35,13 +35,19 @@ #include "utils/stringutils.h" PartyMember::PartyMember(): - avatar(new Avatar) + mAvatar(new Avatar) { } PartyMember::~PartyMember() { - delete avatar; + delete mAvatar; +} + +void PartyMember::setLeader(bool leader) +{ + mLeader = leader; + mAvatar->setDisplayBold(true); } @@ -108,7 +114,7 @@ int PartyWindow::findMember(const std::string &name) const while (itr != itr_end) { - if ((*itr).second->name == name) + if ((*itr).second->mAvatar->getName() == name) { return (*itr).first; } @@ -122,12 +128,9 @@ void PartyWindow::updateMember(int id, const std::string &memberName, bool leader, bool online) { PartyMember *member = findOrCreateMember(id); - member->name = memberName; - member->leader = leader; - member->online = online; - member->avatar->setDisplayBold(leader); - member->avatar->setName(memberName); - member->avatar->setOnline(online); + member->mAvatar->setName(memberName); + member->setLeader(leader); + member->mAvatar->setOnline(online); Player *player = dynamic_cast<Player*>(beingManager->findBeing(id)); if (player && online) @@ -137,8 +140,8 @@ void PartyWindow::updateMember(int id, const std::string &memberName, void PartyWindow::updateMemberHP(int id, int hp, int maxhp) { PartyMember *player = findOrCreateMember(id); - player->avatar->setHp(hp); - player->avatar->setMaxHp(maxhp); + player->mAvatar->setHp(hp); + player->mAvatar->setMaxHp(maxhp); } void PartyWindow::removeMember(int id) @@ -163,8 +166,7 @@ void PartyWindow::updateOnlne(int id, bool online) if (!player) return; - player->online = online; - player->avatar->setOnline(online); + player->mAvatar->setOnline(online); } void PartyWindow::showPartyInvite(const std::string &inviter, @@ -245,7 +247,7 @@ void PartyWindow::buildLayout() for (it = mMembers.begin(); it != mMembers.end(); it++) { member = (*it).second; - add(member->avatar, 0, lastPos); - lastPos += member->avatar->getHeight() + 2; + add(member->mAvatar, 0, lastPos); + lastPos += member->mAvatar->getHeight() + 2; } } diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index 19e611ed..7f366fd1 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -33,6 +33,8 @@ #include <string> #include <map> +class PartyWindow; + /** * Party Member * Used for storing players in the party @@ -43,10 +45,16 @@ class PartyMember PartyMember(); ~PartyMember(); - std::string name; - bool leader; - bool online; - Avatar *avatar; + Avatar *getAvatar() const { return mAvatar; } + + bool getLeader() const { return mLeader; } + + void setLeader(bool leader); + + private: + friend class PartyWindow; + bool mLeader; + Avatar *mAvatar; }; diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index faaf22ab..5d8aea01 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -84,6 +84,7 @@ void Avatar::setName(const std::string &name) void Avatar::setOnline(bool online) { + mOnline = online; mStatus->setImage(online ? avatarStatusOnline : avatarStatusOffline); } diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h index dbe30a94..f5190be8 100644 --- a/src/gui/widgets/avatar.h +++ b/src/gui/widgets/avatar.h @@ -38,19 +38,35 @@ public: ~Avatar(); /** + * Returns the avatar's name. + */ + std::string getName() const { return mName; }; + + /** * Set the avatar's name. */ void setName(const std::string &name); /** + * Returns the avatar's online status. + */ + bool getOnline() const { return mOnline; } + + /** * Set the avatar's online status. */ void setOnline(bool online); + int getHp() const { return mHp; } + void setHp(int hp); + int getMaxHp() const { return mMaxHp; } + void setMaxHp(int maxHp); + bool getDisplayBold() const { return mDisplayBold; } + void setDisplayBold(bool displayBold) { mDisplayBold = displayBold; } private: @@ -61,6 +77,7 @@ private: int mMaxHp; Icon *mStatus; gcn::Label *mLabel; + bool mOnline; bool mDisplayBold; }; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 8a958845..1ede1b8d 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -483,7 +483,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) { PartyMember *member = partyWindow->findMember(id); - if (member && member->online) + if (member && member->getAvatar()->getOnline()) { player->setInParty(true); } diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 0865f71c..21d63ae5 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -268,7 +268,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg) PartyMember *member = partyWindow->findMember(id); if (member) - partyTab->chatLog(member->name, chatMsg); + partyTab->chatLog(member->getAvatar()->getName(), chatMsg); else partyTab->chatLog(strprintf(_("An unknown member tried to " "say: %s"), chatMsg.c_str()), BY_SERVER); |