added support for menu list entry size for game elements info screen
authorHolger Schemel <info@artsoft.org>
Sun, 26 Mar 2023 14:41:24 +0000 (16:41 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 26 Mar 2023 14:50:00 +0000 (16:50 +0200)
This commit adds support for using the following three graphics
configuration options to customize the available size (height),
spacing between lines of text and spacing between list entries
for the list of game element graphics and descriptions on the
game elements info screen:

* menu.list_entry_size.INFO[ELEMENTS] - available height for text
* menu.line_spacing.INFO[ELEMENTS]    - space between lines of text
* menu.extra_spacing.INFO[ELEMENTS]   - space between list entries

src/conf_gfx.c
src/screens.c

index b246940475146e69a6372de525f29674459a5ff3..1b6ed53ec9a2538a417cfcf2c80df75bc9ce231e 100644 (file)
@@ -8175,7 +8175,7 @@ struct ConfigInfo image_config[] =
   { "menu.extra_spacing.SCOREINFO",            "2"                     },
   { "menu.extra_spacing.INFO",                 "2"                     },
   { "menu.extra_spacing.INFO[TITLE]",          "2"                     },
-  { "menu.extra_spacing.INFO[ELEMENTS]",       "2"                     },
+  { "menu.extra_spacing.INFO[ELEMENTS]",       "4"                     },
   { "menu.extra_spacing.INFO[MUSIC]",          "2"                     },
   { "menu.extra_spacing.INFO[CREDITS]",                "2"                     },
   { "menu.extra_spacing.INFO[PROGRAM]",                "2"                     },
index 1365e7371cf195c6483aac22caa75baf6b2f3451..dee3b79cd4dcc3e8662416489131cdfbcd9e5bf6 100644 (file)
 #define MENU_SCREEN_INFO_SPACE_RIGHT   (menu.right_spacing_info[info_mode])
 #define MENU_SCREEN_INFO_SPACE_TOP     (menu.top_spacing_info[info_mode])
 #define MENU_SCREEN_INFO_SPACE_BOTTOM  (menu.bottom_spacing_info[info_mode])
+#define MENU_SCREEN_INFO_SPACE_LINE    (menu.line_spacing_info[info_mode])
+#define MENU_SCREEN_INFO_SPACE_EXTRA   (menu.extra_spacing_info[info_mode])
+#define MENU_SCREEN_INFO_ENTRY_SIZE_RAW        (menu.list_entry_size_info[info_mode])
+#define MENU_SCREEN_INFO_ENTRY_SIZE    (MAX(MENU_SCREEN_INFO_ENTRY_SIZE_RAW, \
+                                            TILEY))
 #define MENU_SCREEN_INFO_YSTART                MENU_SCREEN_INFO_SPACE_TOP
-#define MENU_SCREEN_INFO_YSTEP         (TILEY + 4)
+#define MENU_SCREEN_INFO_YSTEP         (MENU_SCREEN_INFO_ENTRY_SIZE + \
+                                        MENU_SCREEN_INFO_SPACE_EXTRA)
 #define MENU_SCREEN_INFO_YBOTTOM       (SYSIZE - MENU_SCREEN_INFO_SPACE_BOTTOM)
 #define MENU_SCREEN_INFO_YSIZE         (MENU_SCREEN_INFO_YBOTTOM -     \
                                         MENU_SCREEN_INFO_YSTART -      \
@@ -3113,6 +3119,8 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
   int ystart = mSY + MENU_SCREEN_INFO_YSTART + getHeadlineSpacing();
   int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
   int ystep = MENU_SCREEN_INFO_YSTEP;
+  int row_height = MENU_SCREEN_INFO_ENTRY_SIZE;
+  int yoffset = (row_height - TILEY) / 2;
   int element, action, direction;
   int graphic;
   int delay;
@@ -3147,6 +3155,7 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
     }
 
     int ypos = i - start;
+    int ystart_pos = ystart + ypos * ystep + yoffset;
 
     j += infoscreen_step[ypos];
 
@@ -3197,9 +3206,8 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
 
     j++;
 
-    ClearRectangleOnBackground(drawto, xstart, ystart + ypos * ystep,
-                              TILEX, TILEY);
-    DrawFixedGraphicAnimationExt(drawto, xstart, ystart + ypos * ystep,
+    ClearRectangleOnBackground(drawto, xstart, ystart_pos, TILEX, TILEY);
+    DrawFixedGraphicAnimationExt(drawto, xstart, ystart_pos,
                                 graphic, sync_frame, USE_MASKING);
 
     if (init)
@@ -3233,15 +3241,20 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
   int font_nr = FONT_INFO_ELEMENTS;
   int font_width = getFontWidth(font_nr);
   int font_height = getFontHeight(font_nr);
-  int yoffset = (TILEX - 2 * font_height) / 2;
+  int line_spacing = MENU_SCREEN_INFO_SPACE_LINE;
+  int line_height = font_height + line_spacing;
+  int row_height = MENU_SCREEN_INFO_ENTRY_SIZE;
   int xstart = mSX + MENU_SCREEN_INFO_SPACE_LEFT + TILEX + MINI_TILEX;
-  int ystart = mSY + MENU_SCREEN_INFO_YSTART + yoffset + getHeadlineSpacing();
-  int ystep = TILEY + 4;
+  int ystart = mSY + MENU_SCREEN_INFO_YSTART + getHeadlineSpacing();
+  int ystep = MENU_SCREEN_INFO_YSTEP;
   int pad_left = xstart - SX;
   int pad_right = MENU_SCREEN_INFO_SPACE_RIGHT;
   int max_chars_per_line = (SXSIZE - pad_left - pad_right) / font_width;
-  int max_lines_per_text = 2;    
+  int max_lines_per_text = (row_height + line_spacing) / line_height;
   char *text = NULL;
+  boolean autowrap = TRUE;
+  boolean centered = FALSE;
+  boolean parse_comments = FALSE;
 
   if (action != -1 && direction != -1)         // element.action.direction
     text = getHelpText(element, action, direction);
@@ -3258,12 +3271,22 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
   if (text == NULL)                            // not found
     text = "No description available";
 
-  if (strlen(text) <= max_chars_per_line)      // only one line of text
-    ystart += getFontHeight(font_nr) / 2;
+  DisableDrawingText();
+
+  // first get number of text lines to calculate offset for centering text
+  int num_lines_printed =
+    DrawTextBuffer(0, 0, text, font_nr,
+                  max_chars_per_line, -1, max_lines_per_text, line_spacing, -1,
+                  autowrap, centered, parse_comments);
 
-  DrawTextBuffer(xstart, ystart + ypos * ystep, text, font_nr,
-                max_chars_per_line, -1, max_lines_per_text, 0, -1,
-                TRUE, FALSE, FALSE);
+  EnableDrawingText();
+
+  int size_lines_printed = num_lines_printed * line_height - line_spacing;
+  int yoffset = (row_height - size_lines_printed) / 2;
+
+  DrawTextBuffer(xstart, ystart + ypos * ystep + yoffset, text, font_nr,
+                max_chars_per_line, -1, max_lines_per_text, line_spacing, -1,
+                autowrap, centered, parse_comments);
 }
 
 static void DrawInfoScreen_TitleScreen(void)