From: Holger Schemel Date: Wed, 26 Oct 2022 22:50:24 +0000 (+0200) Subject: added new animation mode ".global_anim_sync" for game element graphics X-Git-Tag: 4.3.3.0~33 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a7a3a417929449b5d1c32a5ef9e67693015d187b;p=rocksndiamonds.git added new animation mode ".global_anim_sync" for game element graphics While the existing animation mode ".global_sync" is used to sync game animations with the frame counter of the game just played, the new mode ".global_anim_sync" can be used to sync with the global animation frame counter, which makes it possible to sync with global animations that are always running during program execution (that is, in the menu and while playing a game, without interruption). --- diff --git a/src/anim.c b/src/anim.c index c4952d70..50075c83 100644 --- a/src/anim.c +++ b/src/anim.c @@ -1315,7 +1315,8 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, part->anim_event_state = (c->anim_event != ANIM_EVENT_UNDEFINED); part->initial_anim_sync_frame = - (g->anim_global_sync ? 0 : anim_sync_frame + part->init_delay_counter); + (g->anim_global_sync || g->anim_global_anim_sync ? 0 : + anim_sync_frame + part->init_delay_counter); // do not re-initialize random animation frame after fade-in if (part->anim_random_frame == -1) @@ -1982,3 +1983,8 @@ boolean HandleGlobalAnimClicks(int mx, int my, int button, boolean force_click) return click_consumed_current; } + +int getGlobalAnimSyncFrame(void) +{ + return anim_sync_frame; +} diff --git a/src/anim.h b/src/anim.h index 5c5b7895..3d0153c9 100644 --- a/src/anim.h +++ b/src/anim.h @@ -20,4 +20,6 @@ void DrawGlobalAnimations(int, int); boolean HandleGlobalAnimClicks(int, int, int, boolean); +int getGlobalAnimSyncFrame(void); + #endif diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 37a37395..829000da 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -41,6 +41,7 @@ struct ConfigTypeInfo image_config_suffix[] = { ".delay", "1", TYPE_INTEGER }, { ".anim_mode", ARG_UNDEFINED, TYPE_STRING }, { ".global_sync", "false", TYPE_BOOLEAN }, + { ".global_anim_sync", "false", TYPE_BOOLEAN }, { ".crumbled_like", ARG_UNDEFINED, TYPE_ELEMENT }, { ".diggable_like", ARG_UNDEFINED, TYPE_ELEMENT }, { ".border_size", ARG_UNDEFINED, TYPE_INTEGER }, diff --git a/src/game.c b/src/game.c index d3d7f513..178f35de 100644 --- a/src/game.c +++ b/src/game.c @@ -2566,7 +2566,9 @@ static void UpdateGameControlValues(void) int element = gpc->value; int graphic = el2panelimg(element); int init_gfx_random = (graphic_info[graphic].anim_global_sync ? - sync_random_frame : INIT_GFX_RANDOM()); + sync_random_frame : + graphic_info[graphic].anim_global_anim_sync ? + getGlobalAnimSyncFrame() : INIT_GFX_RANDOM()); if (gpc->value != gpc->last_value) { @@ -2601,7 +2603,9 @@ static void UpdateGameControlValues(void) int last_anim_random_frame = gfx.anim_random_frame; int graphic = gpc->graphic; int init_gfx_random = (graphic_info[graphic].anim_global_sync ? - sync_random_frame : INIT_GFX_RANDOM()); + sync_random_frame : + graphic_info[graphic].anim_global_anim_sync ? + getGlobalAnimSyncFrame() : INIT_GFX_RANDOM()); if (gpc->value != gpc->last_value) { @@ -5305,6 +5309,8 @@ static void ResetGfxFrame(int x, int y) if (graphic_info[graphic].anim_global_sync) GfxFrame[x][y] = FrameCounter; + else if (graphic_info[graphic].anim_global_anim_sync) + GfxFrame[x][y] = getGlobalAnimSyncFrame(); else if (ANIM_MODE(graphic) == ANIM_CE_VALUE) GfxFrame[x][y] = CustomValue[x][y]; else if (ANIM_MODE(graphic) == ANIM_CE_SCORE) diff --git a/src/init.c b/src/init.c index 547d629e..6fd4ae08 100644 --- a/src/init.c +++ b/src/init.c @@ -1561,6 +1561,9 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, // animation synchronized with global frame counter, not move position g->anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC]; + // animation synchronized with global anim frame counter, not move position + g->anim_global_anim_sync = parameter[GFX_ARG_GLOBAL_ANIM_SYNC]; + // optional element for cloning crumble graphics if (parameter[GFX_ARG_CRUMBLED_LIKE] != ARG_UNDEFINED_VALUE) g->crumbled_like = parameter[GFX_ARG_CRUMBLED_LIKE]; diff --git a/src/main.h b/src/main.h index fd70216d..1a77f8a9 100644 --- a/src/main.h +++ b/src/main.h @@ -2411,6 +2411,7 @@ enum GFX_ARG_DELAY, GFX_ARG_ANIM_MODE, GFX_ARG_GLOBAL_SYNC, + GFX_ARG_GLOBAL_ANIM_SYNC, GFX_ARG_CRUMBLED_LIKE, GFX_ARG_DIGGABLE_LIKE, GFX_ARG_BORDER_SIZE, @@ -3626,6 +3627,7 @@ struct GraphicInfo int anim_mode; boolean anim_global_sync; + boolean anim_global_anim_sync; int crumbled_like; // element for cloning crumble graphics int diggable_like; // element for cloning digging graphics diff --git a/src/tools.c b/src/tools.c index 9333f9f9..98e60731 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1492,6 +1492,8 @@ int getGraphicAnimationFrame(int graphic, int sync_frame) // animation synchronized with global frame counter, not move position if (graphic_info[graphic].anim_global_sync || sync_frame < 0) sync_frame = FrameCounter; + else if (graphic_info[graphic].anim_global_anim_sync) + sync_frame = getGlobalAnimSyncFrame(); return getAnimationFrame(graphic_info[graphic].anim_frames, graphic_info[graphic].anim_delay, @@ -8786,6 +8788,8 @@ void SetGfxAnimation_EM(struct GraphicInfo_EM *g_em, if (graphic_info[graphic].anim_global_sync) sync_frame = FrameCounter; + else if (graphic_info[graphic].anim_global_anim_sync) + sync_frame = getGlobalAnimSyncFrame(); else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY)) sync_frame = GfxFrame[x][y]; else @@ -8845,6 +8849,8 @@ void getGraphicSourceObjectExt_EM(struct GraphicInfo_EM *g_em, if (graphic_info[graphic].anim_global_sync) sync_frame = FrameCounter; + else if (graphic_info[graphic].anim_global_anim_sync) + sync_frame = getGlobalAnimSyncFrame(); else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY)) sync_frame = GfxFrame[x][y]; else