added new animation mode ".global_anim_sync" for game element graphics
authorHolger Schemel <info@artsoft.org>
Wed, 26 Oct 2022 22:50:24 +0000 (00:50 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 26 Oct 2022 22:51:19 +0000 (00:51 +0200)
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).

src/anim.c
src/anim.h
src/conf_gfx.c
src/game.c
src/init.c
src/main.h
src/tools.c

index c4952d700167e4516274d694648cf70c51262ecc..50075c832ab8b42b4993c7c8fa7f7871aeac831c 100644 (file)
@@ -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 =
     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)
 
     // 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;
 }
 
   return click_consumed_current;
 }
+
+int getGlobalAnimSyncFrame(void)
+{
+  return anim_sync_frame;
+}
index 5c5b7895456569b5cd5e5e88cf2fb6b726cc5724..3d0153c99532c1c3ec8d23c9216d3c9128d932ea 100644 (file)
@@ -20,4 +20,6 @@ void DrawGlobalAnimations(int, int);
 
 boolean HandleGlobalAnimClicks(int, int, int, boolean);
 
 
 boolean HandleGlobalAnimClicks(int, int, int, boolean);
 
+int getGlobalAnimSyncFrame(void);
+
 #endif
 #endif
index 37a37395b5931c2e2ceb9236bd642b5899cdb3b1..829000dab50915c3d9f05fddc85fbc0888d6f539 100644 (file)
@@ -41,6 +41,7 @@ struct ConfigTypeInfo image_config_suffix[] =
   { ".delay",                          "1",            TYPE_INTEGER    },
   { ".anim_mode",                      ARG_UNDEFINED,  TYPE_STRING     },
   { ".global_sync",                    "false",        TYPE_BOOLEAN    },
   { ".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    },
   { ".crumbled_like",                  ARG_UNDEFINED,  TYPE_ELEMENT    },
   { ".diggable_like",                  ARG_UNDEFINED,  TYPE_ELEMENT    },
   { ".border_size",                    ARG_UNDEFINED,  TYPE_INTEGER    },
index d3d7f513034d9f75dcc5a68d8d9819ef7073dda9..178f35defaf7352aff75dd66bbd529c6e22ad41c 100644 (file)
@@ -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 ?
        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)
        {
 
        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 ?
        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)
        {
 
        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;
 
   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)
   else if (ANIM_MODE(graphic) == ANIM_CE_VALUE)
     GfxFrame[x][y] = CustomValue[x][y];
   else if (ANIM_MODE(graphic) == ANIM_CE_SCORE)
index 547d629e6f4f8f9c416147cdb88201d29649fdac..6fd4ae087a8e5b4135de7de6cded6a737fc2020b 100644 (file)
@@ -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 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];
   // optional element for cloning crumble graphics
   if (parameter[GFX_ARG_CRUMBLED_LIKE] != ARG_UNDEFINED_VALUE)
     g->crumbled_like = parameter[GFX_ARG_CRUMBLED_LIKE];
index fd70216dddaa7b7bb6cb586bdf84563be68748c8..1a77f8a9bc7959fc7c73dfd018e4a213ef25ac8b 100644 (file)
@@ -2411,6 +2411,7 @@ enum
   GFX_ARG_DELAY,
   GFX_ARG_ANIM_MODE,
   GFX_ARG_GLOBAL_SYNC,
   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,
   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;
   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
 
   int crumbled_like;           // element for cloning crumble graphics
   int diggable_like;           // element for cloning digging graphics
index 9333f9f9b319263b16653a921472dea22f7a9ab7..98e60731333f9add8584999855c3ee65459e3e1f 100644 (file)
@@ -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;
   // 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,
 
   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;
 
   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
   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;
 
   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
   else if (IN_FIELD(x, y, MAX_LEV_FIELDX, MAX_LEV_FIELDY))
     sync_frame = GfxFrame[x][y];
   else