X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Ftext.c;h=9e9556095fbd9dddd8b09534b2c007543044a732;hb=fd2761fde6102017cd3be6b59c3be9140f96f703;hp=6b5f03e0e521529b36f5f9b088342cd3cb029459;hpb=c781e660ed2fe6ad36c9eee0a77d64ee07163030;p=rocksndiamonds.git diff --git a/src/libgame/text.c b/src/libgame/text.c index 6b5f03e0..9e955609 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -191,7 +191,7 @@ void DrawInitText(char *text, int ypos, int font_nr) } } -void DrawTextFCentered(int y, int font_nr, char *format, ...) +void DrawTextF(int x, int y, int font_nr, char *format, ...) { char buffer[MAX_OUTPUT_LINESIZE + 1]; va_list ap; @@ -201,13 +201,12 @@ void DrawTextFCentered(int y, int font_nr, char *format, ...) va_end(ap); if (strlen(buffer) > MAX_OUTPUT_LINESIZE) - Error(ERR_EXIT, "string too long in DrawTextFCentered() -- aborting"); + Error(ERR_EXIT, "string too long in DrawTextF() -- aborting"); - DrawText(gfx.sx + (gfx.sxsize - getTextWidth(buffer, font_nr)) / 2, - gfx.sy + y, buffer, font_nr); + DrawText(gfx.sx + x, gfx.sy + y, buffer, font_nr); } -void DrawTextF(int x, int y, int font_nr, char *format, ...) +void DrawTextFCentered(int y, int font_nr, char *format, ...) { char buffer[MAX_OUTPUT_LINESIZE + 1]; va_list ap; @@ -217,9 +216,21 @@ void DrawTextF(int x, int y, int font_nr, char *format, ...) va_end(ap); if (strlen(buffer) > MAX_OUTPUT_LINESIZE) - Error(ERR_EXIT, "string too long in DrawTextF() -- aborting"); + Error(ERR_EXIT, "string too long in DrawTextFCentered() -- aborting"); - DrawText(gfx.sx + x, gfx.sy + y, buffer, font_nr); + DrawText(gfx.sx + (gfx.sxsize - getTextWidth(buffer, font_nr)) / 2, + gfx.sy + y, buffer, font_nr); +} + +void DrawTextS(int x, int y, int font_nr, char *text) +{ + DrawText(gfx.sx + x, gfx.sy + y, text, font_nr); +} + +void DrawTextSCentered(int y, int font_nr, char *text) +{ + DrawText(gfx.sx + (gfx.sxsize - getTextWidth(text, font_nr)) / 2, + gfx.sy + y, text, font_nr); } void DrawText(int x, int y, char *text, int font_nr) @@ -326,8 +337,8 @@ void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, } } -void DrawTextToTextArea(int x, int y, char *text, int font_nr, - int area_xsize, int area_ysize) +void DrawTextToTextArea(int x, int y, char *text, int font_nr, int line_length, + int area_xsize, int area_ysize, int mask_mode) { int area_line = 0; int font_height = getFontHeight(font_nr); @@ -340,13 +351,16 @@ void DrawTextToTextArea(int x, int y, char *text, int font_nr, char buffer[MAX_OUTPUT_LINESIZE + 1]; int i; - for (i=0; i < area_xsize && *text; i++) + for (i=0; i < line_length && *text; i++) if ((buffer[i] = *text++) == '\n') break; - buffer[i] = '\0'; + buffer[MIN(i, area_xsize)] = '\0'; - DrawText(x, y + area_line * font_height, buffer, font_nr); + DrawTextExt(drawto, x, y + area_line * font_height, buffer, font_nr, + mask_mode); area_line++; } + + redraw_mask |= REDRAW_FIELD; }