summaryrefslogtreecommitdiff
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
parent7ba882b543b45794301f2490fceb84b0dd9c60e1 (diff)
downloadmanaplus-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.gz
manaplus-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.bz2
manaplus-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.tar.xz
manaplus-7ed077a94dd553e5aa7675144ce98fd6e4ce723e.zip
Add pickup ignore list.
-rw-r--r--src/actorspritemanager.cpp166
-rw-r--r--src/actorspritemanager.h78
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/flooritem.h3
-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
-rw-r--r--src/localplayer.cpp7
-rw-r--r--src/maplayer.h4
14 files changed, 531 insertions, 193 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 9dcae629c..97d559ffc 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -40,6 +40,8 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include "resources/iteminfo.h"
+
#include "net/net.h"
#include "net/playerhandler.h"
@@ -221,6 +223,8 @@ void ActorSpriteManager::setPlayer(LocalPlayer *player)
mActors.insert(player);
if (socialWindow)
socialWindow->updateAttackFilter();
+ if (socialWindow)
+ socialWindow->updatePickupFilter();
}
Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type,
@@ -239,6 +243,8 @@ FloorItem *ActorSpriteManager::createItem(int id, int itemId, int x, int y,
FloorItem *floorItem = new FloorItem(id, itemId, x, y,
mMap, amount, color, subX, subY);
+ if (!checkForPickup(floorItem))
+ floorItem->disableHightlight();
mActors.insert(floorItem);
return floorItem;
}
@@ -500,6 +506,7 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
return false;
bool finded(false);
+ bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
if (!serverBuggy)
{
for_actors
@@ -511,8 +518,30 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
&& ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
&& ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
{
- if (player_node->pickUp(static_cast<FloorItem*>(*it)))
- finded = true;
+ FloorItem *item = static_cast<FloorItem*>(*it);
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+ if (allowAll)
+ {
+ if (mIgnorePickupItemsSet.find(name)
+ == mIgnorePickupItemsSet.end())
+ {
+ if (player_node->pickUp(item))
+ finded = true;
+ }
+ }
+ else
+ {
+ if (mPickupItemsSet.find(name) != mPickupItemsSet.end())
+ {
+ if (player_node->pickUp(item))
+ finded = true;
+ }
+ }
}
}
}
@@ -532,13 +561,41 @@ bool ActorSpriteManager::pickUpAll(int x1, int y1, int x2, int y2,
FloorItem *tempItem = static_cast<FloorItem*>(*it);
if (tempItem->getPickupCount() < cnt)
{
- item = tempItem;
- cnt = item->getPickupCount();
- if (cnt == 0)
+ const ItemInfo &info = tempItem->getInfo();
+ std::string name;
+ if (serverVersion > 0)
+ name = info.getName(tempItem->getColor());
+ else
+ name = info.getName();
+ if (allowAll)
{
- item->incrementPickup();
- player_node->pickUp(item);
- return true;
+ if (mIgnorePickupItemsSet.find(name)
+ == mIgnorePickupItemsSet.end())
+ {
+ item = tempItem;
+ cnt = item->getPickupCount();
+ if (cnt == 0)
+ {
+ item->incrementPickup();
+ player_node->pickUp(item);
+ return true;
+ }
+ }
+ }
+ else
+ {
+ if (mPickupItemsSet.find(name)
+ != mPickupItemsSet.end())
+ {
+ item = tempItem;
+ cnt = item->getPickupCount();
+ if (cnt == 0)
+ {
+ item->incrementPickup();
+ player_node->pickUp(item);
+ return true;
+ }
+ }
}
}
}
@@ -557,6 +614,7 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
maxdist = maxdist * maxdist;
FloorItem *closestItem = nullptr;
int dist = 0;
+ bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
for_actors
{
@@ -574,8 +632,29 @@ bool ActorSpriteManager::pickUpNearest(int x, int y, int maxdist)
|| player_node->isReachable(item->getTileX(),
item->getTileY())))
{
- dist = d;
- closestItem = item;
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+ if (allowAll)
+ {
+ if (mIgnorePickupItemsSet.find(name)
+ == mIgnorePickupItemsSet.end())
+ {
+ dist = d;
+ closestItem = item;
+ }
+ }
+ else
+ {
+ if (mPickupItemsSet.find(name) != mPickupItemsSet.end())
+ {
+ dist = d;
+ closestItem = item;
+ }
+ }
}
}
}
@@ -1378,6 +1457,15 @@ void ActorSpriteManager::removeAttackMob(const std::string &name)
rebuildPriorityAttackMobs();
}
+void ActorSpriteManager::removePickupItem(const std::string &name)
+{
+ mPickupItems.remove(name);
+ mPickupItemsSet.erase(name);
+ mIgnorePickupItems.remove(name);
+ mIgnorePickupItemsSet.erase(name);
+ rebuildPickupItems();
+}
+
#define addMobToList(name, mob) \
{\
int size = get##mob##sSize();\
@@ -1435,6 +1523,19 @@ void ActorSpriteManager::addIgnoreAttackMob(std::string name)
rebuildPriorityAttackMobs();
}
+void ActorSpriteManager::addPickupItem(std::string name)
+{
+ addMobToList(name, PickupItem);
+ rebuildPickupItems();
+}
+
+void ActorSpriteManager::addIgnorePickupItem(std::string name)
+{
+ mIgnorePickupItems.push_back(name);
+ mIgnorePickupItemsSet.insert(name);
+ rebuildPickupItems();
+}
+
void ActorSpriteManager::rebuildPriorityAttackMobs()
{
rebuildMobsList(PriorityAttackMob);
@@ -1445,6 +1546,11 @@ void ActorSpriteManager::rebuildAttackMobs()
rebuildMobsList(AttackMob);
}
+void ActorSpriteManager::rebuildPickupItems()
+{
+ rebuildMobsList(PickupItem);
+}
+
int ActorSpriteManager::getIndexByName(std::string name,
std::map<std::string, int> &map)
{
@@ -1466,6 +1572,11 @@ int ActorSpriteManager::getAttackMobIndex(std::string name)
return getIndexByName(name, mAttackMobsMap);
}
+int ActorSpriteManager::getPickupItemIndex(std::string name)
+{
+ return getIndexByName(name, mPickupItemsMap);
+}
+
#define loadList(key, mob) \
{\
list = unpackList(serverConfig.getValue(key, ""));\
@@ -1491,15 +1602,24 @@ void ActorSpriteManager::loadAttackList()
loadList("attackPriorityMobs", PriorityAttackMob);
loadList("attackMobs", AttackMob);
loadList("ignoreAttackMobs", IgnoreAttackMob);
-
if (!empty)
{
mAttackMobs.push_back("");
mAttackMobsSet.insert("");
+ empty = false;
+ }
+
+ loadList("pickupItems", PickupItem);
+ loadList("ignorePickupItems", IgnorePickupItem);
+ if (!empty)
+ {
+ mPickupItems.push_back("");
+ mPickupItemsSet.insert("");
}
rebuildAttackMobs();
rebuildPriorityAttackMobs();
+ rebuildPickupItems();
}
void ActorSpriteManager::storeAttackList()
@@ -1507,4 +1627,28 @@ void ActorSpriteManager::storeAttackList()
serverConfig.setValue("attackPriorityMobs", packList(mPriorityAttackMobs));
serverConfig.setValue("attackMobs", packList(mAttackMobs));
serverConfig.setValue("ignoreAttackMobs", packList(mIgnoreAttackMobs));
+
+ serverConfig.setValue("pickupItems", packList(mPickupItems));
+ serverConfig.setValue("ignorePickupItems", packList(mIgnorePickupItems));
+}
+
+bool ActorSpriteManager::checkForPickup(FloorItem *item)
+{
+ const ItemInfo &info = item->getInfo();
+ std::string name;
+ if (serverVersion > 0)
+ name = info.getName(item->getColor());
+ else
+ name = info.getName();
+
+ if (mPickupItemsSet.find("") != mPickupItemsSet.end())
+ {
+ if (mIgnorePickupItemsSet.find(name) == mIgnorePickupItemsSet.end())
+ return true;
+ }
+ else if (mPickupItemsSet.find(name) != mPickupItemsSet.end())
+ {
+ return true;
+ }
+ return false;
}
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 9605b9ccd..7ce00dd68 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -226,17 +226,17 @@ class ActorSpriteManager: public ConfigListener
void removeAttackMob(const std::string &name);
+ void removePickupItem(const std::string &name);
+
void addPriorityAttackMob(std::string name);
void addAttackMob(std::string name);
void addIgnoreAttackMob(std::string name);
- std::list<std::string> getPriorityAttackMobs() const
- { return mPriorityAttackMobs; }
+ void addPickupItem(std::string name);
- std::list<std::string> getAttackMobs() const
- { return mAttackMobs; }
+ void addIgnorePickupItem(std::string name);
void setPriorityAttackMobs(std::list<std::string> mobs)
{ mPriorityAttackMobs = mobs; }
@@ -250,36 +250,23 @@ class ActorSpriteManager: public ConfigListener
int getAttackMobsSize() const
{ return static_cast<int>(mAttackMobs.size()); }
- std::list<std::string> getIgnoreAttackMobs() const
- { return mIgnoreAttackMobs; }
-
- std::set<std::string> getAttackMobsSet() const
- { return mAttackMobsSet; }
-
- std::set<std::string> getPriorityAttackMobsSet() const
- { return mPriorityAttackMobsSet; }
-
- std::set<std::string> getIgnoreAttackMobsSet() const
- { return mIgnoreAttackMobsSet; }
-
- void rebuildPriorityAttackMobs();
+ int getPickupItemsSize() const
+ { return static_cast<int>(mPickupItems.size()); }
- void rebuildAttackMobs();
+#define defList(list1, mob) \
+ bool isIn##list1##List(const std::string &name) const\
+ { return m##list1##mob##Set.find(name) != m##list1##mob##Set.end(); }\
+ void rebuild##list1##mob();\
+ std::set<std::string> get##list1##mob##Set() const\
+ { return m##list1##mob##Set; }\
+ std::list<std::string> get##list1##mob() const\
+ { return m##list1##mob; }
- bool isInAttackList(const std::string &name) const
- { return mAttackMobsSet.find(name) != mAttackMobsSet.end(); }
-
- bool isInPriorityAttackList(const std::string &name)
- {
- return mPriorityAttackMobsSet.find(name)
- != mPriorityAttackMobsSet.end();
- }
-
- bool isInIgnoreAttackList(const std::string &name)
- {
- return mIgnoreAttackMobsSet.find(name)
- != mIgnoreAttackMobsSet.end();
- }
+ defList(Attack, Mobs)
+ defList(PriorityAttack, Mobs)
+ defList(IgnoreAttack, Mobs)
+ defList(Pickup, Items)
+ defList(IgnorePickup, Items)
std::map<std::string, int> getAttackMobsMap() const
{ return mAttackMobsMap; }
@@ -291,8 +278,12 @@ class ActorSpriteManager: public ConfigListener
int getPriorityAttackMobIndex(std::string name);
+ int getPickupItemIndex(std::string name);
+
int getIndexByName(std::string name, std::map<std::string, int> &map);
+ bool checkForPickup(FloorItem *item);
+
protected:
bool validateBeing(Being *aroundBeing, Being* being,
Being::Type type, Being* excluded = nullptr,
@@ -317,14 +308,21 @@ class ActorSpriteManager: public ConfigListener
bool mCycleMonsters;
bool mExtMouseTargeting;
- std::list<std::string> mPriorityAttackMobs;
- std::list<std::string> mAttackMobs;
- std::list<std::string> mIgnoreAttackMobs;
- std::set<std::string> mPriorityAttackMobsSet;
- std::set<std::string> mAttackMobsSet;
- std::set<std::string> mIgnoreAttackMobsSet;
- std::map<std::string, int> mPriorityAttackMobsMap;
- std::map<std::string, int> mAttackMobsMap;
+#define defVarsP(mob) \
+ std::list<std::string> mPriority##mob;\
+ std::set<std::string> mPriority##mob##Set;\
+ std::map<std::string, int> mPriority##mob##Map;
+
+#define defVars(mob) \
+ std::list<std::string> m##mob;\
+ std::set<std::string> m##mob##Set;\
+ std::map<std::string, int> m##mob##Map;\
+ std::list<std::string> mIgnore##mob;\
+ std::set<std::string> mIgnore##mob##Set;
+
+ defVarsP(AttackMobs)
+ defVars(AttackMobs)
+ defVars(PickupItems)
};
extern ActorSpriteManager *actorSpriteManager;
diff --git a/src/defaults.cpp b/src/defaults.cpp
index d65e722de..a5f8083c1 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -199,6 +199,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "showExtMinimaps", false);
AddDEF(configData, "hideChatInput", true);
AddDEF(configData, "enableAttackFilter", true);
+ AddDEF(configData, "enablePickupFilter", true);
AddDEF(configData, "securetrades", true);
AddDEF(configData, "unsecureChars", "IO0@#$");
AddDEF(configData, "currentTip", 0);
diff --git a/src/flooritem.h b/src/flooritem.h
index 1f3126078..791b125f1 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -87,6 +87,9 @@ class FloorItem : public ActorSprite
void setShowMsg(bool n)
{ mShowMsg = n; }
+ void disableHightlight()
+ { mHighlight = false; }
+
private:
int mItemId;
int mX, mY;
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();
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 6cf02bf4a..ade74edc1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -937,8 +937,11 @@ bool LocalPlayer::pickUp(FloorItem *item)
if (dx * dx + dy * dy < dist)
{
- Net::getPlayerHandler()->pickUp(item);
- mPickUpTarget = nullptr;
+ if (actorSpriteManager->checkForPickup(item))
+ {
+ Net::getPlayerHandler()->pickUp(item);
+ mPickUpTarget = nullptr;
+ }
}
else if (mPickUpType >= 4 && mPickUpType <= 6)
{
diff --git a/src/maplayer.h b/src/maplayer.h
index 861ef1318..327a6baa0 100644
--- a/src/maplayer.h
+++ b/src/maplayer.h
@@ -231,7 +231,9 @@ class MapItem
ATTACK = 10,
PRIORITY = 11,
IGNORE_ = 12,
- SEPARATOR = 13
+ PICKUP = 13,
+ NOPICKUP = 14,
+ SEPARATOR = 15
};
MapItem();