00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <guichan/color.hpp>
00023
00024 #include "textparticle.h"
00025
00026 #include "gui/textrenderer.h"
00027
00028 TextParticle::TextParticle(Map *map, const std::string &text,
00029 const gcn::Color* color,
00030 gcn::Font *font, bool outline):
00031 Particle(map),
00032 mText(text),
00033 mTextFont(font),
00034 mColor(color),
00035 mOutline(outline)
00036 {
00037 }
00038
00039 void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
00040 {
00041 if (!mAlive)
00042 return;
00043
00044 int screenX = (int) mPos.x + offsetX;
00045 int screenY = (int) mPos.y - (int) mPos.z + offsetY;
00046
00047 float alpha = mAlpha * 255.0f;
00048
00049 if (mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
00050 {
00051 alpha *= mLifetimeLeft;
00052 alpha /= mFadeOut;
00053 }
00054
00055 if (mLifetimePast < mFadeIn)
00056 {
00057 alpha *= mLifetimePast;
00058 alpha /= mFadeIn;
00059 }
00060
00061 TextRenderer::renderText(graphics, mText,
00062 screenX, screenY, gcn::Graphics::CENTER,
00063 *mColor, mTextFont, mOutline, false, (int) alpha);
00064 }