summaryrefslogtreecommitdiff
path: root/src/gui
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
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')
-rw-r--r--src/gui/popupmenu.cpp205
-rw-r--r--src/gui/popupmenu.h5
-rw-r--r--src/gui/setup_other.cpp3
-rw-r--r--src/gui/socialwindow.cpp230
-rw-r--r--src/gui/socialwindow.h3
-rw-r--r--src/gui/viewport.cpp5
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp12
8 files changed, 326 insertions, 139 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 45cf8b9b2..1bd634c7c 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -534,6 +534,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
mFloorItemId = floorItem->getId();
mX = x;
mY = y;
+ mType = Being::FLOOR_ITEM;
const ItemInfo &info = floorItem->getInfo();
mBrowserBox->clearRows();
std::string name;
@@ -543,9 +544,35 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
name = info.getName(floorItem->getColor());
else
name = info.getName();
+ mNick = name;
mBrowserBox->addRow(name);
- mBrowserBox->addRow("pickup", _("Pick up"));
+
+ if (config.getBoolValue("enablePickupFilter"))
+ {
+ if (actorSpriteManager->isInPickupList(name)
+ && !actorSpriteManager->isInIgnorePickupList(""))
+ {
+ mBrowserBox->addRow("pickup", _("Pick up"));
+ mBrowserBox->addRow("##3---");
+ }
+ if (actorSpriteManager->isInPickupList(name)
+ || actorSpriteManager->isInIgnorePickupList(name))
+ {
+ mBrowserBox->addRow("remove pickup",
+ _("Remove from pickup list"));
+ }
+ else
+ {
+ mBrowserBox->addRow("add pickup", _("Add to pickup list"));
+ mBrowserBox->addRow("add pickup ignore",
+ _("Add to ignore list"));
+ }
+ }
+ else
+ {
+ mBrowserBox->addRow("pickup", _("Pick up"));
+ }
mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
@@ -1390,18 +1417,6 @@ void PopupMenu::handleLink(const std::string &link,
spellManager->save();
}
}
- else if (link == "load old item shortcuts")
- {
- if (itemShortcutWindow)
- {
- int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < SHORTCUT_TABS && itemShortcut[num])
- {
- itemShortcut[num]->load(true);
- itemShortcut[num]->save();
- }
- }
- }
else if (link == "clear drops")
{
if (dropShortcut)
@@ -1528,6 +1543,33 @@ void PopupMenu::handleLink(const std::string &link,
socialWindow->updateAttackFilter();
}
}
+ else if (link == "remove pickup" && !mNick.empty())
+ {
+ if (actorSpriteManager)
+ {
+ actorSpriteManager->removePickupItem(mNick);
+ if (socialWindow)
+ socialWindow->updatePickupFilter();
+ }
+ }
+ else if (link == "add pickup" && !mNick.empty())
+ {
+ if (actorSpriteManager)
+ {
+ actorSpriteManager->addPickupItem(mNick);
+ if (socialWindow)
+ socialWindow->updatePickupFilter();
+ }
+ }
+ else if (link == "add pickup ignore" && !mNick.empty())
+ {
+ if (actorSpriteManager)
+ {
+ actorSpriteManager->addIgnorePickupItem(mNick);
+ if (socialWindow)
+ socialWindow->updatePickupFilter();
+ }
+ }
else if (link == "attack moveup")
{
if (actorSpriteManager)
@@ -1681,6 +1723,31 @@ void PopupMenu::handleLink(const std::string &link,
socialWindow->updateAttackFilter();
}
}
+ else if (link == "pickup remove")
+ {
+ if (actorSpriteManager)
+ {
+ if (mNick.empty())
+ {
+ if (actorSpriteManager->isInPickupList(mNick))
+ {
+ actorSpriteManager->removePickupItem(mNick);
+ actorSpriteManager->addIgnorePickupItem(mNick);
+ }
+ else
+ {
+ actorSpriteManager->removePickupItem(mNick);
+ actorSpriteManager->addPickupItem(mNick);
+ }
+ }
+ else
+ {
+ actorSpriteManager->removePickupItem(mNick);
+ }
+ if (socialWindow)
+ socialWindow->updatePickupFilter();
+ }
+ }
else if (link == "reset yellow")
{
if (player_node)
@@ -1814,6 +1881,7 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
mWindow = parent;
mX = x;
mY = y;
+ mNick = "";
mBrowserBox->clearRows();
int cnt = item->getQuantity();
@@ -1884,6 +1952,28 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
mBrowserBox->addRow("retrieve all", _("Retrieve all"));
}
}
+ if (config.getBoolValue("enablePickupFilter"))
+ {
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+ mNick = name;
+ mBrowserBox->addRow("##3---");
+ if (actorSpriteManager->isInPickupList(name)
+ || actorSpriteManager->isInIgnorePickupList(name))
+ {
+ mBrowserBox->addRow("remove pickup", _("Remove from pickup list"));
+ }
+ else
+ {
+ mBrowserBox->addRow("add pickup", _("Add to pickup list"));
+ mBrowserBox->addRow("add pickup ignore", _("Add to ignore list"));
+ }
+ }
mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow("cancel", _("Cancel"));
@@ -1913,9 +2003,6 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
mBrowserBox->addRow("use", _("Use"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("load old item shortcuts",
- _("Load old item shortcuts"));
- mBrowserBox->addRow("##3---");
mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
@@ -1937,6 +2024,7 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
mItemId = 0;
mItemColor = 1;
}
+ mNick = "";
mBrowserBox->clearRows();
if (item)
@@ -1969,10 +2057,33 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
if (InventoryWindow::isStorageActive())
mBrowserBox->addRow("store", _("Store"));
mBrowserBox->addRow("chat", _("Add to chat"));
- mBrowserBox->addRow("##3---");
+
+ if (config.getBoolValue("enablePickupFilter"))
+ {
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+ mNick = name;
+
+ mBrowserBox->addRow("##3---");
+ if (actorSpriteManager->isInPickupList(name)
+ || actorSpriteManager->isInIgnorePickupList(name))
+ {
+ mBrowserBox->addRow("remove pickup",
+ _("Remove from pickup list"));
+ }
+ else
+ {
+ mBrowserBox->addRow("add pickup", _("Add to pickup list"));
+ mBrowserBox->addRow("add pickup ignore",
+ _("Add to ignore list"));
+ }
+ }
}
- mBrowserBox->addRow("load old item shortcuts",
- _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow("cancel", _("Cancel"));
@@ -1984,6 +2095,7 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
mItem = item;
mX = x;
mY = y;
+ mNick = "";
mBrowserBox->clearRows();
if (item)
@@ -2016,8 +2128,33 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
if (InventoryWindow::isStorageActive())
mBrowserBox->addRow("store", _("Store"));
mBrowserBox->addRow("chat", _("Add to chat"));
- mBrowserBox->addRow("##3---");
+ if (config.getBoolValue("enablePickupFilter"))
+ {
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+ mNick = name;
+
+ mBrowserBox->addRow("##3---");
+ if (actorSpriteManager->isInPickupList(name)
+ || actorSpriteManager->isInIgnorePickupList(name))
+ {
+ mBrowserBox->addRow("remove pickup",
+ _("Remove from pickup list"));
+ }
+ else
+ {
+ mBrowserBox->addRow("add pickup", _("Add to pickup list"));
+ mBrowserBox->addRow("add pickup ignore",
+ _("Add to ignore list"));
+ }
+ }
}
+ mBrowserBox->addRow("##3---");
mBrowserBox->addRow("clear drops", _("Clear drop window"));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow("cancel", _("Cancel"));
@@ -2130,7 +2267,6 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
mBrowserBox->addRow("attack moveup", _("Move up"));
if (idx + 1 < size)
mBrowserBox->addRow("attack movedown", _("Move down"));
- mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::PRIORITY:
@@ -2141,16 +2277,39 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
mBrowserBox->addRow("priority moveup", _("Move up"));
if (idx + 1 < size)
mBrowserBox->addRow("priority movedown", _("Move down"));
- mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::IGNORE_:
- mBrowserBox->addRow("attack remove", _("Remove"));
break;
default:
break;
}
+ mBrowserBox->addRow("attack remove", _("Remove"));
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("cancel", _("Cancel"));
+
+ showPopup(x, y);
+}
+
+void PopupMenu::showPickupItemPopup(int x, int y, std::string name)
+{
+ if (!player_node || !actorSpriteManager)
+ return;
+
+ mNick = name;
+ mType = Being::FLOOR_ITEM;
+ mX = x;
+ mY = y;
+
+ mBrowserBox->clearRows();
+
+ if (name.empty())
+ mBrowserBox->addRow(_("(default)"));
+ else
+ mBrowserBox->addRow(name);
+
+ mBrowserBox->addRow("pickup remove", _("Remove"));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow("cancel", _("Cancel"));
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index f616e46ee..ac47d406a 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -137,8 +137,9 @@ class PopupMenu : public Popup, public LinkHandler
void showSpellPopup(int x, int y, TextCommand *cmd);
- void showAttackMonsterPopup(int x, int y, std::string name,
- int type);
+ void showAttackMonsterPopup(int x, int y, std::string name, int type);
+
+ void showPickupItemPopup(int x, int y, std::string name);
void showUndressPopup(int x, int y, Being *being, Item *item);
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 2f86db8af..aacc5d736 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -134,6 +134,9 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Enable attack filter"), "",
"enableAttackFilter", this, "enableAttackFilterEvent");
+ new SetupItemCheckBox(_("Enable pickup filter"), "",
+ "enablePickupFilter", this, "enablePickupFilterEvent");
+
new SetupItemCheckBox(_("Enable advert protocol"), "",
"enableAdvert", this, "enableAdvertEvent");
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);
diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h
index 9da78562b..9536ee3d7 100644
--- a/src/gui/socialwindow.h
+++ b/src/gui/socialwindow.h
@@ -117,6 +117,8 @@ public:
void updateAttackFilter();
+ void updatePickupFilter();
+
void widgetResized(const gcn::Event &event);
protected:
@@ -139,6 +141,7 @@ protected:
PartyMap mParties;
SocialTab *mAttackFilter;
+ SocialTab *mPickupFilter;
SocialTab *mPlayers;
SocialTab *mNavigation;
SocialTab *mFriends;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 65ca8071c..2a69428b4 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -704,6 +704,11 @@ void Viewport::showAttackMonsterPopup(std::string name, int type)
name, type);
}
+void Viewport::showPickupItemPopup(std::string name)
+{
+ mPopupMenu->showPickupItemPopup(getMouseX(), getMouseY(), name);
+}
+
void Viewport::showUndressPopup(int x, int y, Being *being, Item *item)
{
mPopupMenu->showUndressPopup(x, y, being, item);
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 3031a181e..fc3db142a 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -160,6 +160,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void showAttackMonsterPopup(std::string name, int type);
+ void showPickupItemPopup(std::string name);
+
/**
* Shows the related popup menu when right click on the chat
* at the specified mouse coordinates.
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index b4fc4fad0..685be7f4c 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -369,6 +369,18 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
model->getAvatarAt(selected)->getType());
break;
}
+ case MapItem::PICKUP:
+ case MapItem::NOPICKUP:
+ {
+ std::string name;
+ if (model->getAvatarAt(selected)->getLevel() == 0)
+ name = "";
+ else
+ name = model->getAvatarAt(selected)->getName();
+
+ viewport->showPickupItemPopup(name);
+ break;
+ }
default:
{
Map *map = viewport->getMap();