[Super-tux-commit] supertux/lib/video drawing_context.cpp,1.4,1.5 drawing_context.h,1.5,1.6 font.cpp
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-09-15 18:47:56
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8936/lib/video Modified Files: drawing_context.cpp drawing_context.h font.cpp font.h Log Message: Added an alpha argument for drawing fonts. Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- font.cpp 29 Jul 2004 11:24:41 -0000 1.6 +++ font.cpp 15 Sep 2004 18:47:45 -0000 1.7 @@ -114,17 +114,17 @@ } 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. @@ -140,12 +140,12 @@ { 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; @@ -154,7 +154,7 @@ 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; @@ -179,7 +179,7 @@ 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; } } Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- drawing_context.cpp 28 Jul 2004 14:57:24 -0000 1.4 +++ drawing_context.cpp 15 Sep 2004 18:47:45 -0000 1.5 @@ -78,7 +78,7 @@ 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; @@ -91,6 +91,7 @@ textrequest->font = font; textrequest->text = text; textrequest->center = false; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -98,7 +99,7 @@ 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; @@ -111,6 +112,7 @@ textrequest->font = font; textrequest->text = text; textrequest->center = true; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -218,9 +220,9 @@ 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; } Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- drawing_context.h 28 Jul 2004 14:57:24 -0000 1.5 +++ drawing_context.h 15 Sep 2004 18:47:45 -0000 1.6 @@ -67,10 +67,10 @@ 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. @@ -130,6 +130,7 @@ Font* font; std::string text; bool center; + int alpha; }; struct GradientRequest Index: font.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- font.h 29 Jul 2004 11:24:41 -0000 1.7 +++ font.h 15 Sep 2004 18:47:45 -0000 1.8 @@ -64,11 +64,11 @@ 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; |