void
DrawingContext::draw_text(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect)
+ const Vector& position, int layer, Uint32 drawing_effect, int alpha)
{
DrawingRequest request;
textrequest->font = font;
textrequest->text = text;
textrequest->center = false;
+ textrequest->alpha = alpha;
request.request_data = textrequest;
drawingrequests.push_back(request);
void
DrawingContext::draw_text_center(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect)
+ const Vector& position, int layer, Uint32 drawing_effect, int alpha)
{
DrawingRequest request;
textrequest->font = font;
textrequest->text = text;
textrequest->center = true;
+ textrequest->alpha = alpha;
request.request_data = textrequest;
drawingrequests.push_back(request);
TextRequest* textrequest = (TextRequest*) request.request_data;
if(textrequest->center)
- textrequest->font->draw_center(textrequest->text, request.pos, request.drawing_effect);
+ textrequest->font->draw_center(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha);
else
- textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect);
+ textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha);
delete textrequest;
}
Uint32 drawing_effect = NONE_EFFECT);
/// Draws a text.
void draw_text(Font* font, const std::string& text, const Vector& position,
- int layer, Uint32 drawing_effect = NONE_EFFECT);
+ int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
/// Draws aligned text.
void draw_text_center(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT);
+ const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
/// Draws a color gradient onto the whole screen */
void draw_gradient(Color from, Color to, int layer);
/// Fills a rectangle.
Font* font;
std::string text;
bool center;
+ int alpha;
};
struct GradientRequest
}
void
-Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect)
+Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha)
{
if(shadowsize > 0)
draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize),
- drawing_effect);
+ drawing_effect, alpha);
- draw_chars(chars, text, pos, drawing_effect);
+ draw_chars(chars, text, pos, drawing_effect, alpha);
}
void
-Font::draw_center(const std::string& text, const Vector& pos, Uint32 drawing_effect)
+Font::draw_center(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha)
{
/* Cut lines changes into seperate strings, needed to support centering text
with break lines.
{
temp[text.copy(temp, text.size() - i, i)] = '\0';
draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y),
- drawing_effect);
+ drawing_effect, alpha);
break;
}
temp[text.copy(temp, l - i, i)] = '\0';
draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y),
- drawing_effect);
+ drawing_effect, alpha);
i = l+1;
y += h + 2;
void
Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos,
- Uint32 drawing_effect)
+ Uint32 drawing_effect, int alpha)
{
SurfaceImpl* impl = pchars->impl;
int source_x = (index % 16) * w;
int source_y = (index / 16) * h;
- impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255, drawing_effect);
+ impl->draw_part(source_x, source_y, p.x, p.y, w, h, alpha, drawing_effect);
p.x += w;
}
}
friend class DrawingContext;
void draw(const std::string& text, const Vector& pos,
- Uint32 drawing_effect = NONE_EFFECT);
+ Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
void draw_center(const std::string& text, const Vector& pos,
- Uint32 drawing_effect = NONE_EFFECT);
+ Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
void draw_chars(Surface* pchars, const std::string& text,
- const Vector& position, Uint32 drawing_effect);
+ const Vector& position, Uint32 drawing_effect, int alpha);
Surface* chars;
Surface* shadow_chars;