summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-26 21:56:11 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-26 21:56:11 +0300
commit8f10444e4ce4a4e25455f0a3857edc7ca74631e8 (patch)
tree7917730822f7bc090adc6af482eab843c79a389c /src/gui
parent110134603554e06adab93a132ef8f82e55db68ad (diff)
downloadplus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.gz
plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.bz2
plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.xz
plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.zip
Impliment 3 attack lists. (priority, attack, ignore)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popupmenu.cpp136
-rw-r--r--src/gui/popupmenu.h2
-rw-r--r--src/gui/socialwindow.cpp43
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/viewport.h2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp65
6 files changed, 193 insertions, 59 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 7b0688587..ad0cb275f 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -254,19 +254,19 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (config.getBoolValue("enableAttackFilter"))
{
mBrowserBox->addRow("##3---");
- if (player_node->isInAttackList(name))
+ if (player_node->isInAttackList(name)
+ || player_node->isInIgnoreAttackList(name)
+ || player_node->isInPriorityAttackList(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 priority|Add "
+ "to priority attack list@@"));
+ mBrowserBox->addRow(
_("@@add attack|Add to attack list@@"));
mBrowserBox->addRow(
_("@@add attack ignore|Add to ignore list@@"));
@@ -1165,6 +1165,15 @@ void PopupMenu::handleLink(const std::string &link,
socialWindow->updateAttackFilter();
}
}
+ else if (link == "add attack priority" && being)
+ {
+ if (player_node && being->getType() == Being::MONSTER)
+ {
+ player_node->addPriorityAttackMob(being->getName());
+ if (socialWindow)
+ socialWindow->updateAttackFilter();
+ }
+ }
else if (link == "add attack ignore" && being)
{
if (player_node && being->getType() == Being::MONSTER)
@@ -1203,6 +1212,36 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
+ else if (link == "priority moveup")
+ {
+ if (player_node)
+ {
+ int idx = player_node->getPriorityAttackMobIndex(mNick);
+ if (idx > 0)
+ {
+ std::list<std::string> mobs
+ = player_node->getPriorityAttackMobs();
+ 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->setPriorityAttackMobs(mobs);
+ player_node->rebuildPriorityAttackMobs();
+ break;
+ }
+ ++ it;
+ ++ it2;
+ }
+
+ if (socialWindow)
+ socialWindow->updateAttackFilter();
+ }
+ }
+ }
else if (link == "attack movedown")
{
if (player_node)
@@ -1236,6 +1275,40 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
+ else if (link == "priority movedown")
+ {
+ if (player_node)
+ {
+ int idx = player_node->getPriorityAttackMobIndex(mNick);
+ int size = player_node->getPriorityAttackMobsSize();
+ if (idx + 1 < size)
+ {
+ std::list<std::string> mobs
+ = player_node->getPriorityAttackMobs();
+ 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->setPriorityAttackMobs(mobs);
+ player_node->rebuildPriorityAttackMobs();
+ break;
+ }
+ ++ it;
+ ++ it2;
+ }
+
+ if (socialWindow)
+ socialWindow->updateAttackFilter();
+ }
+ }
+ }
else if (link == "attack remove")
{
if (player_node)
@@ -1606,7 +1679,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
}
void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
- bool isAttack)
+ int type)
{
if (!player_node)
return;
@@ -1619,27 +1692,48 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
mBrowserBox->addRow(_("(default)"));
else
mBrowserBox->addRow(name);
- if (isAttack)
+ switch (type)
{
- int idx = player_node->getAttackMobIndex(name);
- int size = player_node->getAttackMobsSize();
- if (idx > 0)
+ case MapItem::ATTACK:
{
+ 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 moveup|%s@@", _("Move up")));
+ "@@attack remove|%s@@", _("Remove")));
+ break;
}
- if (idx + 1 < size)
+ case MapItem::PRIORITY:
{
+ int idx = player_node->getPriorityAttackMobIndex(name);
+ int size = player_node->getPriorityAttackMobsSize();
+ if (idx > 0)
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@priority moveup|%s@@", _("Move up")));
+ }
+ if (idx + 1 < size)
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@priority movedown|%s@@", _("Move down")));
+ }
mBrowserBox->addRow(strprintf(
- "@@attack movedown|%s@@", _("Move down")));
+ "@@attack remove|%s@@", _("Remove")));
+ break;
}
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
- }
- else
- {
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ case MapItem::IGNORE:
+ mBrowserBox->addRow(strprintf(
+ "@@attack remove|%s@@", _("Remove")));
+ break;
}
mBrowserBox->addRow("##3---");
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 61720d417..208652083 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -118,7 +118,7 @@ class PopupMenu : public Popup, public LinkHandler
void showSpellPopup(int x, int y, TextCommand *cmd);
void showAttackMonsterPopup(int x, int y, std::string name,
- bool isAttack);
+ int type);
/**
* Shows the related popup menu when right click on the chat
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index c6ec12cd8..d25ca209d 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -808,7 +808,7 @@ public:
std::vector<Avatar*> *avatars = mBeings->getMembers();
- std::list<std::string> mobs = player_node->getAttackMobs();
+ std::list<std::string> mobs = player_node->getPriorityAttackMobs();
std::list<std::string>::iterator i = mobs.begin();
std::vector<Avatar*>::iterator ia = avatars->begin();
@@ -820,7 +820,7 @@ public:
}
avatars->clear();
- Avatar *ava = new Avatar(_("Selected mobs"));
+ Avatar *ava = new Avatar(_("Priority mobs"));
ava->setOnline(false);
ava->setLevel(-1);
ava->setType(MapItem::SEPARATOR);
@@ -844,7 +844,42 @@ public:
Avatar *ava = new Avatar(name);
ava->setOnline(true);
ava->setLevel(level);
- ava->setType(MapItem::MONSTER);
+ ava->setType(MapItem::PRIORITY);
+ ava->setX(0);
+ ava->setY(0);
+ avatars->push_back(ava);
+
+ ++ i;
+ }
+
+ 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);
+
+ mobs = player_node->getAttackMobs();
+ 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(true);
+ ava->setLevel(level);
+ ava->setType(MapItem::ATTACK);
ava->setX(0);
ava->setY(0);
avatars->push_back(ava);
@@ -879,7 +914,7 @@ public:
Avatar *ava = new Avatar(name);
ava->setOnline(false);
ava->setLevel(level);
- ava->setType(MapItem::MONSTER);
+ ava->setType(MapItem::IGNORE);
ava->setX(0);
ava->setY(0);
avatars->push_back(ava);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 9688c818a..478059f53 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -625,10 +625,10 @@ void Viewport::showPopup(int x, int y, ProgressBar *bar)
mPopupMenu->showPopup(x, y, bar);
}
-void Viewport::showAttackMonsterPopup(std::string name, bool isAttack)
+void Viewport::showAttackMonsterPopup(std::string name, int type)
{
mPopupMenu->showAttackMonsterPopup(getMouseX(), getMouseY(),
- name, isAttack);
+ name, type);
}
void Viewport::closePopupMenu()
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 59db38e4c..d3a3bfe4b 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -160,7 +160,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void showSpellPopup(TextCommand *cmd);
- void showAttackMonsterPopup(std::string name, bool isAttack);
+ void showAttackMonsterPopup(std::string name, int type);
/**
* Shows the related popup menu when right click on the chat
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index f3bdb6a45..d16388837 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -308,42 +308,47 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- if (ava->getType() == AVATAR_PLAYER)
+ switch (ava->getType())
{
- Being* being = actorSpriteManager->findBeingByName(
- model->getAvatarAt(selected)->getName(), Being::PLAYER);
- if (being)
- {
- viewport->showPopup(event.getX(), event.getY(), being);
- }
- else
+ case AVATAR_PLAYER:
{
- viewport->showPlayerPopup(
- model->getAvatarAt(selected)->getName());
- }
- }
- else if (ava->getType() == MapItem::MONSTER)
- {
- if (model->getAvatarAt(selected)->getLevel() == 0)
- {
- viewport->showAttackMonsterPopup("",
- model->getAvatarAt(selected)->getOnline());
+ Being* being = actorSpriteManager->findBeingByName(
+ model->getAvatarAt(selected)->getName(), Being::PLAYER);
+ if (being)
+ {
+ viewport->showPopup(event.getX(), event.getY(), being);
+ }
+ else
+ {
+ viewport->showPlayerPopup(
+ model->getAvatarAt(selected)->getName());
+ }
+ break;
}
- else
+ case MapItem::ATTACK:
+ case MapItem::PRIORITY:
+ case MapItem::IGNORE:
{
- viewport->showAttackMonsterPopup(
- model->getAvatarAt(selected)->getName(),
- model->getAvatarAt(selected)->getOnline());
+ std::string name;
+ if (model->getAvatarAt(selected)->getLevel() == 0)
+ name = "";
+ else
+ name = model->getAvatarAt(selected)->getName();
+
+ viewport->showAttackMonsterPopup(name,
+ model->getAvatarAt(selected)->getType());
+ break;
}
- }
- else
- {
- Map *map = viewport->getMap();
- Avatar *ava = model->getAvatarAt(selected);
- if (map && ava)
+ default:
{
- MapItem *mapItem = map->findPortalXY(ava->getX(), ava->getY());
- viewport->showPopup(mapItem);
+ Map *map = viewport->getMap();
+ Avatar *ava = model->getAvatarAt(selected);
+ if (map && ava)
+ {
+ MapItem *mapItem = map->findPortalXY(ava->getX(), ava->getY());
+ viewport->showPopup(mapItem);
+ }
+ break;
}
}
}