summaryrefslogtreecommitdiff
path: root/src/gui/socialwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-05-04 01:36:53 +0300
committerAndrei Karas <akaras@inbox.ru>2012-05-05 19:36:52 +0300
commit7ed077a94dd553e5aa7675144ce98fd6e4ce723e (patch)
tree1cdb4cad6692d0dc34b4220f62038f67af77da2e /src/gui/socialwindow.cpp
parent7ba882b543b45794301f2490fceb84b0dd9c60e1 (diff)
downloadmv-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.gz
mv-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.bz2
mv-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.xz
mv-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.zip
Add pickup ignore list.
Diffstat (limited to 'src/gui/socialwindow.cpp')
-rw-r--r--src/gui/socialwindow.cpp230
1 files changed, 116 insertions, 114 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 74fcfc851..b8c73f448 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -864,6 +864,58 @@ protected:
};
+#define addAvatars(mob, str, type) \
+{\
+ ava = new Avatar(str);\
+ ava->setOnline(false);\
+ ava->setLevel(-1);\
+ ava->setType(MapItem::SEPARATOR);\
+ ava->setX(0);\
+ ava->setY(0);\
+ avatars->push_back(ava);\
+ mobs = actorSpriteManager->get##mob##s();\
+ i = mobs.begin();\
+ i_end = mobs.end();\
+ while (i != i_end)\
+ {\
+ std::string name;\
+ int level = -1;\
+ if (*i == "")\
+ {\
+ name = _("(default)");\
+ level = 0;\
+ }\
+ else\
+ {\
+ name = *i;\
+ }\
+ ava = new Avatar(name);\
+ ava->setOnline(true);\
+ ava->setLevel(level);\
+ ava->setType(MapItem::type);\
+ ava->setX(0);\
+ ava->setY(0);\
+ avatars->push_back(ava);\
+ ++ i;\
+ }\
+}
+
+#define updateAtkListStart() \
+ if (!socialWindow || !player_node || !actorSpriteManager)\
+ return;\
+ std::vector<Avatar*> *avatars = mBeings->getMembers();\
+ std::vector<Avatar*>::iterator ia = avatars->begin();\
+ while (ia != avatars->end())\
+ {\
+ delete *ia;\
+ ++ ia;\
+ }\
+ avatars->clear();\
+ Avatar *ava;\
+ std::list<std::string> mobs;\
+ std::list<std::string>::const_iterator i;\
+ std::list<std::string>::const_iterator i_end;
+
class SocialAttackTab : public SocialTab
{
public:
@@ -900,130 +952,63 @@ public:
void updateList()
{
- if (!socialWindow || !player_node || !actorSpriteManager)
- return;
-
- std::vector<Avatar*> *avatars = mBeings->getMembers();
-
- std::list<std::string> mobs
- = actorSpriteManager->getPriorityAttackMobs();
-
- std::vector<Avatar*>::iterator ia = avatars->begin();
-
- while (ia != avatars->end())
- {
- delete *ia;
- ++ ia;
- }
-
- avatars->clear();
- Avatar *ava = new Avatar(_("Priority mobs"));
- ava->setOnline(false);
- ava->setLevel(-1);
- ava->setType(MapItem::SEPARATOR);
- ava->setX(0);
- ava->setY(0);
- avatars->push_back(ava);
-
- std::list<std::string>::const_iterator i = mobs.begin();
- std::list<std::string>::const_iterator i_end = mobs.end();
+ updateAtkListStart();
+ addAvatars(PriorityAttackMob, _("Priority mobs"), PRIORITY);
+ addAvatars(AttackMob, _("Attack mobs"), ATTACK);
+ addAvatars(IgnoreAttackMob, _("Ignore mobs"), IGNORE_);
+ }
- while (i != i_end)
- {
- std::string name;
- int level = -1;
- if (*i == "")
- {
- name = _("(default)");
- level = 0;
- }
- else
- {
- name = *i;
- }
- ava = new Avatar(name);
- ava->setOnline(true);
- ava->setLevel(level);
- ava->setType(MapItem::PRIORITY);
- ava->setX(0);
- ava->setY(0);
- avatars->push_back(ava);
+ void updateAvatar(std::string name A_UNUSED)
+ {
+ }
- ++ i;
- }
+ void resetDamage(std::string name A_UNUSED)
+ {
+ }
- ava = new Avatar(_("Attack mobs"));
- ava->setOnline(false);
- ava->setLevel(-1);
- ava->setType(MapItem::SEPARATOR);
- ava->setX(0);
- ava->setY(0);
- avatars->push_back(ava);
+private:
+ BeingsListModal *mBeings;
+};
- mobs = actorSpriteManager->getAttackMobs();
- i = mobs.begin();
- i_end = mobs.end();
+class SocialPickupTab : public SocialTab
+{
+public:
+ SocialPickupTab()
+ {
+ mBeings = new BeingsListModal();
- while (i != i_end)
- {
- std::string name;
- int level = -1;
- if (*i == "")
- {
- name = _("(default)");
- level = 0;
- }
- else
- {
- name = *i;
- }
- ava = new Avatar(name);
- ava->setOnline(true);
- ava->setLevel(level);
- ava->setType(MapItem::ATTACK);
- ava->setX(0);
- ava->setY(0);
- avatars->push_back(ava);
+ mList = new AvatarListBox(mBeings);
+ mScroll = new ScrollArea(mList);
- ++ i;
- }
+ mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
- 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);
+ setCaption(_("Pik"));
+ }
- mobs = actorSpriteManager->getIgnoreAttackMobs();
- i = mobs.begin();
- i_end = mobs.end();
+ ~SocialPickupTab()
+ {
+ delete mList;
+ mList = nullptr;
+ delete mScroll;
+ mScroll = nullptr;
+ delete mBeings;
+ mBeings = nullptr;
+ }
- while (i != i_end)
- {
- std::string name;
- int level = -1;
- if (*i == "")
- {
- name = _("(default)");
- level = 0;
- }
- else
- {
- name = *i;
- }
- ava = new Avatar(name);
- ava->setOnline(false);
- ava->setLevel(level);
- ava->setType(MapItem::IGNORE_);
- ava->setX(0);
- ava->setY(0);
- avatars->push_back(ava);
+ void invite()
+ {
+ }
- ++ i;
- }
+ void leave()
+ {
+ }
+ void updateList()
+ {
+ updateAtkListStart();
+ addAvatars(PickupItem, _("Pickup items"), PICKUP);
+ addAvatars(IgnorePickupItem, _("Ignore items"), NOPICKUP);
}
void updateAvatar(std::string name A_UNUSED)
@@ -1036,7 +1021,6 @@ public:
private:
BeingsListModal *mBeings;
-
};
@@ -1250,6 +1234,16 @@ SocialWindow::SocialWindow() :
mAttackFilter = nullptr;
}
+ if (config.getBoolValue("enablePickupFilter"))
+ {
+ mPickupFilter = new SocialPickupTab();
+ mTabs->addTab(mPickupFilter, mPickupFilter->mScroll);
+ }
+ else
+ {
+ mPickupFilter = nullptr;
+ }
+
if (player_node && player_node->getParty())
addTab(player_node->getParty());
@@ -1287,6 +1281,8 @@ SocialWindow::~SocialWindow()
mNavigation = nullptr;
delete mAttackFilter;
mAttackFilter = nullptr;
+ delete mPickupFilter;
+ mPickupFilter = nullptr;
delete mFriends;
mFriends = nullptr;
}
@@ -1718,6 +1714,12 @@ void SocialWindow::updateAttackFilter()
mAttackFilter->updateList();
}
+void SocialWindow::updatePickupFilter()
+{
+ if (mPickupFilter)
+ mPickupFilter->updateList();
+}
+
void SocialWindow::widgetResized(const gcn::Event &event)
{
Window::widgetResized(event);