X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fvideo%2Fdrawing_context.h;h=7ef8de954c368e9c25fd1f5deec0d4fea87000be;hb=133d94d5b145f325c38c8c15c9ea561bfffb092d;hp=c52e40f759b52fe99f7037ad0587626fe24d522d;hpb=ca65a4babe2341f4c9b8952cfd516df8d74575e4;p=supertux.git diff --git a/lib/video/drawing_context.h b/lib/video/drawing_context.h index c52e40f75..7ef8de954 100644 --- a/lib/video/drawing_context.h +++ b/lib/video/drawing_context.h @@ -24,9 +24,9 @@ #include "SDL.h" -#include "../math/vector.h" -#include "../video/screen.h" -#include "../video/surface.h" +#include "math/vector.h" +#include "video/screen.h" +#include "video/surface.h" namespace SuperTux { @@ -67,10 +67,15 @@ namespace SuperTux 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 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, int alpha = 255); + 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. @@ -81,33 +86,41 @@ namespace SuperTux void do_drawing(); const Vector& get_translation() const - { - return transform.translation; - } + { return transform.translation; } + Uint32 get_drawing_effect() const + { return transform.drawing_effect; } + void set_translation(const Vector& newtranslation) - { - transform.translation = newtranslation; - } + { transform.translation = newtranslation; } void push_transform(); void pop_transform(); /// Apply that effect in the next draws (effects are listed on surface.h). void set_drawing_effect(int effect); + /// apply that zoom in the next draws */ + void set_zooming(float zoom); + /// apply that alpha in the next draws */ + void set_alpha(int alpha); private: class Transform - { - public: - Vector translation; // only translation for now... + { + public: + Vector translation; + Uint32 drawing_effect; + float zoom; + int alpha; - Vector apply(const Vector& v) const - { - return v - translation; - } + Transform() + : drawing_effect(NONE_EFFECT), zoom(1), alpha(255) + { } - int draw_effect; - }; + Vector apply(const Vector& v) const + { + return v - translation; + } + }; /// the transform stack std::vector transformstack; @@ -129,8 +142,7 @@ namespace SuperTux { Font* font; std::string text; - bool center; - int alpha; + int allignment; }; struct GradientRequest @@ -147,11 +159,13 @@ namespace SuperTux struct DrawingRequest { + RequestType type; + Vector pos; + int layer; Uint32 drawing_effect; - - RequestType type; - Vector pos; + float zoom; + int alpha; void* request_data;