rnd-20061028-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 28 Oct 2006 11:44:10 +0000 (13:44 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:53:32 +0000 (10:53 +0200)
* fixed bug when displaying titlescreen with size less than element tile

ChangeLog
src/conf_gfx.c
src/conf_gfx.h
src/conftime.h
src/init.c
src/libgame/text.c
src/main.h
src/screens.c
src/tools.c
src/tools.h

index 17baa7ed8f4c7f356f3033de5e37390ae9800415..bd7464c9e8d32a48cc9c816354426a4a614504cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006-10-28
+       * fixed bug when displaying titlescreen with size less than element tile
+
 2006-10-24
        * fixed bug that allowed making engine snapshots from the level editor
 
index 33a58e2469de410da1f0c41f48734cf30ef22760..5f6583f9383d7b0d070333740c997456038ea5b6 100644 (file)
@@ -4500,17 +4500,6 @@ struct ConfigInfo image_config[] =
   { "background.envelope_4.anim_mode",         "default"               },
   { "background.envelope_4.draw_masked",       "false"                 },
 
-  { "titlescreen_initial_1",                   UNDEFINED_FILENAME      },
-  { "titlescreen_initial_2",                   UNDEFINED_FILENAME      },
-  { "titlescreen_initial_3",                   UNDEFINED_FILENAME      },
-  { "titlescreen_initial_4",                   UNDEFINED_FILENAME      },
-  { "titlescreen_initial_5",                   UNDEFINED_FILENAME      },
-  { "titlescreen_1",                           UNDEFINED_FILENAME      },
-  { "titlescreen_2",                           UNDEFINED_FILENAME      },
-  { "titlescreen_3",                           UNDEFINED_FILENAME      },
-  { "titlescreen_4",                           UNDEFINED_FILENAME      },
-  { "titlescreen_5",                           UNDEFINED_FILENAME      },
-
   { "background",                              UNDEFINED_FILENAME      },
   { "background.TITLE",                                UNDEFINED_FILENAME      },
   { "background.MAIN",                         UNDEFINED_FILENAME      },
@@ -4526,6 +4515,17 @@ struct ConfigInfo image_config[] =
   { "background.SETUP",                                UNDEFINED_FILENAME      },
   { "background.DOOR",                         UNDEFINED_FILENAME      },
 
+  { "titlescreen_initial_1",                   UNDEFINED_FILENAME      },
+  { "titlescreen_initial_2",                   UNDEFINED_FILENAME      },
+  { "titlescreen_initial_3",                   UNDEFINED_FILENAME      },
+  { "titlescreen_initial_4",                   UNDEFINED_FILENAME      },
+  { "titlescreen_initial_5",                   UNDEFINED_FILENAME      },
+  { "titlescreen_1",                           UNDEFINED_FILENAME      },
+  { "titlescreen_2",                           UNDEFINED_FILENAME      },
+  { "titlescreen_3",                           UNDEFINED_FILENAME      },
+  { "titlescreen_4",                           UNDEFINED_FILENAME      },
+  { "titlescreen_5",                           UNDEFINED_FILENAME      },
+
   /* the following directives are not associated with an image, but
      probably make sense to be defined in "graphicsinfo.conf", too */
 
index 33083cc2a156435542d6d036e9f57f6f8ecdad92..0e919e37aef5a45faf6b0db357426035f8a9af9b 100644 (file)
 #define IMG_BACKGROUND_ENVELOPE_2                      1542
 #define IMG_BACKGROUND_ENVELOPE_3                      1543
 #define IMG_BACKGROUND_ENVELOPE_4                      1544
-#define IMG_TITLESCREEN_INITIAL_1                      1545
-#define IMG_TITLESCREEN_INITIAL_2                      1546
-#define IMG_TITLESCREEN_INITIAL_3                      1547
-#define IMG_TITLESCREEN_INITIAL_4                      1548
-#define IMG_TITLESCREEN_INITIAL_5                      1549
-#define IMG_TITLESCREEN_1                              1550
-#define IMG_TITLESCREEN_2                              1551
-#define IMG_TITLESCREEN_3                              1552
-#define IMG_TITLESCREEN_4                              1553
-#define IMG_TITLESCREEN_5                              1554
-#define IMG_BACKGROUND                                 1555
-#define IMG_BACKGROUND_TITLE                           1556
-#define IMG_BACKGROUND_MAIN                            1557
-#define IMG_BACKGROUND_LEVELS                          1558
-#define IMG_BACKGROUND_SCORES                          1559
-#define IMG_BACKGROUND_EDITOR                          1560
-#define IMG_BACKGROUND_INFO                            1561
-#define IMG_BACKGROUND_INFO_ELEMENTS                   1562
-#define IMG_BACKGROUND_INFO_MUSIC                      1563
-#define IMG_BACKGROUND_INFO_CREDITS                    1564
-#define IMG_BACKGROUND_INFO_PROGRAM                    1565
-#define IMG_BACKGROUND_INFO_LEVELSET                   1566
-#define IMG_BACKGROUND_SETUP                           1567
-#define IMG_BACKGROUND_DOOR                            1568
+#define IMG_BACKGROUND                                 1545
+#define IMG_BACKGROUND_TITLE                           1546
+#define IMG_BACKGROUND_MAIN                            1547
+#define IMG_BACKGROUND_LEVELS                          1548
+#define IMG_BACKGROUND_SCORES                          1549
+#define IMG_BACKGROUND_EDITOR                          1550
+#define IMG_BACKGROUND_INFO                            1551
+#define IMG_BACKGROUND_INFO_ELEMENTS                   1552
+#define IMG_BACKGROUND_INFO_MUSIC                      1553
+#define IMG_BACKGROUND_INFO_CREDITS                    1554
+#define IMG_BACKGROUND_INFO_PROGRAM                    1555
+#define IMG_BACKGROUND_INFO_LEVELSET                   1556
+#define IMG_BACKGROUND_SETUP                           1557
+#define IMG_BACKGROUND_DOOR                            1558
+#define IMG_TITLESCREEN_INITIAL_1                      1559
+#define IMG_TITLESCREEN_INITIAL_2                      1560
+#define IMG_TITLESCREEN_INITIAL_3                      1561
+#define IMG_TITLESCREEN_INITIAL_4                      1562
+#define IMG_TITLESCREEN_INITIAL_5                      1563
+#define IMG_TITLESCREEN_1                              1564
+#define IMG_TITLESCREEN_2                              1565
+#define IMG_TITLESCREEN_3                              1566
+#define IMG_TITLESCREEN_4                              1567
+#define IMG_TITLESCREEN_5                              1568
 
 #define NUM_IMAGE_FILES                                        1569
 
index 8bb265d1e6b4ffe7008ac9ddab341149cef79071..15feac7601b8d17eb10c0fbdf5ffcb442304bde3 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-10-24 19:53]"
+#define COMPILE_DATE_STRING "[2006-10-28 13:41]"
index 7f29f4bd1f998ae03ecf1f600df506deba879230..0ef4dc379c009b2a7d13122b488306f1faf12399 100644 (file)
@@ -949,13 +949,13 @@ static void set_graphic_parameters(int graphic)
 
   graphic_info[graphic].bitmap = src_bitmap;
 
