summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-05-24 02:29:28 +0300
committerJared Adams <jaxad0127@gmail.com>2010-05-24 12:59:53 -0600
commit98820e79e786f3d318a45e0f8e6100841530ff50 (patch)
tree2ea5e02d7320881b523303bd789406ac5fbfc0f8
parent698620d703fea6d572c967bfa746d475d28f2d81 (diff)
downloadmana-client-98820e79e786f3d318a45e0f8e6100841530ff50.tar.gz
mana-client-98820e79e786f3d318a45e0f8e6100841530ff50.tar.bz2
mana-client-98820e79e786f3d318a45e0f8e6100841530ff50.tar.xz
mana-client-98820e79e786f3d318a45e0f8e6100841530ff50.zip
Show selected target with bold font.
Also fix possible memory corruption. Signed-off-by: Jared Adams <jaxad0127@gmail.com>
-rw-r--r--src/being.cpp16
-rw-r--r--src/beingmanager.cpp3
-rw-r--r--src/localplayer.cpp9
-rw-r--r--src/text.cpp13
-rw-r--r--src/text.h6
5 files changed, 38 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index fd3561ae..0e09126d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -122,11 +122,14 @@ Being::Being(int id, Type type, int subtype, Map *map):
Being::~Being()
{
+ config.removeListener("visiblenames", this);
+
delete mSpeechBubble;
delete mDispName;
delete mText;
-
- config.removeListener("visiblenames", this);
+ mSpeechBubble = 0;
+ mDispName = 0;
+ mText = 0;
}
void Being::setSubtype(Uint16 subtype)
@@ -1004,8 +1007,15 @@ void Being::showName()
}
}
+ gcn::Font *font = 0;
+ if (player_node && player_node->getTarget() == this
+ && getType() != MONSTER)
+ {
+ font = boldFont;
+ }
+
mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
- gcn::Graphics::CENTER, mNameColor);
+ gcn::Graphics::CENTER, mNameColor, font);
updateCoords();
}
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index a92e3faf..79591ce6 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -182,7 +182,10 @@ void BeingManager::logic()
void BeingManager::clear()
{
if (player_node)
+ {
+ player_node->setTarget(0);
mBeings.remove(player_node);
+ }
delete_all(mBeings);
mBeings.clear();
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 40592f59..7bf339c6 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -736,14 +736,23 @@ void LocalPlayer::setTarget(Being *target)
mTargetTime = -1;
}
+ Being *oldTarget = 0;
if (mTarget)
+ {
mTarget->untarget();
+ oldTarget = mTarget;
+ }
if (mTarget && mTarget->getType() == ActorSprite::MONSTER)
mTarget->setShowName(false);
mTarget = target;
+ if (oldTarget)
+ oldTarget->updateName();
+ if (mTarget)
+ mTarget->updateName();
+
if (target && target->getType() == ActorSprite::MONSTER)
target->setShowName(true);
}
diff --git a/src/text.cpp b/src/text.cpp
index f6c71dba..9f970872 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -41,12 +41,17 @@ Image *Text::mBubbleArrow;
Text::Text(const std::string &text, int x, int y,
gcn::Graphics::Alignment alignment,
- const gcn::Color* color, bool isSpeech) :
+ const gcn::Color* color, bool isSpeech,
+ gcn::Font *font) :
mText(text),
mColor(color),
- mFont(gui->getFont()),
mIsSpeech(isSpeech)
{
+ if (!font)
+ mFont = gui->getFont();
+ else
+ mFont = font;
+
if (textManager == 0)
{
textManager = new TextManager;
@@ -145,8 +150,8 @@ void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
FlashText::FlashText(const std::string &text, int x, int y,
gcn::Graphics::Alignment alignment,
- const gcn::Color *color) :
- Text(text, x, y, alignment, color),
+ const gcn::Color *color, gcn::Font *font) :
+ Text(text, x, y, alignment, color, false, font),
mTime(0)
{
}
diff --git a/src/text.h b/src/text.h
index fcfaf6ed..c884b394 100644
--- a/src/text.h
+++ b/src/text.h
@@ -40,7 +40,8 @@ class Text
*/
Text(const std::string &text, int x, int y,
gcn::Graphics::Alignment alignment,
- const gcn::Color *color, bool isSpeech = false);
+ const gcn::Color *color, bool isSpeech = false,
+ gcn::Font *font = 0);
/**
* Destructor. The text is removed from the screen.
@@ -84,7 +85,8 @@ class FlashText : public Text
public:
FlashText(const std::string &text, int x, int y,
gcn::Graphics::Alignment alignment,
- const gcn::Color* color);
+ const gcn::Color* color,
+ gcn::Font *font = 0);
/**
* Remove the text from the screen