00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TEXT_RENDERER_H
00023 #define TEXT_RENDERER_H
00024
00025 #include "graphics.h"
00026 #include "palette.h"
00027
00032 class TextRenderer
00033 {
00034 public:
00038 static inline void renderText(gcn::Graphics *graphics,
00039 const std::string &text,
00040 int x, int y,
00041 gcn::Graphics::Alignment align,
00042 const gcn::Color &color,
00043 gcn::Font *font,
00044 bool outline = false,
00045 bool shadow = false, int alpha = 255)
00046 {
00047 graphics->setFont(font);
00048
00049
00050 if (shadow)
00051 {
00052 graphics->setColor(guiPalette->getColor(Palette::SHADOW,
00053 alpha / 2));
00054 if (outline)
00055 {
00056 graphics->drawText(text, x + 2, y + 2, align);
00057 }
00058 else
00059 {
00060 graphics->drawText(text, x + 1, y + 1, align);
00061 }
00062 }
00063
00064 if (outline) {
00065
00066
00067
00068
00069
00070
00071
00072
00073 graphics->setColor(guiPalette->getColor(Palette::OUTLINE, alpha));
00074 graphics->drawText(text, x + 1, y, align);
00075 graphics->drawText(text, x - 1, y, align);
00076 graphics->drawText(text, x, y + 1, align);
00077 graphics->drawText(text, x, y - 1, align);
00078 }
00079
00080 graphics->setColor(color);
00081 graphics->drawText(text, x, y, align);
00082 }
00083 };
00084
00085 #endif