-  /* start with reliable default values */
+  /* always start with reliable default values */
   graphic_info[graphic].src_image_width = 0;
   graphic_info[graphic].src_image_height = 0;
   graphic_info[graphic].src_x = 0;
   graphic_info[graphic].src_y = 0;
-  graphic_info[graphic].width = TILEX;
-  graphic_info[graphic].height = TILEY;
+  graphic_info[graphic].width  = TILEX;        /* default for element graphics */
+  graphic_info[graphic].height = TILEY;        /* default for element graphics */
   graphic_info[graphic].offset_x = 0;  /* one or both of these values ... */
   graphic_info[graphic].offset_y = 0;  /* ... will be corrected later */
   graphic_info[graphic].offset2_x = 0; /* one or both of these values ... */
@@ -974,6 +974,15 @@ static void set_graphic_parameters(int graphic)
   graphic_info[graphic].post_delay = -1;
   graphic_info[graphic].auto_delay = -1;
 
+#if 1
+  if (graphic_info[graphic].use_image_size)
+  {
+    /* set default bitmap size (with scaling, but without small images) */
+    graphic_info[graphic].width  = get_scaled_graphic_width(graphic);
+    graphic_info[graphic].height = get_scaled_graphic_height(graphic);
+  }
+#endif
+
   /* optional x and y tile position of animation frame sequence */
   if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE)
     graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
