From: Ricardo Cruz Date: Fri, 24 Sep 2004 18:13:27 +0000 (+0000) Subject: Added a function to draw text on center of screen for comodity. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c6c8b57b862c835acfcfa0ae6856fe7c2e5204fb;p=supertux.git Added a function to draw text on center of screen for comodity. SVN-Revision: 1968 --- diff --git a/lib/video/drawing_context.cpp b/lib/video/drawing_context.cpp index c7718c5f7..889b86377 100644 --- a/lib/video/drawing_context.cpp +++ b/lib/video/drawing_context.cpp @@ -104,6 +104,14 @@ DrawingContext::draw_text(Font* font, const std::string& text, } void +DrawingContext::draw_center_text(Font* font, const std::string& text, + const Vector& position, int layer, Uint32 drawing_effect) +{ +draw_text(font, text, Vector(position.x + screen->w/2, position.y), + CENTER_ALLIGN, layer, drawing_effect); +} + +void DrawingContext::draw_gradient(Color top, Color bottom, int layer) { DrawingRequest request; diff --git a/lib/video/drawing_context.h b/lib/video/drawing_context.h index 2d7b1ad58..6c7e7749d 100644 --- a/lib/video/drawing_context.h +++ b/lib/video/drawing_context.h @@ -69,6 +69,13 @@ namespace SuperTux void draw_text(Font* font, const std::string& text, const Vector& position, int allignment, int layer, Uint32 drawing_effect = NONE_EFFECT); + + /// Draws text on screen center (feed Vector.x with a 0). + /// This is the same as draw_text() with a screen->w/2 position and + /// allignment set to LEFT_ALLIGN + void draw_center_text(Font* font, const std::string& text, + const Vector& position, int layer, + Uint32 drawing_effect = NONE_EFFECT); /// Draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); /// Fills a rectangle.