From 4f1505e125379280d5e68a04ac780e746e6dfdf5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 8 Feb 2023 22:49:12 +0100 Subject: [PATCH] added support for stacked global animations This extension of global animations adds "stacked animations" that are created by "stacking" the same global animation multiple times, either horizontally, vertically, or both, with additional options to use some empty space between two adjacent stacked animations, as follows: global.anim_X.stacked_xfactor: global.anim_X.stacked_yfactor: global.anim_X.stacked_xoffset: global.anim_X.stacked_yoffset: This would stack global animation X times horizontally and times vertically, while adding empty space between stacked animations of pixels horizontally and vertically. --- src/anim.c | 29 +++++++++++++++++++++-------- src/conf_gfx.c | 4 ++++ src/init.c | 6 ++++++ src/main.h | 9 +++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/anim.c b/src/anim.c index 1fb0672e..9ac9d168 100644 --- a/src/anim.c +++ b/src/anim.c @@ -636,7 +636,9 @@ void InitGlobalAnimations(void) InitGlobalAnimControls(); } -static void BlitGlobalAnimation(struct GraphicInfo *g, Bitmap *src_bitmap, +static void BlitGlobalAnimation(struct GraphicInfo *g, + struct GraphicInfo *c, + Bitmap *src_bitmap, int src_x, int src_y, int width, int height, int dst_x, int dst_y, int drawing_target) { @@ -647,13 +649,23 @@ static void BlitGlobalAnimation(struct GraphicInfo *g, Bitmap *src_bitmap, Bitmap *fade_bitmap = (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source : drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL); + int x, y; - if (drawing_target == DRAW_TO_SCREEN) - blit_screen(src_bitmap, src_x, src_y, width, height, - dst_x, dst_y); - else - blit_bitmap(src_bitmap, fade_bitmap, src_x, src_y, width, height, - dst_x, dst_y); + for (y = 0; y < c->stacked_yfactor; y++) + { + for (x = 0; x < c->stacked_xfactor; x++) + { + int dst_x_final = dst_x + x * (g->width + c->stacked_xoffset); + int dst_y_final = dst_y + y * (g->height + c->stacked_yoffset); + + if (drawing_target == DRAW_TO_SCREEN) + blit_screen(src_bitmap, src_x, src_y, width, height, + dst_x_final, dst_y_final); + else + blit_bitmap(src_bitmap, fade_bitmap, src_x, src_y, width, height, + dst_x_final, dst_y_final); + } + } } static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) @@ -800,6 +812,7 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) { struct GlobalAnimPartControlInfo *part = &anim->part[part_nr]; struct GraphicInfo *g = &part->graphic_info; + struct GraphicInfo *c = &part->control_info; Bitmap *src_bitmap; int src_x, src_y; int width = g->width; @@ -864,7 +877,7 @@ static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage) src_x += cut_x; src_y += cut_y; - BlitGlobalAnimation(g, src_bitmap, src_x, src_y, width, height, + BlitGlobalAnimation(g, c, src_bitmap, src_x, src_y, width, height, dst_x, dst_y, drawing_target); } } diff --git a/src/conf_gfx.c b/src/conf_gfx.c index b168262d..fe2dd219 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -86,6 +86,10 @@ struct ConfigTypeInfo image_config_suffix[] = { ".active_yoffset", "0", TYPE_INTEGER }, { ".pressed_xoffset", "0", TYPE_INTEGER }, { ".pressed_yoffset", "0", TYPE_INTEGER }, + { ".stacked_xfactor", "1", TYPE_INTEGER }, + { ".stacked_yfactor", "1", TYPE_INTEGER }, + { ".stacked_xoffset", "0", TYPE_INTEGER }, + { ".stacked_yoffset", "0", TYPE_INTEGER }, { NULL, NULL, 0 } }; diff --git a/src/init.c b/src/init.c index 00b471ee..6cfba4e6 100644 --- a/src/init.c +++ b/src/init.c @@ -1691,6 +1691,12 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->active_yoffset = parameter[GFX_ARG_ACTIVE_YOFFSET]; g->pressed_xoffset = parameter[GFX_ARG_PRESSED_XOFFSET]; g->pressed_yoffset = parameter[GFX_ARG_PRESSED_YOFFSET]; + + // this is only used for drawing stacked global animations + g->stacked_xfactor = parameter[GFX_ARG_STACKED_XFACTOR]; + g->stacked_yfactor = parameter[GFX_ARG_STACKED_YFACTOR]; + g->stacked_xoffset = parameter[GFX_ARG_STACKED_XOFFSET]; + g->stacked_yoffset = parameter[GFX_ARG_STACKED_YOFFSET]; } static void set_graphic_parameters(int graphic) diff --git a/src/main.h b/src/main.h index 238a0774..618db1fb 100644 --- a/src/main.h +++ b/src/main.h @@ -2456,6 +2456,10 @@ enum GFX_ARG_ACTIVE_YOFFSET, GFX_ARG_PRESSED_XOFFSET, GFX_ARG_PRESSED_YOFFSET, + GFX_ARG_STACKED_XFACTOR, + GFX_ARG_STACKED_YFACTOR, + GFX_ARG_STACKED_XOFFSET, + GFX_ARG_STACKED_YOFFSET, NUM_GFX_ARGS }; @@ -3690,6 +3694,11 @@ struct GraphicInfo int pressed_xoffset; int pressed_yoffset; + int stacked_xfactor; + int stacked_yfactor; + int stacked_xoffset; + int stacked_yoffset; + boolean use_image_size; // use image size as default width and height }; -- 2.34.1