@@ -1201,10 +1210,60 @@ static void InitGraphicInfo()
   GC copy_clipmask_gc = None;
 #endif
 
+  /* use image size as default values for width and height for these images */
+  static int full_size_graphics[] =
+  {
+    IMG_GLOBAL_BORDER,
+    IMG_GLOBAL_DOOR,
+
+    IMG_BACKGROUND_ENVELOPE_1,
+    IMG_BACKGROUND_ENVELOPE_2,
+    IMG_BACKGROUND_ENVELOPE_3,
+    IMG_BACKGROUND_ENVELOPE_4,
+
+    IMG_BACKGROUND,
+    IMG_BACKGROUND_TITLE,
+    IMG_BACKGROUND_MAIN,
+    IMG_BACKGROUND_LEVELS,
+    IMG_BACKGROUND_SCORES,
+    IMG_BACKGROUND_EDITOR,
+    IMG_BACKGROUND_INFO,
+    IMG_BACKGROUND_INFO_ELEMENTS,
+    IMG_BACKGROUND_INFO_MUSIC,
+    IMG_BACKGROUND_INFO_CREDITS,
+    IMG_BACKGROUND_INFO_PROGRAM,
+    IMG_BACKGROUND_INFO_LEVELSET,
+    IMG_BACKGROUND_SETUP,
+    IMG_BACKGROUND_DOOR,
+
+    IMG_TITLESCREEN_INITIAL_1,
+    IMG_TITLESCREEN_INITIAL_2,
+    IMG_TITLESCREEN_INITIAL_3,
+    IMG_TITLESCREEN_INITIAL_4,
+    IMG_TITLESCREEN_INITIAL_5,
+    IMG_TITLESCREEN_1,
+    IMG_TITLESCREEN_2,
+    IMG_TITLESCREEN_3,
+    IMG_TITLESCREEN_4,
+    IMG_TITLESCREEN_5,
+
+    -1
+  };
+
   checked_free(graphic_info);
 
   graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
 
