From: Holger Schemel Date: Sun, 20 Aug 2023 11:31:23 +0000 (+0200) Subject: added setting global animation position from CE triggering that animation X-Git-Tag: 4.3.7.0~30 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=dbba72fb511aee11057e6db5d0e9a4d53c9a0ddc;p=rocksndiamonds.git added setting global animation position from CE triggering that animation --- diff --git a/src/anim.c b/src/anim.c index d570be06..219c79fd 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1360,7 +1360,8 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, } } -static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page) +static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page, + int x, int y) { struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[GAME_MODE_PLAYING]; @@ -1383,6 +1384,14 @@ static void InitGlobalAnim_Triggered_ByCustomElement(int nr, int page) if (isClickablePart(part2, mask)) { + struct GraphicInfo *c = &part2->control_info; + + if (c->position == POS_CE) + { + part2->x = c->x + x; + part2->y = c->y + y; + } + part2->triggered = TRUE; #if 0 @@ -2148,11 +2157,12 @@ int getGlobalAnimSyncFrame(void) return anim_sync_frame; } -void HandleGlobalAnimEventByElementChange(int element, int page) +void HandleGlobalAnimEventByElementChange(int element, int page, int x, int y) { if (!IS_CUSTOM_ELEMENT(element)) return; // custom element stored as 0 to 255, change page stored as 1 to 32 - InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START, page + 1); + InitGlobalAnim_Triggered_ByCustomElement(element - EL_CUSTOM_START, page + 1, + x, y); } diff --git a/src/anim.h b/src/anim.h index 5224be13..0bde9a0b 100644 --- a/src/anim.h +++ b/src/anim.h @@ -22,7 +22,7 @@ void DrawGlobalAnimations(int, int); void RestartGlobalAnimsByStatus(int); boolean HandleGlobalAnimClicks(int, int, int, boolean); -void HandleGlobalAnimEventByElementChange(int, int); +void HandleGlobalAnimEventByElementChange(int, int, int, int); int getGlobalAnimSyncFrame(void); diff --git a/src/files.c b/src/files.c index 13141d7f..77fe2cdb 100644 --- a/src/files.c +++ b/src/files.c @@ -11829,6 +11829,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) strEqual(value, "lower") ? POS_LOWER : strEqual(value, "bottom") ? POS_BOTTOM : strEqual(value, "any") ? POS_ANY : + strEqual(value, "ce") ? POS_CE : strEqual(value, "last") ? POS_LAST : POS_UNDEFINED); } else if (strEqual(suffix, ".align")) diff --git a/src/game.c b/src/game.c index 299fd72b..8cabb12d 100644 --- a/src/game.c +++ b/src/game.c @@ -10716,7 +10716,14 @@ static boolean ChangeElement(int x, int y, int element, int page) ChangeCount[x][y]++; // count number of changes in the same frame if (ei->has_anim_event) - HandleGlobalAnimEventByElementChange(element, page); + { + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); + int sx = FX + SCREENX(x) * TILEX_VAR; + int sy = FY + SCREENY(y) * TILEY_VAR; + + HandleGlobalAnimEventByElementChange(element, page, sx - fx, sy - fy); + } if (change->explode) { diff --git a/src/libgame/system.h b/src/libgame/system.h index e429d233..05f9f08a 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -478,7 +478,8 @@ #define POS_LOWER 5 #define POS_BOTTOM 6 #define POS_ANY 7 -#define POS_LAST 8 +#define POS_CE 8 +#define POS_LAST 9 // values for text alignment #define ALIGN_LEFT (1 << 0)