separated graphic and control definitions for global animations
authorHolger Schemel <info@artsoft.org>
Wed, 3 Feb 2016 19:01:49 +0000 (20:01 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 3 Feb 2016 19:01:49 +0000 (20:01 +0100)
src/conf_gfx.c
src/init.c
src/main.c
src/main.h

index e5937a08e32782ffa3107c4d56eb71b63003d08a..18d12dd9f10a40f371857ced967d192aaa6601e4 100644 (file)
@@ -4591,6 +4591,15 @@ struct ConfigInfo image_config[] =
   { "toon_20.direction",                       "down"                  },
   { "toon_20.position",                                "any"                   },
 
   { "toon_20.direction",                       "down"                  },
   { "toon_20.position",                                "any"                   },
 
+  { "global.anim_1.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_2.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_3.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_4.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_5.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_6.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_7.gfx",                       UNDEFINED_FILENAME      },
+  { "global.anim_8.gfx",                       UNDEFINED_FILENAME      },
+
   { "global.anim_1",                           UNDEFINED_FILENAME      },
   { "global.anim_2",                           UNDEFINED_FILENAME      },
   { "global.anim_3",                           UNDEFINED_FILENAME      },
   { "global.anim_1",                           UNDEFINED_FILENAME      },
   { "global.anim_2",                           UNDEFINED_FILENAME      },
   { "global.anim_3",                           UNDEFINED_FILENAME      },
index 0af298ee1bcdb5af172c564d53334fa9b6fed34a..f85660d1e6a5898b67b8ba6d3f3b756125b29f31 100644 (file)
@@ -232,7 +232,7 @@ static void InitGlobalAnimImages()
 
   for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
   {
 
   for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
   {
-    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS; j++)
+    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++)
     {
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
       {
     {
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
       {
@@ -537,15 +537,19 @@ void InitGlobalAnimGraphicInfo()
     return;
 
   /* always start with reliable default values (no global animations) */
     return;
 
   /* always start with reliable default values (no global animations) */
-  for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
-    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS; j++)
+  for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++)
+    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++)
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
        global_anim_info[i].graphic[j][k] = IMG_UNDEFINED;
 
   /* initialize global animation definitions from static configuration */
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
        global_anim_info[i].graphic[j][k] = IMG_UNDEFINED;
 
   /* initialize global animation definitions from static configuration */
-  for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
-    global_anim_info[i].graphic[0][GFX_SPECIAL_ARG_DEFAULT] =
-      IMG_GLOBAL_ANIM_1 + i;
+  for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++)
+  {
+    int j = GLOBAL_ANIM_ID_PART_BASE;
+    int k = GFX_SPECIAL_ARG_DEFAULT;
+
+    global_anim_info[i].graphic[j][k] = IMG_GLOBAL_ANIM_1_GFX + i;
+  }
 
   /* initialize global animation definitions from dynamic configuration */
   for (i = 0; i < num_property_mappings; i++)
 
   /* initialize global animation definitions from dynamic configuration */
   for (i = 0; i < num_property_mappings; i++)
@@ -555,14 +559,14 @@ void InitGlobalAnimGraphicInfo()
     int special = property_mapping[i].ext3_index;
     int graphic = property_mapping[i].artwork_index;
 
     int special = property_mapping[i].ext3_index;
     int graphic = property_mapping[i].artwork_index;
 
-    if (anim_nr < 0 || anim_nr >= NUM_GLOBAL_ANIMS)
+    if (anim_nr < 0 || anim_nr >= NUM_GLOBAL_ANIM_TOKENS)
       continue;
 
       continue;
 
-    /* map animation part to first part, if not specified */
-    if (part_nr < 0)
-      part_nr = 0;
+    /* set animation part to base part, if not specified */
+    if (!IS_GLOBAL_ANIM_PART(part_nr))
+      part_nr = GLOBAL_ANIM_ID_PART_BASE;
 
 
-    /* map animation screen to default, if not specified */
+    /* set animation screen to default, if not specified */
     if (!IS_SPECIAL_GFX_ARG(special))
       special = GFX_SPECIAL_ARG_DEFAULT;
 
     if (!IS_SPECIAL_GFX_ARG(special))
       special = GFX_SPECIAL_ARG_DEFAULT;
 
@@ -573,11 +577,11 @@ void InitGlobalAnimGraphicInfo()
   printf("::: InitGlobalAnimGraphicInfo\n");
 
   for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
   printf("::: InitGlobalAnimGraphicInfo\n");
 
   for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
-    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS; j++)
+    for (j = 0; j < NUM_GLOBAL_ANIM_PARTS_ALL; j++)
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
        if (global_anim_info[i].graphic[j][k] != IMG_UNDEFINED &&
            graphic_info[global_anim_info[i].graphic[j][k]].bitmap != NULL)
       for (k = 0; k < NUM_SPECIAL_GFX_ARGS; k++)
        if (global_anim_info[i].graphic[j][k] != IMG_UNDEFINED &&
            graphic_info[global_anim_info[i].graphic[j][k]].bitmap != NULL)
