From adab6bbf3e2b3b78b7b51f18379e6db399b62b5c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 3 Feb 2016 20:01:49 +0100 Subject: [PATCH] separated graphic and control definitions for global animations --- src/conf_gfx.c | 9 +++++++++ src/init.c | 36 ++++++++++++++++++++---------------- src/main.c | 13 ++++++++++++- src/main.h | 17 +++++++++++++++-- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index e5937a08..18d12dd9 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4591,6 +4591,15 @@ struct ConfigInfo image_config[] = { "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 }, diff --git a/src/init.c b/src/init.c index 0af298ee..f85660d1 100644 --- a/src/init.c +++ b/src/init.c @@ -232,7 +232,7 @@ static void InitGlobalAnimImages() 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++) { @@ -537,15 +537,19 @@ void InitGlobalAnimGraphicInfo() 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 (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++) @@ -555,14 +559,14 @@ void InitGlobalAnimGraphicInfo() 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; - /* 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; @@ -573,11 +577,11 @@ void InitGlobalAnimGraphicInfo() 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) - 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 } @@ -4989,7 +4993,7 @@ static void InitArtworkConfig() { 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]; @@ -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; - 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 + 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; diff --git a/src/main.c b/src/main.c index d315bc7f..190cda43 100644 --- a/src/main.c +++ b/src/main.c @@ -5551,8 +5551,19 @@ struct FontInfo font_info[NUM_FONTS + 1] = { 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", }, diff --git a/src/main.h b/src/main.h index 157eafe6..3e58df38 100644 --- a/src/main.h +++ b/src/main.h @@ -870,6 +870,8 @@ #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 : \ @@ -1958,6 +1960,17 @@ /* 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 @@ -2762,8 +2775,8 @@ struct GlobalAnimInfo { 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 -- 2.34.1