diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-14 19:08:25 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-14 22:12:15 +0200 |
commit | 53c32dd1beb5575c38bbc830f7d37cb954be90d2 (patch) | |
tree | 66acb3c3fb03e9e08a39520f805c03ade87f6430 | |
parent | 2477cc428795d678142bf6f66147790c71ad03fd (diff) | |
download | mana-53c32dd1beb5575c38bbc830f7d37cb954be90d2.tar.gz mana-53c32dd1beb5575c38bbc830f7d37cb954be90d2.tar.bz2 mana-53c32dd1beb5575c38bbc830f7d37cb954be90d2.tar.xz mana-53c32dd1beb5575c38bbc830f7d37cb954be90d2.zip |
Fixed alpha to also apply to the main text of a text particle
It was only being applied to the outline and shadow. This improves the
fadeout a little, but because the text is being rendered multiple times,
it still looks strange.
(cherry picked from commit 3591c264f14edf300e7d3ea20577c517a092cf50)
-rw-r--r-- | src/gui/textrenderer.h | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 3 | ||||
-rw-r--r-- | src/localplayer.h | 3 | ||||
-rw-r--r-- | src/textparticle.cpp | 17 | ||||
-rw-r--r-- | src/textparticle.h | 2 |
5 files changed, 13 insertions, 14 deletions
diff --git a/src/gui/textrenderer.h b/src/gui/textrenderer.h index 712c1312..c8ff5833 100644 --- a/src/gui/textrenderer.h +++ b/src/gui/textrenderer.h @@ -50,7 +50,7 @@ class TextRenderer if (shadow) { graphics->setColor(guiPalette->getColor(Palette::SHADOW, - alpha / 2)); + alpha / 2)); if (outline) { graphics->drawText(text, x + 2, y + 2, align); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c1423190..7119bfc9 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -946,7 +946,8 @@ void LocalPlayer::initTargetCursor() true, TC_LARGE); } -void LocalPlayer::loadTargetCursor(std::string filename, int width, int height, +void LocalPlayer::loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, TargetCursorSize size) { assert(size > -1); diff --git a/src/localplayer.h b/src/localplayer.h index add5c049..4a85dd75 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -490,7 +490,8 @@ class LocalPlayer : public Player /** * Helper function for loading target cursors */ - void loadTargetCursor(std::string filename, int width, int height, + void loadTargetCursor(const std::string &filename, + int width, int height, bool outRange, Being::TargetCursorSize size); /** Images of the target cursor. */ diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 04b7abe1..da176087 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -26,7 +26,7 @@ #include "gui/textrenderer.h" TextParticle::TextParticle(Map *map, const std::string &text, - const gcn::Color* color, + const gcn::Color *color, gcn::Font *font, bool outline): Particle(map), mText(text), @@ -47,18 +47,15 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const float alpha = mAlpha * 255.0f; if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut) - { - alpha *= mLifetimeLeft; - alpha /= mFadeOut; - } + alpha = alpha * mLifetimeLeft / mFadeOut; if (mLifetimePast < mFadeIn) - { - alpha *= mLifetimePast; - alpha /= mFadeIn; - } + alpha = alpha * mLifetimePast / mFadeIn; + + gcn::Color color = *mColor; + color.a = (int) alpha; TextRenderer::renderText(graphics, mText, screenX, screenY, gcn::Graphics::CENTER, - *mColor, mTextFont, mOutline, false, (int) alpha); + color, mTextFont, mOutline, false, (int) alpha); } diff --git a/src/textparticle.h b/src/textparticle.h index 8b7d3e01..a87137ea 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -47,7 +47,7 @@ class TextParticle : public Particle private: std::string mText; /**< Text of the particle. */ gcn::Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color* mColor; /**< Color used for drawing the text. */ + const gcn::Color *mColor; /**< Color used for drawing the text. */ bool mOutline; /**< Make the text better readable */ }; |