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/gui | |
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/gui')
-rw-r--r-- | src/gui/minimap.cpp | 12 | ||||
-rw-r--r-- | src/gui/partywindow.cpp | 32 |
2 files changed, 33 insertions, 11 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(); } |