+#if 1
+  /* initialize "use_image_size" flag with default value */
+  for (i = 0; i < num_images; i++)
+    graphic_info[i].use_image_size = FALSE;
+
+  /* initialize "use_image_size" flag from static configuration above */
+  for (i = 0; full_size_graphics[i] != -1; i++)
+    graphic_info[full_size_graphics[i]].use_image_size = TRUE;
+#endif
+
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   if (clipmasks_initialized)
   {
@@ -1234,6 +1293,7 @@ static void InitGraphicInfo()
   {
     Bitmap *src_bitmap;
     int src_x, src_y;
+    int width, height;
     int first_frame, last_frame;
     int src_bitmap_width, src_bitmap_height;
 
@@ -1242,6 +1302,10 @@ static void InitGraphicInfo()
     if (graphic_info[i].bitmap == NULL)
       continue;                /* skip check for optional images that are undefined */
 
+    /* get image size (this can differ from the standard element tile size!) */
+    width  = graphic_info[i].width;
+    height = graphic_info[i].height;
+
     /* get final bitmap size (with scaling, but without small images) */
     src_bitmap_width  = graphic_info[i].src_image_width;
     src_bitmap_height = graphic_info[i].src_image_height;
@@ -1251,9 +1315,15 @@ static void InitGraphicInfo()
     first_frame = 0;
     getGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
 
+#if 1
+    /* this avoids calculating wrong start position for out-of-bounds frame */
+    src_x = graphic_info[i].src_x;
+    src_y = graphic_info[i].src_y;
+#endif
+
     if (src_x < 0 || src_y < 0 ||
-       src_x + TILEX > src_bitmap_width ||
-       src_y + TILEY > src_bitmap_height)
+       src_x + width  > src_bitmap_width ||
+       src_y + height > src_bitmap_height)
     {
       Error(ERR_RETURN_LINE, "-");
       Error(ERR_RETURN, "warning: error found in config file:");
@@ -1280,8 +1350,8 @@ static void InitGraphicInfo()
     getGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
 
     if (src_x < 0 || src_y < 0 ||
-       src_x + TILEX > src_bitmap_width ||
-       src_y + TILEY > src_bitmap_height)
+       src_x + width  > src_bitmap_width ||
+       src_y + height > src_bitmap_height)
     {
       Error(ERR_RETURN_LINE, "-");
       Error(ERR_RETURN, "warning: error found in config file:");
index 59c2ba3a6e9fa585e11d2ae7dcb2a64393314dc9..ccf32e700bbd070d6d753cad2a7d9599db773427 100644 (file)
@@ -270,8 +270,12 @@ void DrawText(int x, int y, char *text, int font_nr)
 void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text,
                 int font_nr, int mask_mode)
 {
+#if 1
+  struct FontBitmapInfo *font = getFontBitmapInfo(font_nr);
+#else
   int font_bitmap_id = gfx.select_font_function(font_nr);
   struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id];
+#endif
   int font_width = getFontWidth(font_nr);
   int font_height = getFontHeight(font_nr);
 #if 0
index bc912050179cd9779b82ee5239f30e7eeb7f0a15..70ea792a9844e53ad0bd9507eb9883f57b4b8ec8 100644 (file)
@@ -2363,6 +2363,8 @@ struct GraphicInfo
   int post_delay;              /* optional setting for drawing title screens */
   int auto_delay;              /* optional setting for drawing title screens */
 
+  boolean use_image_size;      /* use image size as default width and height */
+
 #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   Pixmap clip_mask;            /* single-graphic-only clip mask for X11 */
   GC clip_gc;                  /* single-graphic-only clip gc for X11 */
index 6592b97f4feec60c9e7b0afb76c65b02ad53f31e..0d297f6cecff9908e02f6c95047ab8b3d71bd76a 100644 (file)
@@ -488,31 +488,32 @@ static void DrawCursorAndText_Main(int nr, boolean active)
 
       if (pos_button != NULL)
       {
-       int button_x = mSX + pos_button->x;
-       int button_y = mSY + pos_button->y;
+       struct MenuPosInfo *pos = pos_button;
+       int x = mSX + pos->x;
+       int y = mSY + pos->y;
 
-       DrawBackground(button_x,button_y, pos_button->width,pos_button->height);
-       DrawGraphicThruMaskExt(drawto, button_x, button_y, button_graphic, 0);
+       DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
+       DrawGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
       }
 
       if (pos_text != NULL && text != NULL)
       {
-       int text_x = mSX + ALIGNED_XPOS(pos_text->x, pos_text->width,
-                                       pos_text->align);
-       int text_y = mSY + pos_text->y;
+       struct MenuPosInfo *pos = pos_text;
+       int x = mSX + ALIGNED_XPOS(pos->x, pos->width, pos->align);
+       int y = mSY + pos->y;
 
-       DrawBackground(text_x, text_y, pos_text->width, pos_text->height);
-       DrawText(text_x, text_y, text, font_text);
+       DrawBackgroundForFont(x, y, pos->width, pos->height, font_text);
+       DrawText(x, y, text, font_text);
       }
 
       if (pos_input != NULL && input != NULL)
       {
-       int input_x = mSX + ALIGNED_XPOS(pos_input->x, pos_input->width,
-                                        pos_input->align);
-       int input_y = mSY + pos_input->y;
+       struct MenuPosInfo *pos = pos_input;
+       int x = mSX + ALIGNED_XPOS(pos->x, pos->width, pos->align);
+       int y = mSY + pos->y;
 
-       DrawBackground(input_x, input_y, pos_input->width, pos_input->height);
-       DrawText(input_x, input_y, input, font_input);
+       DrawBackgroundForFont(x, y, pos->width, pos->height, font_input);
+       DrawText(x, y, input, font_input);
       }
     }
   }
@@ -558,7 +559,7 @@ static void drawCursorExt(int xpos, int ypos, boolean active, int graphic)
   if (active)
     graphic = BUTTON_GRAPHIC_ACTIVE(graphic);
 
-  DrawBackground(x, y, TILEX, TILEY);
+  DrawBackgroundForGraphic(x, y, TILEX, TILEY, graphic);
   DrawGraphicThruMaskExt(drawto, x, y, graphic, 0);
 }
 
