From 3ab83dfed59fddd35d5b6f1f62b09a79b0939338 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 14 Oct 2024 23:31:07 +0200 Subject: [PATCH] added function to initialize wrapped text output without drawing --- src/libgame/text.c | 20 ++++++++++++++++---- src/libgame/text.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libgame/text.c b/src/libgame/text.c index d946f772..4fbd48ee 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -756,7 +756,8 @@ struct WrappedTextInfo *GetWrappedTextFile(char *filename, int font_nr, return wrapped_text; } -int DrawWrappedText(int x, int y, struct WrappedTextInfo *wrapped_text, int start_pos) +static int DrawWrappedTextExt(int x, int y, struct WrappedTextInfo *wrapped_text, int start_pos, + boolean init_only) { int current_line = 0; int current_ypos = 0; @@ -780,9 +781,10 @@ int DrawWrappedText(int x, int y, struct WrappedTextInfo *wrapped_text, int star if (current_ypos + font_height > wrapped_text->max_height) break; - DrawTextBuffer_Flush(x, y, wrapped_text->line[i].text, font_nr, line_length, - wrapped_text->cut_length, wrapped_text->mask_mode, - wrapped_text->line[i].centered, current_ypos); + if (!init_only) + DrawTextBuffer_Flush(x, y, wrapped_text->line[i].text, font_nr, line_length, + wrapped_text->cut_length, wrapped_text->mask_mode, + wrapped_text->line[i].centered, current_ypos); current_ypos += line_height; current_line++; @@ -793,6 +795,16 @@ int DrawWrappedText(int x, int y, struct WrappedTextInfo *wrapped_text, int star return current_line; } +int InitWrappedText(int x, int y, struct WrappedTextInfo *wrapped_text, int start_pos) +{ + return DrawWrappedTextExt(x, y, wrapped_text, start_pos, TRUE); +} + +int DrawWrappedText(int x, int y, struct WrappedTextInfo *wrapped_text, int start_pos) +{ + return DrawWrappedTextExt(x, y, wrapped_text, start_pos, FALSE); +} + void FreeWrappedText(struct WrappedTextInfo *wrapped_text) { int i; diff --git a/src/libgame/text.h b/src/libgame/text.h index 2beecb18..42c4fd67 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -156,6 +156,7 @@ struct WrappedTextInfo *GetWrappedTextBuffer(char *, int, int, int, int, int, in boolean, boolean, boolean); struct WrappedTextInfo *GetWrappedTextFile(char *, int, int, int, int, int, int, int, int, int, boolean, boolean, boolean); +int InitWrappedText(int, int, struct WrappedTextInfo *, int); int DrawWrappedText(int, int, struct WrappedTextInfo *, int); void FreeWrappedText(struct WrappedTextInfo *); -- 2.34.1