From 1264abe158bef8419451c95e6db9a738eeec76f8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 28 Oct 2006 13:44:10 +0200 Subject: [PATCH] rnd-20061028-1-src * fixed bug when displaying titlescreen with size less than element tile --- ChangeLog | 3 ++ src/conf_gfx.c | 22 ++++++------ src/conf_gfx.h | 48 +++++++++++++------------- src/conftime.h | 2 +- src/init.c | 84 ++++++++++++++++++++++++++++++++++++++++++---- src/libgame/text.c | 4 +++ src/main.h | 2 ++ src/screens.c | 47 +++++++++++++++----------- src/tools.c | 26 ++++++++++++-- src/tools.h | 2 ++ 10 files changed, 175 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17baa7ed..bd7464c9 100644 --- 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 diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 33a58e24..5f6583f9 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -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 */ diff --git a/src/conf_gfx.h b/src/conf_gfx.h index 33083cc2..0e919e37 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1563,30 +1563,30 @@ #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 diff --git a/src/conftime.h b/src/conftime.h index 8bb265d1..15feac76 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-10-24 19:53]" +#define COMPILE_DATE_STRING "[2006-10-28 13:41]" diff --git a/src/init.c b/src/init.c index 7f29f4bd..0ef4dc37 100644 --- a/src/init.c +++ b/src/init.c @@ -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:"); diff --git a/src/libgame/text.c b/src/libgame/text.c index 59c2ba3a..ccf32e70 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -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 diff --git a/src/main.h b/src/main.h index bc912050..70ea792a 100644 --- a/src/main.h +++ b/src/main.h @@ -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 */ diff --git a/src/screens.c b/src/screens.c index 6592b97f..0d297f6c 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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 */ diff --git a/src/tools.c b/src/tools.c index 32289597..ddc8353b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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) !!! */ diff --git a/src/tools.h b/src/tools.h index ec72a611..1aab5d32 100644 --- a/src/tools.h +++ b/src/tools.h @@ -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(); -- 2.34.1