fixed multi-line request text overlapping with request buttons
authorHolger Schemel <holger.schemel@virtion.de>
Mon, 30 Dec 2024 18:08:14 +0000 (19:08 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Mon, 30 Dec 2024 18:11:25 +0000 (19:11 +0100)
src/tools.c

index 7af966c98a40a644d52e3a3b014e81aeeef75c44..51f3e11b1745e8057cb4487a54b8eb2dad5b666c 100644 (file)
@@ -3229,6 +3229,21 @@ static void DrawEnvelopeRequestText(int sx, int sy, char *text)
 
     text_final = text_door_style;
   }
+  else if (strlen(text_final) * font_width > max_text_width)
+  {
+    // prevent multi-line request text overlapping with request buttons
+    max_text_height = menu.request.button.confirm.y - sy_offset;
+
+    struct WrappedTextInfo *wrapped_text =
+      GetWrappedTextBuffer(text_final, font_nr, -1, -1, -1,
+                           max_text_width, -1, max_text_height, line_spacing, mask_mode,
+                           menu.request.autowrap, menu.request.centered, FALSE);
+
+    if (wrapped_text != NULL && wrapped_text->total_height > wrapped_text->max_height)
+      use_narrow_font = TRUE;
+
+    FreeWrappedText(wrapped_text);
+  }
 
   if (use_narrow_font)
   {