diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-21 05:25:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-21 05:25:01 +0300 |
commit | 8037d33c9f429d4c0322da383cdda46776c3c14e (patch) | |
tree | 7460a6dd0c774817ff1dd92aa190776ae1684ed9 /src/gui/popupmenu.cpp | |
parent | d7eae524bf7e88ebb5a324431b74a77ce1e7fded (diff) | |
download | ManaVerse-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.gz ManaVerse-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.bz2 ManaVerse-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.xz ManaVerse-8037d33c9f429d4c0322da383cdda46776c3c14e.zip |
Impliment attack filter.
Add tab in social tab.
Diffstat (limited to 'src/gui/popupmenu.cpp')
-rw-r--r-- | src/gui/popupmenu.cpp | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 6c43fdfa1..06ee9a9b8 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -246,7 +246,32 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow(_("@@attack|Attack@@")); if (player_node->isGM()) + { + mBrowserBox->addRow("##3---"); mBrowserBox->addRow(_("@@admin-kick|Kick@@")); + } + + if (config.getBoolValue("enableAttackFilter")) + { + mBrowserBox->addRow("##3---"); + if (player_node->isInAttackList(name)) + { + mBrowserBox->addRow( + _("@@remove attack|Remove from attack list@@")); + } + else if (player_node->isInIgnoreAttackList(name)) + { + mBrowserBox->addRow( + _("@@remove attack|Remove from ignore list@@")); + } + else + { + mBrowserBox->addRow( + _("@@add attack|Add to attack list@@")); + mBrowserBox->addRow( + _("@@add attack ignore|Add to ignore list@@")); + } + } } break; @@ -1122,6 +1147,120 @@ void PopupMenu::handleLink(const std::string &link, { mTab->setNoAway(false); } + else if (link == "remove attack" && being) + { + if (player_node && being->getType() == Being::MONSTER) + { + player_node->removeAttackMob(being->getName()); + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + else if (link == "add attack" && being) + { + if (player_node && being->getType() == Being::MONSTER) + { + player_node->addAttackMob(being->getName()); + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + else if (link == "add attack ignore" && being) + { + if (player_node && being->getType() == Being::MONSTER) + { + player_node->addIgnoreAttackMob(being->getName()); + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + else if (link == "attack moveup") + { + if (player_node) + { + int idx = player_node->getAttackMobIndex(mNick); + if (idx > 0) + { + std::list<std::string> mobs = player_node->getAttackMobs(); + std::list<std::string>::iterator it = mobs.begin(); + std::list<std::string>::iterator it2 = mobs.begin(); + while (it != mobs.end()) + { + if (*it == mNick) + { + -- it2; + mobs.splice(it2, mobs, it); + player_node->setAttackMobs(mobs); + player_node->rebuildAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + } + else if (link == "attack movedown") + { + if (player_node) + { + int idx = player_node->getAttackMobIndex(mNick); + int size = player_node->getAttackMobsSize(); + if (idx + 1 < size) + { + std::list<std::string> mobs = player_node->getAttackMobs(); + std::list<std::string>::iterator it = mobs.begin(); + std::list<std::string>::iterator it2 = mobs.begin(); + while (it != mobs.end()) + { + if (*it == mNick) + { + ++ it2; + if (it2 == mobs.end()) + break; + + mobs.splice(it, mobs, it2); + player_node->setAttackMobs(mobs); + player_node->rebuildAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + } + else if (link == "attack remove") + { + if (player_node) + { + if (mNick.empty()) + { + if (player_node->isInAttackList(mNick)) + { + player_node->removeAttackMob(mNick); + player_node->addIgnoreAttackMob(mNick); + } + else + { + player_node->removeAttackMob(mNick); + player_node->addAttackMob(mNick); + } + } + else + { + player_node->removeAttackMob(mNick); + } + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } else if (link == "guild-pos" && !mNick.empty()) { showChangePos(getX(), getY()); @@ -1459,6 +1598,49 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) showPopup(x, y); } +void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, + bool isAttack) +{ + if (!player_node) + return; + + mNick = name; + + mBrowserBox->clearRows(); + + if (name.empty()) + mBrowserBox->addRow(_("(default)")); + else + mBrowserBox->addRow(name); + if (isAttack) + { + int idx = player_node->getAttackMobIndex(name); + int size = player_node->getAttackMobsSize(); + if (idx > 0) + { + mBrowserBox->addRow(strprintf( + "@@attack moveup|%s@@", _("Move up"))); + } + if (idx + 1 < size) + { + mBrowserBox->addRow(strprintf( + "@@attack movedown|%s@@", _("Move down"))); + } + mBrowserBox->addRow(strprintf( + "@@attack remove|%s@@", _("Remove"))); + } + else + { + mBrowserBox->addRow(strprintf( + "@@attack remove|%s@@", _("Remove"))); + } + + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + + showPopup(x, y); +} + void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); |