@@ -627,9 +628,16 @@ void DrawTitleScreenImage(int nr)
 {
   int graphic = getTitleScreenGraphic() + nr;
   Bitmap *bitmap = graphic_info[graphic].bitmap;
+#if 1
+  int width  = graphic_info[graphic].width;
+  int height = graphic_info[graphic].height;
+  int src_x = graphic_info[graphic].src_x;
+  int src_y = graphic_info[graphic].src_y;
+#else
   int width  = graphic_info[graphic].src_image_width;
   int height = graphic_info[graphic].src_image_height;
   int src_x = 0, src_y = 0;
+#endif
   int dst_x, dst_y;
 
   if (bitmap == NULL)
@@ -2600,6 +2608,7 @@ static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
   TreeInfo *node, *node_first;
   int x, last_redraw_mask = redraw_mask;
   int ypos = MENU_TITLE2_YPOS;
+  int font_nr = FONT_TITLE_2;
 
   if (ti->type != TREE_TYPE_LEVEL_DIR)
     return;
@@ -2607,16 +2616,16 @@ static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
   node_first = getTreeInfoFirstGroupEntry(ti);
   node = getTreeInfoFromPos(node_first, entry_pos);
 
-  DrawBackground(SX, SY + ypos, SXSIZE, getFontHeight(FONT_TITLE_2));
+  DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
 
   if (node->parent_link)
-    DrawTextFCentered(ypos, FONT_TITLE_2, "leave group \"%s\"",
+    DrawTextFCentered(ypos, font_nr, "leave group \"%s\"",
                      node->class_desc);
   else if (node->level_group)
-    DrawTextFCentered(ypos, FONT_TITLE_2, "enter group \"%s\"",
+    DrawTextFCentered(ypos, font_nr, "enter group \"%s\"",
                      node->class_desc);
   else if (ti->type == TREE_TYPE_LEVEL_DIR)
-    DrawTextFCentered(ypos, FONT_TITLE_2, "%3d levels (%s)",
+    DrawTextFCentered(ypos, font_nr, "%3d levels (%s)",
                      node->levels, node->class_desc);
 
   /* let BackToFront() redraw only what is needed */
index 3228959755cc0ea844df4885eb485e2e62e244c8..ddc8353b5c9da4a33b9d0caa3d3911f3690ac87d 100644 (file)
@@ -627,19 +627,39 @@ void SetPanelBackground()
   SetDoorBackgroundBitmap(bitmap_db_panel);
 }
 
-void DrawBackground(int dst_x, int dst_y, int width, int height)
+void DrawBackground(int x, int y, int width, int height)
 {
   /* !!! "drawto" might still point to playfield buffer here (see below) !!! */
   /* (when entering hall of fame after playing) */
 #if 0
-  ClearRectangleOnBackground(drawto, dst_x, dst_y, width, height);
+  ClearRectangleOnBackground(drawto, x, y, width, height);
 #else
-  ClearRectangleOnBackground(backbuffer, dst_x, dst_y, width, height);
+  ClearRectangleOnBackground(backbuffer, x, y, width, height);
 #endif
 
   redraw_mask |= REDRAW_FIELD;
 }
 
+void DrawBackgroundForFont(int x, int y, int width, int height, int font_nr)
+{
+  struct FontBitmapInfo *font = getFontBitmapInfo(font_nr);
+
+  if (font->bitmap == NULL)
+    return;
+
+  DrawBackground(x, y, width, height);
+}
+
+void DrawBackgroundForGraphic(int x, int y, int width, int height, int graphic)
+{
+  struct GraphicInfo *g = &graphic_info[graphic];
+
+  if (g->bitmap == NULL)
+    return;
+
+  DrawBackground(x, y, width, height);
+}
+
 void ClearWindow()
 {
   /* !!! "drawto" might still point to playfield buffer here (see above) !!! */
index ec72a61107b451a0f858b1d35f778429013542fa..1aab5d3244ae971678b1c35b0ee3fee3b5866d65 100644 (file)
@@ -85,6 +85,8 @@ void SetMainBackgroundImage(int);
 void SetDoorBackgroundImage(int);
 void SetPanelBackground();
 void DrawBackground(int, int, int, int);
+void DrawBackgroundForFont(int, int, int, int, int);
+void DrawBackgroundForGraphic(int, int, int, int, int);
 
 void MarkTileDirty(int, int);
 void SetBorderElement();