-         printf("::: %d, %d, %d => %d\n",
+         printf("::: - anim %d, part %d, mode %d => %d\n",
                 i, j, k, global_anim_info[i].graphic[j][k]);
 #endif
 }
                 i, j, k, global_anim_info[i].graphic[j][k]);
 #endif
 }
@@ -4989,7 +4993,7 @@ static void InitArtworkConfig()
 {
   static char *image_id_prefix[MAX_NUM_ELEMENTS +
                               NUM_FONTS +
 {
   static char *image_id_prefix[MAX_NUM_ELEMENTS +
                               NUM_FONTS +
-                              NUM_GLOBAL_ANIMS + 1];
+                              NUM_GLOBAL_ANIM_TOKENS + 1];
   static char *sound_id_prefix[2 * MAX_NUM_ELEMENTS + 1];
   static char *music_id_prefix[NUM_MUSIC_PREFIXES + 1];
   static char *action_id_suffix[NUM_ACTIONS + 1];
   static char *sound_id_prefix[2 * MAX_NUM_ELEMENTS + 1];
   static char *music_id_prefix[NUM_MUSIC_PREFIXES + 1];
   static char *action_id_suffix[NUM_ACTIONS + 1];
@@ -5050,10 +5054,10 @@ static void InitArtworkConfig()
     image_id_prefix[i] = element_info[i].token_name;
   for (i = 0; i < NUM_FONTS; i++)
     image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name;
     image_id_prefix[i] = element_info[i].token_name;
   for (i = 0; i < NUM_FONTS; i++)
     image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name;
-  for (i = 0; i < NUM_GLOBAL_ANIMS; i++)
+  for (i = 0; i < NUM_GLOBAL_ANIM_TOKENS; i++)
     image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + i] =
       global_anim_info[i].token_name;
     image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + i] =
       global_anim_info[i].token_name;
-  image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + NUM_GLOBAL_ANIMS] = NULL;
+  image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + NUM_GLOBAL_ANIM_TOKENS] = NULL;
 
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
     sound_id_prefix[i] = element_info[i].token_name;
 
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
     sound_id_prefix[i] = element_info[i].token_name;
index d315bc7f354de93e317be411dff9d647e7b4b25f..190cda430c8e73fc277298364248aae0e7a5e074 100644 (file)
@@ -5551,8 +5551,19 @@ struct FontInfo font_info[NUM_FONTS + 1] =
   { NULL                       }
 };
 
   { NULL                       }
 };
 
