diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-05-12 10:41:31 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-05-12 10:41:31 -0600 |
commit | a2aa7c577b6d69b8185111a8ea8781957ce45b38 (patch) | |
tree | 5cd34f507fd16a9c66f7e83fffea3e94a49acaac /src | |
parent | fd47b191acef2230183cee1ab54901c777291e46 (diff) | |
download | mana-client-a2aa7c577b6d69b8185111a8ea8781957ce45b38.tar.gz mana-client-a2aa7c577b6d69b8185111a8ea8781957ce45b38.tar.bz2 mana-client-a2aa7c577b6d69b8185111a8ea8781957ce45b38.tar.xz mana-client-a2aa7c577b6d69b8185111a8ea8781957ce45b38.zip |
Handle in party status in a much saner way
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/minimap.cpp | 12 | ||||
-rw-r--r-- | src/gui/partywindow.cpp | 32 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 7 | ||||
-rw-r--r-- | src/player.cpp | 6 | ||||
-rw-r--r-- | src/player.h | 2 |
5 files changed, 39 insertions, 20 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 17a7e82a..160c0722 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -31,7 +31,6 @@ #include "player.h" #include "gui/palette.h" -#include "gui/partywindow.h" #include "resources/image.h" #include "resources/resourcemanager.h" @@ -182,6 +181,8 @@ void Minimap::draw(gcn::Graphics *graphics) { case Being::PLAYER: { + const Player* player = static_cast<const Player*>(being); + Palette::ColorType type = Palette::PC; if (being == player_node) @@ -189,14 +190,15 @@ void Minimap::draw(gcn::Graphics *graphics) type = Palette::SELF; dotSize = 3; } - else if (partyWindow->findMember(being->getId())) + else if (player->isGM()) + { + type = Palette::GM_NAME; + } + else if (player->isInParty()) { type = Palette::PARTY; } - if (static_cast<const Player*>(being)->isGM()) - type = Palette::GM_NAME; - graphics->setColor(guiPalette->getColor(type)); break; } diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index cb514844..b13f4b0b 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -23,6 +23,9 @@ #include "gui/widgets/chattab.h" +#include "beingmanager.h" +#include "player.h" + #include "net/net.h" #include "net/partyhandler.h" @@ -105,12 +108,16 @@ int PartyWindow::findMember(const std::string &name) const void PartyWindow::updateMember(int id, const std::string &memberName, bool leader, bool online) { - PartyMember *player = findOrCreateMember(id); - player->name = memberName; - player->leader = leader; - player->online = online; - player->avatar->setName(memberName); - player->avatar->setOnline(online); + PartyMember *member = findOrCreateMember(id); + member->name = memberName; + member->leader = leader; + member->online = online; + member->avatar->setName(memberName); + member->avatar->setOnline(online); + + Player *player = dynamic_cast<Player*>(beingManager->findBeing(id)); + if (player) + player->setInParty(true); } void PartyWindow::updateMemberHP(int id, int hp, int maxhp) @@ -123,6 +130,10 @@ void PartyWindow::updateMemberHP(int id, int hp, int maxhp) void PartyWindow::removeMember(int id) { mMembers.erase(id); + + Player *player = dynamic_cast<Player*>(beingManager->findBeing(id)); + if (player) + player->setInParty(false); } void PartyWindow::removeMember(const std::string &name) @@ -189,10 +200,19 @@ void PartyWindow::action(const gcn::ActionEvent &event) } } +void clearMembersSub(std::pair<int, PartyMember*> p) +{ + Player *player = dynamic_cast<Player*>(beingManager->findBeing(p.first)); + if (player) + player->setInParty(false); +} + void PartyWindow::clearMembers() { clearLayout(); + std::for_each(mMembers.begin(), mMembers.end(), clearMembersSub); + delete_all(mMembers); mMembers.clear(); } diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 0eda7792..072297dd 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -102,10 +102,6 @@ void PartyHandler::handleMessage(MessageIn &msg) bool online = msg.readInt8() == 0; partyWindow->updateMember(id, nick, leader, online); - - Being *being = beingManager->findBeing(id); - if (being) - being->setName(nick); } } break; @@ -229,7 +225,6 @@ void PartyHandler::handleMessage(MessageIn &msg) msg.readInt8(); // fail if (id == player_node->getId()) { - player_node->setInParty(false); partyWindow->clearMembers(); partyWindow->setVisible(false); partyTab->chatLog(_("You have left the party."), BY_SERVER); @@ -306,7 +301,7 @@ void PartyHandler::inviteResponse(const std::string &inviter, bool accept) MessageOut outMsg(CMSG_PARTY_INVITED); outMsg.writeInt32(player_node->getId()); outMsg.writeInt32(accept ? 1 : 0); - player_node->setInParty(player_node->getInParty() || accept); + player_node->setInParty(player_node->isInParty() || accept); } void PartyHandler::leave() diff --git a/src/player.cpp b/src/player.cpp index f658b8b5..e797fdfe 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -31,7 +31,6 @@ #include "text.h" #include "gui/palette.h" -#include "gui/partywindow.h" #include "resources/colordb.h" #include "resources/itemdb.h" @@ -77,7 +76,7 @@ void Player::setName(const std::string &name) { color = &guiPalette->getColor(Palette::SELF); } - else if (partyWindow->findMember(getId())) + else if (mInParty) { color = &guiPalette->getColor(Palette::PARTY); } @@ -304,6 +303,9 @@ short Player::getNumberOfGuilds() void Player::setInParty(bool value) { mInParty = value; + + if (this != player_node && mName) + mName->setColor(&guiPalette->getColor(value ? Palette::PARTY : Palette::PC)); } void Player::optionChanged(const std::string &value) diff --git a/src/player.h b/src/player.h index 5d037b75..af6412d4 100644 --- a/src/player.h +++ b/src/player.h @@ -127,7 +127,7 @@ class Player : public Being /** * Returns whether player is in the party */ - bool getInParty() const { return mInParty; } + bool isInParty() const { return mInParty; } /** * Gets the way the character is blocked by other objects. |