diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-01-26 21:00:03 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-05 22:18:07 -0700 |
commit | b5f54a7bc2e8df4187e847d72a6fee2ffd6c5299 (patch) | |
tree | 280e63f606d40b0e3f7a55a2bb3793aed07d64de /src/gui | |
parent | c5331a575468ee94b4cde35d157b74d9776676e5 (diff) | |
download | mana-client-b5f54a7bc2e8df4187e847d72a6fee2ffd6c5299.tar.gz mana-client-b5f54a7bc2e8df4187e847d72a6fee2ffd6c5299.tar.bz2 mana-client-b5f54a7bc2e8df4187e847d72a6fee2ffd6c5299.tar.xz mana-client-b5f54a7bc2e8df4187e847d72a6fee2ffd6c5299.zip |
Image alpha should also be set to 1, in case it was changed before.
(cherry picked from mainline commit 0962fc8b567279a6e97e13e4b3f2f9f2ffe304c0)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/truetypefont.cpp | 14 | ||||
-rw-r--r-- | src/gui/truetypefont.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index 82a22bc2..5576eaab 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -35,7 +35,7 @@ class TextChunk { public: - TextChunk(const std::string &text, gcn::Color color) : + TextChunk(const std::string &text, const gcn::Color &color) : img(NULL), text(text), color(color) { } @@ -130,12 +130,12 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, } gcn::Color col = g->getColor(); - float alpha = 1.0f; - if (col.a != 255) alpha = col.a / 255.0f; - col.a = 255; - /* alpha value is ignored at sting generation so it makes no sense to - * cache the same text with different alpha values. + const float alpha = col.a / 255.0f; + + /* The alpha value is ignored at string generation so avoid caching the + * same text with different alpha values. */ + col.a = 255; TextChunk chunk(text, col); @@ -163,7 +163,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, cache.front().generate(mFont); } - if (alpha != 1.0f) cache.front().img->setAlpha(alpha); + cache.front().img->setAlpha(alpha); g->drawImage(cache.front().img, x, y); } diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index d496d82e..7a4ee9ac 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -33,7 +33,7 @@ /** * A wrapper around SDL_ttf for allowing the use of TrueType fonts. * - * <b>NOTE:</b> This class needs SDL_ttf to be initialized. + * <b>NOTE:</b> This class initializes SDL_ttf as necessary. */ class TrueTypeFont : public gcn::Font { |