summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-05-07 16:22:54 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-05-07 16:22:54 +0000
commit8313edcc163bfecd1c41a7faf55f51379189b92b (patch)
treeebb6f1db2038b3277aca90efe4061c5b8e1820c4 /src/gui
parent279b74f292a45709afcddeea6667d0096d06fd3f (diff)
downloadmana-client-8313edcc163bfecd1c41a7faf55f51379189b92b.tar.gz
mana-client-8313edcc163bfecd1c41a7faf55f51379189b92b.tar.bz2
mana-client-8313edcc163bfecd1c41a7faf55f51379189b92b.tar.xz
mana-client-8313edcc163bfecd1c41a7faf55f51379189b92b.zip
Fixed positioning of monster names and target circles.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/viewport.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 84634ca6..3def2055 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -41,6 +41,7 @@
#include "../resources/animation.h"
#include "../resources/monsterinfo.h"
#include "../resources/resourcemanager.h"
+#include "../resources/image.h"
#include "../resources/imageset.h"
#include "../utils/tostring.h"
@@ -272,26 +273,28 @@ Viewport::drawTargetCursor(Graphics *graphics)
Being *target = player_node->getTarget();
if (target)
{
+ // Calculate target circle position
+
// Find whether target is in range
int rangeX = abs(target->mX - player_node->mX);
int rangeY = abs(target->mY - player_node->mY);
int attackRange = player_node->getAttackRange();
- // Draw the target cursor, which one depends if the target is in range
+ // get the correct target cursors graphic
+ Image* targetCursor;
if (rangeX > attackRange || rangeY > attackRange)
{
- // Draw the out of range cursor
- graphics->drawImage(mTargetCursorOutRange->getCurrentImage(),
- target->getPixelX() - (int) mViewX,
- target->getPixelY() - (int) mViewY);
+ targetCursor = mTargetCursorOutRange->getCurrentImage();
}
- else
- {
- // Draw the in range cursor
- graphics->drawImage(mTargetCursorInRange->getCurrentImage(),
- target->getPixelX() - (int) mViewX,
- target->getPixelY() - (int) mViewY);
+ else {
+ targetCursor = mTargetCursorInRange->getCurrentImage();
}
+
+ // Draw the target cursor at the correct position
+ int posX = target->getPixelX() + 16 - targetCursor->getWidth() / 2 - (int) mViewX;
+ int posY = target->getPixelY() + 16 - targetCursor->getHeight() / 2 - (int) mViewY;
+
+ graphics->drawImage(targetCursor, posX, posY);
}
}
@@ -306,10 +309,10 @@ Viewport::drawTargetName(Graphics *graphics)
graphics->setColor(gcn::Color(255, 32, 32));
const MonsterInfo &mi = static_cast<Monster*>(target)->getInfo();
- graphics->drawText(mi.getName(),
- target->getPixelX() - (int) mViewX + 15,
- target->getPixelY() - (int) mViewY - 42,
- gcn::Graphics::CENTER);
+ int posX = target->getPixelX() + 16 - (int)mViewX;
+ int posY = target->getPixelY() + 16 - target->getHeight() - (int)mViewY;
+
+ graphics->drawText(mi.getName(), posX, posY, gcn::Graphics::CENTER);
}
}