From e26b64efb9c6b79bbd5d9426af6887e83651e466 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 6 May 2011 19:37:58 +0300 Subject: Move attack filter arrays and methods from localplayer to actorspritemanager class. --- src/gui/popupmenu.cpp | 90 +++++++++++++++++++++++++----------------------- src/gui/socialwindow.cpp | 9 ++--- 2 files changed, 51 insertions(+), 48 deletions(-) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index be76fc4a6..5cc13d8ed 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -105,7 +105,7 @@ PopupMenu::PopupMenu(): void PopupMenu::showPopup(int x, int y, Being *being) { - if (!being || !player_node) + if (!being || !player_node || !actorSpriteManager) return; mBeingId = being->getId(); @@ -254,9 +254,9 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (config.getBoolValue("enableAttackFilter")) { mBrowserBox->addRow("##3---"); - if (player_node->isInAttackList(name) - || player_node->isInIgnoreAttackList(name) - || player_node->isInPriorityAttackList(name)) + if (actorSpriteManager->isInAttackList(name) + || actorSpriteManager->isInIgnoreAttackList(name) + || actorSpriteManager->isInPriorityAttackList(name)) { mBrowserBox->addRow( _("@@remove attack|Remove from attack list@@")); @@ -1149,48 +1149,49 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "remove attack" && being) { - if (player_node && being->getType() == Being::MONSTER) + if (actorSpriteManager && being->getType() == Being::MONSTER) { - player_node->removeAttackMob(being->getName()); + actorSpriteManager->removeAttackMob(being->getName()); if (socialWindow) socialWindow->updateAttackFilter(); } } else if (link == "add attack" && being) { - if (player_node && being->getType() == Being::MONSTER) + if (actorSpriteManager && being->getType() == Being::MONSTER) { - player_node->addAttackMob(being->getName()); + actorSpriteManager->addAttackMob(being->getName()); if (socialWindow) socialWindow->updateAttackFilter(); } } else if (link == "add attack priority" && being) { - if (player_node && being->getType() == Being::MONSTER) + if (actorSpriteManager && being->getType() == Being::MONSTER) { - player_node->addPriorityAttackMob(being->getName()); + actorSpriteManager->addPriorityAttackMob(being->getName()); if (socialWindow) socialWindow->updateAttackFilter(); } } else if (link == "add attack ignore" && being) { - if (player_node && being->getType() == Being::MONSTER) + if (actorSpriteManager && being->getType() == Being::MONSTER) { - player_node->addIgnoreAttackMob(being->getName()); + actorSpriteManager->addIgnoreAttackMob(being->getName()); if (socialWindow) socialWindow->updateAttackFilter(); } } else if (link == "attack moveup") { - if (player_node) + if (actorSpriteManager) { - int idx = player_node->getAttackMobIndex(mNick); + int idx = actorSpriteManager->getAttackMobIndex(mNick); if (idx > 0) { - std::list mobs = player_node->getAttackMobs(); + std::list mobs + = actorSpriteManager->getAttackMobs(); std::list::iterator it = mobs.begin(); std::list::iterator it2 = mobs.begin(); while (it != mobs.end()) @@ -1199,8 +1200,8 @@ void PopupMenu::handleLink(const std::string &link, { -- it2; mobs.splice(it2, mobs, it); - player_node->setAttackMobs(mobs); - player_node->rebuildAttackMobs(); + actorSpriteManager->setAttackMobs(mobs); + actorSpriteManager->rebuildAttackMobs(); break; } ++ it; @@ -1214,13 +1215,13 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "priority moveup") { - if (player_node) + if (actorSpriteManager) { - int idx = player_node->getPriorityAttackMobIndex(mNick); + int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick); if (idx > 0) { std::list mobs - = player_node->getPriorityAttackMobs(); + = actorSpriteManager->getPriorityAttackMobs(); std::list::iterator it = mobs.begin(); std::list::iterator it2 = mobs.begin(); while (it != mobs.end()) @@ -1229,8 +1230,8 @@ void PopupMenu::handleLink(const std::string &link, { -- it2; mobs.splice(it2, mobs, it); - player_node->setPriorityAttackMobs(mobs); - player_node->rebuildPriorityAttackMobs(); + actorSpriteManager->setPriorityAttackMobs(mobs); + actorSpriteManager->rebuildPriorityAttackMobs(); break; } ++ it; @@ -1244,13 +1245,14 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "attack movedown") { - if (player_node) + if (actorSpriteManager) { - int idx = player_node->getAttackMobIndex(mNick); - int size = player_node->getAttackMobsSize(); + int idx = actorSpriteManager->getAttackMobIndex(mNick); + int size = actorSpriteManager->getAttackMobsSize(); if (idx + 1 < size) { - std::list mobs = player_node->getAttackMobs(); + std::list mobs + = actorSpriteManager->getAttackMobs(); std::list::iterator it = mobs.begin(); std::list::iterator it2 = mobs.begin(); while (it != mobs.end()) @@ -1262,8 +1264,8 @@ void PopupMenu::handleLink(const std::string &link, break; mobs.splice(it, mobs, it2); - player_node->setAttackMobs(mobs); - player_node->rebuildAttackMobs(); + actorSpriteManager->setAttackMobs(mobs); + actorSpriteManager->rebuildAttackMobs(); break; } ++ it; @@ -1279,12 +1281,12 @@ void PopupMenu::handleLink(const std::string &link, { if (player_node) { - int idx = player_node->getPriorityAttackMobIndex(mNick); - int size = player_node->getPriorityAttackMobsSize(); + int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick); + int size = actorSpriteManager->getPriorityAttackMobsSize(); if (idx + 1 < size) { std::list mobs - = player_node->getPriorityAttackMobs(); + = actorSpriteManager->getPriorityAttackMobs(); std::list::iterator it = mobs.begin(); std::list::iterator it2 = mobs.begin(); while (it != mobs.end()) @@ -1296,8 +1298,8 @@ void PopupMenu::handleLink(const std::string &link, break; mobs.splice(it, mobs, it2); - player_node->setPriorityAttackMobs(mobs); - player_node->rebuildPriorityAttackMobs(); + actorSpriteManager->setPriorityAttackMobs(mobs); + actorSpriteManager->rebuildPriorityAttackMobs(); break; } ++ it; @@ -1311,24 +1313,24 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "attack remove") { - if (player_node) + if (actorSpriteManager) { if (mNick.empty()) { - if (player_node->isInAttackList(mNick)) + if (actorSpriteManager->isInAttackList(mNick)) { - player_node->removeAttackMob(mNick); - player_node->addIgnoreAttackMob(mNick); + actorSpriteManager->removeAttackMob(mNick); + actorSpriteManager->addIgnoreAttackMob(mNick); } else { - player_node->removeAttackMob(mNick); - player_node->addAttackMob(mNick); + actorSpriteManager->removeAttackMob(mNick); + actorSpriteManager->addAttackMob(mNick); } } else { - player_node->removeAttackMob(mNick); + actorSpriteManager->removeAttackMob(mNick); } if (socialWindow) socialWindow->updateAttackFilter(); @@ -1696,8 +1698,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, { case MapItem::ATTACK: { - int idx = player_node->getAttackMobIndex(name); - int size = player_node->getAttackMobsSize(); + int idx = actorSpriteManager->getAttackMobIndex(name); + int size = actorSpriteManager->getAttackMobsSize(); if (idx > 0) { mBrowserBox->addRow(strprintf( @@ -1714,8 +1716,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, } case MapItem::PRIORITY: { - int idx = player_node->getPriorityAttackMobIndex(name); - int size = player_node->getPriorityAttackMobsSize(); + int idx = actorSpriteManager->getPriorityAttackMobIndex(name); + int size = actorSpriteManager->getPriorityAttackMobsSize(); if (idx > 0) { mBrowserBox->addRow(strprintf( diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 2276f60e0..e943d7286 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -803,12 +803,13 @@ public: void updateList() { - if (!socialWindow || !player_node) + if (!socialWindow || !player_node || !actorSpriteManager) return; std::vector *avatars = mBeings->getMembers(); - std::list mobs = player_node->getPriorityAttackMobs(); + std::list mobs + = actorSpriteManager->getPriorityAttackMobs(); std::list::iterator i = mobs.begin(); std::vector::iterator ia = avatars->begin(); @@ -860,7 +861,7 @@ public: ava->setY(0); avatars->push_back(ava); - mobs = player_node->getAttackMobs(); + mobs = actorSpriteManager->getAttackMobs(); i = mobs.begin(); while (i != mobs.end()) @@ -895,7 +896,7 @@ public: ava->setY(0); avatars->push_back(ava); - mobs = player_node->getIgnoreAttackMobs(); + mobs = actorSpriteManager->getIgnoreAttackMobs(); i = mobs.begin(); while (i != mobs.end()) -- cgit v1.2.3-70-g09d2