From c7fa79ff1704d86e12e12b83e1e4745ca27a543a Mon Sep 17 00:00:00 2001 From: sniper Date: Wed, 11 Mar 2009 17:19:31 +0100 Subject: Added a class for rendering of floating text This is a header only-class that merges the textrendering of the TextParticle and Text classes. It is done to reduce code duplication and to prepare some color configuration gui. --- src/textparticle.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src/textparticle.cpp') diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 3494b97f..ed8609e9 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -21,10 +21,12 @@ #include -#include "graphics.h" -#include "textparticle.h" #include +#include "textparticle.h" + +#include "gui/textrenderer.h" + TextParticle::TextParticle(Map *map, const std::string &text, int colorR, int colorG, int colorB, gcn::Font *font, bool outline): @@ -60,24 +62,8 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const alpha /= mFadeIn; } - graphics->setFont(mTextFont); - if (mOutline) - { - graphics->setColor(gcn::Color(0, 0, 0, (int)(alpha/4))); - // Text outline - graphics->setColor(gcn::Color(0, 0, 0, (int)alpha)); - graphics->drawText(mText, screenX + 1, screenY, - gcn::Graphics::CENTER); - - graphics->drawText(mText, screenX - 1, screenY, - gcn::Graphics::CENTER); - - graphics->drawText(mText, screenX, screenY + 1, - gcn::Graphics::CENTER); - - graphics->drawText(mText, screenX, screenY - 1, - gcn::Graphics::CENTER); - } - graphics->setColor(gcn::Color(mColorR, mColorG, mColorB, (int)alpha)); - graphics->drawText(mText, screenX, screenY, gcn::Graphics::CENTER); + TextRenderer::renderText(graphics, mText, + screenX, screenY, gcn::Graphics::CENTER, + &gcn::Color(mColorR, mColorG, mColorB), mTextFont, mOutline, false, + (int)alpha); } -- cgit v1.2.3-70-g09d2