summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-21 04:03:12 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-21 04:03:12 +0300
commit4bb1025466856bdab15f95806cb8d521552f3759 (patch)
tree967c7a3281ee5c7978b55c8d3fd7bdd0112692c5
parent1f846d2863d36543c854fe630519a4d1fd01f802 (diff)
downloadmv-4bb1025466856bdab15f95806cb8d521552f3759.tar.gz
mv-4bb1025466856bdab15f95806cb8d521552f3759.tar.bz2
mv-4bb1025466856bdab15f95806cb8d521552f3759.tar.xz
mv-4bb1025466856bdab15f95806cb8d521552f3759.zip
Add option to disable advanced mouse targeting.
-rw-r--r--src/actorspritemanager.cpp106
-rw-r--r--src/actorspritemanager.h1
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/setup_players.cpp3
4 files changed, 75 insertions, 36 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 52d807f64..18ef869c1 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -177,11 +177,13 @@ ActorSpriteManager::ActorSpriteManager() :
mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
mCyclePlayers = config.getBoolValue("cyclePlayers");
mCycleMonsters = config.getBoolValue("cycleMonsters");
+ mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
config.addListener("targetDeadPlayers", this);
config.addListener("targetOnlyReachable", this);
config.addListener("cyclePlayers", this);
config.addListener("cycleMonsters", this);
+ config.addListener("extMouseTargeting", this);
loadAttackList();
}
@@ -192,6 +194,7 @@ ActorSpriteManager::~ActorSpriteManager()
config.removeListener("targetOnlyReachable", this);
config.removeListener("cyclePlayers", this);
config.removeListener("cycleMonsters", this);
+ config.removeListener("extMouseTargeting", this);
storeAttackList();
clear();
}
@@ -300,39 +303,81 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
return NULL;
bool targetDead = mTargetDeadPlayers;
- Being *tempBeing = 0;
- bool noBeing(false);
- for_actors
+ if (mExtMouseTargeting)
{
- if (!*it)
- continue;
+ Being *tempBeing = 0;
+ bool noBeing(false);
- if ((*it)->getType() == ActorSprite::PORTAL)
- continue;
-
- if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ for_actors
{
- if (!noBeing)
+ if (!*it)
+ continue;
+
+ if ((*it)->getType() == ActorSprite::PORTAL)
+ continue;
+
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
{
- FloorItem *floor = static_cast<FloorItem*>(*it);
- if (!noBeing && (floor->getPixelX() - 32 <= x) &&
- (floor->getPixelX() + 32 > x) &&
- (floor->getPixelY() - 64 <= y) &&
- (floor->getPixelY() + 16 > y))
+ if (!noBeing)
{
- noBeing = true;
+ FloorItem *floor = static_cast<FloorItem*>(*it);
+ if (!noBeing && (floor->getPixelX() - 32 <= x) &&
+ (floor->getPixelX() + 32 > x) &&
+ (floor->getPixelY() - 64 <= y) &&
+ (floor->getPixelY() + 16 > y))
+ {
+ noBeing = true;
+ }
}
+ continue;
}
- continue;
- }
- Being *being = static_cast<Being*>(*it);
+ Being *being = static_cast<Being*>(*it);
- if ((being->isAlive()
- || (targetDead && being->getType() == Being::PLAYER))
- && (allPlayers || being != player_node))
+ if ((being->isAlive()
+ || (targetDead && being->getType() == Being::PLAYER))
+ && (allPlayers || being != player_node))
+ {
+
+ if ((being->getPixelX() - 16 <= x) &&
+ (being->getPixelX() + 16 > x) &&
+ (being->getPixelY() - 32 <= y) &&
+ (being->getPixelY() > y))
+ {
+ return being;
+ }
+ else if (!noBeing && (being->getPixelX() - 32 <= x) &&
+ (being->getPixelX() + 32 > x) &&
+ (being->getPixelY() - 64 <= y) &&
+ (being->getPixelY() + 16 > y))
+ {
+ if (tempBeing)
+ noBeing = true;
+ else
+ tempBeing = being;
+ }
+ }
+ }
+
+ if (noBeing)
+ return 0;
+ return tempBeing;
+ }
+ else
+ {
+ for_actors
{
+ if (!*it)
+ continue;
+
+ if ((*it)->getType() == ActorSprite::PORTAL ||
+ (*it)->getType() == ActorSprite::FLOOR_ITEM)
+ {
+ continue;
+ }
+
+ Being *being = static_cast<Being*>(*it);
if ((being->getPixelX() - 16 <= x) &&
(being->getPixelX() + 16 > x) &&
@@ -341,22 +386,9 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
{
return being;
}
- else if (!noBeing && (being->getPixelX() - 32 <= x) &&
- (being->getPixelX() + 32 > x) &&
- (being->getPixelY() - 64 <= y) &&
- (being->getPixelY() + 16 > y))
- {
- if (tempBeing)
- noBeing = true;
- else
- tempBeing = being;
- }
}
- }
-
- if (noBeing)
return 0;
- return tempBeing;
+ }
}
void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings,
@@ -1298,6 +1330,8 @@ void ActorSpriteManager::optionChanged(const std::string &name)
mCyclePlayers = config.getBoolValue("cyclePlayers");
else if (name == "cycleMonsters")
mCycleMonsters = config.getBoolValue("cycleMonsters");
+ else if (name == "extMouseTargeting")
+ mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
}
void ActorSpriteManager::removeAttackMob(const std::string &name)
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index bd2ae79fb..d2d9af108 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -318,6 +318,7 @@ class ActorSpriteManager: public ConfigListener
bool mTargetOnlyReachable;
bool mCyclePlayers;
bool mCycleMonsters;
+ bool mExtMouseTargeting;
std::list<std::string> mPriorityAttackMobs;
std::list<std::string> mAttackMobs;
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 4a82a83a9..d7fa07a07 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -218,6 +218,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "showip", false);
AddDEF(configData, "seflMouseHeal", true);
AddDEF(configData, "enableLazyScrolling", true);
+ AddDEF(configData, "extMouseTargeting", true);
return configData;
}
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 670fc3635..a6bf5b81c 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -60,6 +60,9 @@ Setup_Players::Setup_Players()
new SetupItemCheckBox(_("Show own name"), "",
"showownname", this, "showownnameEvent");
+ new SetupItemCheckBox(_("Enable extended mouse targeting"), "",
+ "extMouseTargeting", this, "extMouseTargetingEvent");
+
new SetupItemCheckBox(_("Target dead players"), "",
"targetDeadPlayers", this, "targetDeadPlayersEvent");