-struct GlobalAnimInfo global_anim_info[NUM_GLOBAL_ANIMS + 1] =
+struct GlobalAnimInfo global_anim_info[NUM_GLOBAL_ANIM_TOKENS + 1] =
 {
 {
+  /* (real) graphic definitions used to define animation graphics */
+  { "global.anim_1.gfx",       },
+  { "global.anim_2.gfx",       },
+  { "global.anim_3.gfx",       },
+  { "global.anim_4.gfx",       },
+  { "global.anim_5.gfx",       },
+  { "global.anim_6.gfx",       },
+  { "global.anim_7.gfx",       },
+  { "global.anim_8.gfx",       },
+
+  /* (dummy) graphic definitions used to define animation controls */
   { "global.anim_1",           },
   { "global.anim_2",           },
   { "global.anim_3",           },
   { "global.anim_1",           },
   { "global.anim_2",           },
   { "global.anim_3",           },
index 157eafe6cdc233ee46eeba030eefd5df039ed67b..3e58df38a601d58203f83bc32086445f0699e0e8 100644 (file)
 
 #define IS_SPECIAL_GFX_ARG(a)  ((a) >= 0 && (a) < NUM_SPECIAL_GFX_ARGS)
 
 
 #define IS_SPECIAL_GFX_ARG(a)  ((a) >= 0 && (a) < NUM_SPECIAL_GFX_ARGS)
 
+#define IS_GLOBAL_ANIM_PART(a) ((a) >= 0 && (a) < NUM_GLOBAL_ANIM_PARTS)
+
 #define EL_CASCADE_ACTIVE(e)   (IS_EDITOR_CASCADE_INACTIVE(e) ? (e) + 1 : (e))
 #define EL_CASCADE_INACTIVE(e) (IS_EDITOR_CASCADE_ACTIVE(e)   ? (e) - 1 : (e))
 #define EL_CASCADE_TOGGLE(e)   (IS_EDITOR_CASCADE_INACTIVE(e) ? (e) + 1 :    \
 #define EL_CASCADE_ACTIVE(e)   (IS_EDITOR_CASCADE_INACTIVE(e) ? (e) + 1 : (e))
 #define EL_CASCADE_INACTIVE(e) (IS_EDITOR_CASCADE_ACTIVE(e)   ? (e) - 1 : (e))
 #define EL_CASCADE_TOGGLE(e)   (IS_EDITOR_CASCADE_INACTIVE(e) ? (e) + 1 :    \
 /* values for global animation configuration (must match those from main.c) */
 #define NUM_GLOBAL_ANIMS               8
 #define NUM_GLOBAL_ANIM_PARTS          8
 /* values for global animation configuration (must match those from main.c) */
 #define NUM_GLOBAL_ANIMS               8
 #define NUM_GLOBAL_ANIM_PARTS          8
+#define NUM_GLOBAL_ANIM_PARTS_ALL      (NUM_GLOBAL_ANIM_PARTS + 1)
+#define NUM_GLOBAL_ANIM_TOKENS         (2 * NUM_GLOBAL_ANIMS)
+
+#define GLOBAL_ANIM_ID_GRAPHIC_FIRST   0
+#define GLOBAL_ANIM_ID_GRAPHIC_LAST    7
+#define GLOBAL_ANIM_ID_CONTROL_FIRST   (NUM_GLOBAL_ANIMS + 0)
+#define GLOBAL_ANIM_ID_CONTROL_LAST    (NUM_GLOBAL_ANIMS + 7)
+
+#define GLOBAL_ANIM_ID_PART_FIRST      0
+#define GLOBAL_ANIM_ID_PART_LAST       7
+#define GLOBAL_ANIM_ID_PART_BASE       8
 
 /* values for game_status (must match special image configuration suffixes) */
 #define GAME_MODE_DEFAULT              0
 
 /* values for game_status (must match special image configuration suffixes) */
 #define GAME_MODE_DEFAULT              0
@@ -2762,8 +2775,8 @@ struct GlobalAnimInfo
 {
   char *token_name;            /* global animation token in config files */
 
 {
   char *token_name;            /* global animation token in config files */
 
-  /* global animation parts for certain screens */
-  int graphic[NUM_GLOBAL_ANIM_PARTS][NUM_SPECIAL_GFX_ARGS];
+  /* global animation graphic and control definitions */
+  int graphic[NUM_GLOBAL_ANIM_PARTS_ALL][NUM_SPECIAL_GFX_ARGS];
 };
 
 struct GraphicInfo
 };
 
 struct GraphicInfo