added function to initialize wrapped text output without drawing
authorHolger Schemel <holger.schemel@virtion.de>
Mon, 14 Oct 2024 21:31:07 +0000 (23:31 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Mon, 14 Oct 2024 21:31:41 +0000 (23:31 +0200)
src/libgame/text.c
src/libgame/text.h

index d946f7721d2433f26d7f553bc3de59e5f2591edd..4fbd48eeb043e1df3b999a04e9dc2c894d8992c0 100644 (file)
@@ -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;
index 2beecb18e8acd9f24d69d744867d7e7a43e4940c..42c4fd67d0c45ac588248ad26f899cce735d1d63 100644 (file)
@@ -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 *);