From fc9317d215c78cd3d3101e835b1dea1fe23f20c4 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Thu, 8 Sep 2016 01:42:48 +0200 Subject: [PATCH] add DrawWrappedTextWithShadow --- src/utils.c | 16 ++++++++++------ src/utils.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/utils.c b/src/utils.c index 2936259..b576922 100644 --- a/src/utils.c +++ b/src/utils.c @@ -47,11 +47,11 @@ SYMBOL_EXPORT void DrawHorizontalGradientRect(float x, float y, float w, float h } SYMBOL_EXPORT void DrawTextWithShadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text) { - al_draw_text(font, al_map_rgba(0,0,0,128), (int)x+1, (int)y+1, flags, text); - al_draw_text(font, color, (int)x, (int)y, flags, text); + al_draw_text(font, al_map_rgba(0,0,0,128), x+1, y+1, flags, text); + al_draw_text(font, color, x, y, flags, text); } -SYMBOL_EXPORT int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, int x1, int y1, int width, int flags, char const* text) { +SYMBOL_EXPORT int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const* text) { char stext[1024]; // Copy of the passed text. char *pch; // A pointer to each word. @@ -97,20 +97,24 @@ SYMBOL_EXPORT int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, int x for (int i = 0; i<=line; i+=1) { // Move through each line and draw according to the passed flags. switch (flags) { case ALLEGRO_ALIGN_CENTER: - al_draw_text(font, color, x1 + (width/2), y1 + (i * height), ALLEGRO_ALIGN_CENTER, lines[i]); + al_draw_text(font, color, x + (width/2), y + (i * height), ALLEGRO_ALIGN_CENTER, lines[i]); break; case ALLEGRO_ALIGN_RIGHT: - al_draw_text(font, color, x1 + width, y1 + (i * height), ALLEGRO_ALIGN_RIGHT, lines[i]); + al_draw_text(font, color, x + width, y + (i * height), ALLEGRO_ALIGN_RIGHT, lines[i]); break; case ALLEGRO_ALIGN_LEFT: default: - al_draw_text(font, color, x1, y1 + (i * height), ALLEGRO_ALIGN_LEFT, lines[i]); + al_draw_text(font, color, x, y + (i * height), ALLEGRO_ALIGN_LEFT, lines[i]); break; } } return ((line+1) * height); // Return the actual height of the text in pixels. } +SYMBOL_EXPORT int DrawWrappedTextWithShadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const *text) { + DrawWrappedText(font, al_map_rgba(0,0,0,128), x+1, y+1, width, flags, text); + return DrawWrappedText(font, color, x, y, width, flags, text); +} /* linear filtering code written by SiegeLord */ SYMBOL_EXPORT ALLEGRO_COLOR InterpolateColor(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) { diff --git a/src/utils.h b/src/utils.h index 1571a5d..829547d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -47,7 +47,8 @@ void DrawHorizontalGradientRect(float x, float y, float w, float h, ALLEGRO_COLO */ void DrawTextWithShadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text); -int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, int x1, int y1, int width, int flags, char const *text); +int DrawWrappedText(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const *text); +int DrawWrappedTextWithShadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int width, int flags, char const *text); /*! \brief Loads bitmap into memory and scales it with software linear filtering. */ ALLEGRO_BITMAP* LoadScaledBitmap(struct Game *game, char* filename, int width, int height);