summaryrefslogtreecommitdiff
path: root/src/gui/socialwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-21 05:25:01 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-21 05:25:01 +0300
commit8037d33c9f429d4c0322da383cdda46776c3c14e (patch)
tree7460a6dd0c774817ff1dd92aa190776ae1684ed9 /src/gui/socialwindow.cpp
parentd7eae524bf7e88ebb5a324431b74a77ce1e7fded (diff)
downloadplus-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.gz
plus-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.bz2
plus-8037d33c9f429d4c0322da383cdda46776c3c14e.tar.xz
plus-8037d33c9f429d4c0322da383cdda46776c3c14e.zip
Impliment attack filter.
Add tab in social tab.
Diffstat (limited to 'src/gui/socialwindow.cpp')
-rw-r--r--src/gui/socialwindow.cpp160
1 files changed, 157 insertions, 3 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 8a134b5c3..c6ec12cd8 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -500,7 +500,6 @@ private:
class NavigationTab : public SocialTab
{
-
public:
NavigationTab()
{
@@ -768,6 +767,141 @@ protected:
};
+class AttackTab : public SocialTab
+{
+public:
+ AttackTab()
+ {
+ mBeings = new BeingsListModal();
+
+ mList = new AvatarListBox(mBeings);
+ mScroll = new ScrollArea(mList);
+
+ mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
+
+ setCaption(_("Atk"));
+ }
+
+ ~AttackTab()
+ {
+ delete mList;
+ mList = 0;
+ delete mScroll;
+ mScroll = 0;
+ delete mBeings;
+ mBeings = 0;
+ }
+
+ void invite()
+ {
+ }
+
+ void leave()
+ {
+ }
+
+ void updateList()
+ {
+ if (!socialWindow || !player_node)
+ return;
+
+ std::vector<Avatar*> *avatars = mBeings->getMembers();
+
+ std::list<std::string> mobs = player_node->getAttackMobs();
+ std::list<std::string>::iterator i = mobs.begin();
+
+ std::vector<Avatar*>::iterator ia = avatars->begin();
+
+ while (ia != avatars->end())
+ {
+ delete *ia;
+ ++ ia;
+ }
+
+ avatars->clear();
+ Avatar *ava = new Avatar(_("Selected mobs"));
+ ava->setOnline(false);
+ ava->setLevel(-1);
+ ava->setType(MapItem::SEPARATOR);
+ ava->setX(0);
+ ava->setY(0);
+ avatars->push_back(ava);
+
+ while (i != mobs.end())
+ {
+ std::string name;
+ int level = -1;
+ if (*i == "")
+ {
+ name = _("(default)");
+ level = 0;
+ }
+ else
+ {
+ name = *i;
+ }
+ Avatar *ava = new Avatar(name);
+ ava->setOnline(true);
+ ava->setLevel(level);
+ ava->setType(MapItem::MONSTER);
+ ava->setX(0);
+ ava->setY(0);
+ avatars->push_back(ava);
+
+ ++ i;
+ }
+
+ ava = new Avatar(_("Ignore mobs"));
+ ava->setOnline(false);
+ ava->setLevel(-1);
+ ava->setType(MapItem::SEPARATOR);
+ ava->setX(0);
+ ava->setY(0);
+ avatars->push_back(ava);
+
+ mobs = player_node->getIgnoreAttackMobs();
+ i = mobs.begin();
+
+ while (i != mobs.end())
+ {
+ std::string name;
+ int level = -1;
+ if (*i == "")
+ {
+ name = _("(default)");
+ level = 0;
+ }
+ else
+ {
+ name = *i;
+ }
+ Avatar *ava = new Avatar(name);
+ ava->setOnline(false);
+ ava->setLevel(level);
+ ava->setType(MapItem::MONSTER);
+ ava->setX(0);
+ ava->setY(0);
+ avatars->push_back(ava);
+
+ ++ i;
+ }
+
+ }
+
+ void updateAvatar(std::string name _UNUSED_)
+ {
+ }
+
+ void resetDamage(std::string name _UNUSED_)
+ {
+ }
+
+private:
+ BeingsListModal *mBeings;
+
+};
+
class CreatePopup : public Popup, public LinkHandler
{
public:
@@ -866,6 +1000,16 @@ SocialWindow::SocialWindow() :
mNavigation = new NavigationTab();
mTabs->addTab(mNavigation, mNavigation->mScroll);
+ if (config.getBoolValue("enableAttackFilter"))
+ {
+ mAttackFilter = new AttackTab();
+ mTabs->addTab(mAttackFilter, mAttackFilter->mScroll);
+ }
+ else
+ {
+ mAttackFilter = 0;
+ }
+
if (player_node && player_node->getParty())
addTab(player_node->getParty());
@@ -899,6 +1043,10 @@ SocialWindow::~SocialWindow()
mCreatePopup = 0;
delete mPlayers;
mPlayers = 0;
+ delete mNavigation;
+ mNavigation = 0;
+ delete mAttackFilter;
+ mAttackFilter = 0;
}
bool SocialWindow::addTab(Guild *guild)
@@ -1204,7 +1352,7 @@ void SocialWindow::updateActiveList()
void SocialWindow::logic()
{
unsigned int nowTime = cur_time;
- if (nowTime - mLastUpdateTime > 1 && mNeedUpdate)
+ if (mNeedUpdate && nowTime - mLastUpdateTime > 1)
{
mPlayers->updateList();
mNeedUpdate = false;
@@ -1304,4 +1452,10 @@ void SocialWindow::prevTab()
tab--;
mTabs->setSelectedTab(tab);
-} \ No newline at end of file
+}
+
+void SocialWindow::updateAttackFilter()
+{
+ if (mAttackFilter)
+ mAttackFilter->updateList();
+}