X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fvideo%2Fdrawing_context.cpp;h=0019ff5429afbec9a49f618bf915a937e75616d9;hb=ca65a4babe2341f4c9b8952cfd516df8d74575e4;hp=846e38c556970947cff08b188207ab0395f3a201;hpb=9c511ea692d3a2339597211f08f18ea74fad35ec;p=supertux.git diff --git a/lib/video/drawing_context.cpp b/lib/video/drawing_context.cpp index 846e38c55..0019ff542 100644 --- a/lib/video/drawing_context.cpp +++ b/lib/video/drawing_context.cpp @@ -20,10 +20,12 @@ #include #include -#include "video/drawing_context.h" -#include "video/surface.h" -#include "app/globals.h" -#include "video/font.h" +#include "../video/drawing_context.h" +#include "../video/surface.h" +#include "../app/globals.h" +#include "../video/font.h" + +using namespace SuperTux; DrawingContext::DrawingContext() { @@ -76,7 +78,7 @@ DrawingContext::draw_surface_part(const Surface* surface, const Vector& source, 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; @@ -88,6 +90,8 @@ DrawingContext::draw_text(Font* font, const std::string& text, TextRequest* textrequest = new TextRequest; textrequest->font = font; textrequest->text = text; + textrequest->center = false; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -95,19 +99,20 @@ DrawingContext::draw_text(Font* font, const std::string& text, 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; request.type = TEXT; request.layer = layer; - request.pos = transform.apply(position) + Vector(screen->w/2 - - font->get_text_width(text)/2, 0); + request.pos = transform.apply(position); request.drawing_effect = drawing_effect; TextRequest* textrequest = new TextRequest; textrequest->font = font; textrequest->text = text; + textrequest->center = true; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -213,8 +218,11 @@ void DrawingContext::draw_text(DrawingRequest& request) { TextRequest* textrequest = (TextRequest*) request.request_data; - - textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect); + + if(textrequest->center) + 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->alpha); delete textrequest; }