From: Holger Schemel Date: Mon, 11 Jan 2016 23:44:57 +0000 (+0100) Subject: added configuration handling for global animations (yet to be implemented) X-Git-Tag: 4.0.0.0-rc1~99 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=8bc9d8febda30d07142948f6b892365d3e11a940 added configuration handling for global animations (yet to be implemented) --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 4766b3fd..461dd981 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4588,6 +4588,15 @@ struct ConfigInfo image_config[] = { "toon_20.direction", "down" }, { "toon_20.position", "any" }, + { "global.anim_1", UNDEFINED_FILENAME }, + { "global.anim_2", UNDEFINED_FILENAME }, + { "global.anim_3", UNDEFINED_FILENAME }, + { "global.anim_4", UNDEFINED_FILENAME }, + { "global.anim_5", UNDEFINED_FILENAME }, + { "global.anim_6", UNDEFINED_FILENAME }, + { "global.anim_7", UNDEFINED_FILENAME }, + { "global.anim_8", UNDEFINED_FILENAME }, + { "menu.calibrate_red", "RocksElements.png" }, { "menu.calibrate_red.xpos", "12" }, { "menu.calibrate_red.ypos", "8" }, diff --git a/src/init.c b/src/init.c index ca820886..67079ca5 100644 --- a/src/init.c +++ b/src/init.c @@ -505,6 +505,61 @@ void InitFontGraphicInfo() getFontBitmapID, getFontFromToken); } +void InitGlobalAnimGraphicInfo() +{ + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + int i, j, k; + + if (graphic_info == NULL) /* still at startup phase */ + 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 (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; + + /* initialize global animation definitions from dynamic configuration */ + for (i = 0; i < num_property_mappings; i++) + { + int anim_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS - NUM_FONTS; + int part_nr = property_mapping[i].ext1_index - ACTION_PART_1; + int special = property_mapping[i].ext3_index; + int graphic = property_mapping[i].artwork_index; + + if (anim_nr < 0 || anim_nr >= NUM_GLOBAL_ANIMS) + continue; + + /* map animation part to first part, if not specified */ + if (part_nr < 0) + part_nr = 0; + + /* map animation screen to default, if not specified */ + if (!IS_SPECIAL_GFX_ARG(special)) + special = GFX_SPECIAL_ARG_DEFAULT; + + global_anim_info[anim_nr].graphic[part_nr][special] = graphic; + } + +#if 0 + printf("::: InitGlobalAnimGraphicInfo\n"); + + for (i = 0; i < NUM_GLOBAL_ANIMS; i++) + for (j = 0; j < NUM_GLOBAL_ANIM_PARTS; 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", + i, j, k, global_anim_info[i].graphic[j][k]); +#endif +} + void InitElementGraphicInfo() { struct PropertyMapping *property_mapping = getImageListPropertyMapping(); @@ -1936,6 +1991,8 @@ static void ReinitializeGraphics() print_timestamp_time("InitBitmapPointers"); InitFontGraphicInfo(); /* initialize text drawing functions */ print_timestamp_time("InitFontGraphicInfo"); + InitGlobalAnimGraphicInfo(); /* initialize global animations */ + print_timestamp_time("InitGlobalAnimGraphicInfo"); InitGraphicInfo_EM(); /* graphic mapping for EM engine */ print_timestamp_time("InitGraphicInfo_EM"); @@ -4901,7 +4958,9 @@ static char *get_level_id_suffix(int id_nr) static void InitArtworkConfig() { - static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1]; + static char *image_id_prefix[MAX_NUM_ELEMENTS + + NUM_FONTS + + NUM_GLOBAL_ANIMS + 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]; @@ -4962,7 +5021,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[MAX_NUM_ELEMENTS + NUM_FONTS] = NULL; + for (i = 0; i < NUM_GLOBAL_ANIMS; 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; 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 9659af05..d315bc7f 100644 --- a/src/main.c +++ b/src/main.c @@ -5440,6 +5440,14 @@ struct ElementActionInfo element_action_info[NUM_ACTIONS + 1 + 1] = { ".page[30]", ACTION_PAGE_30, FALSE }, { ".page[31]", ACTION_PAGE_31, FALSE }, { ".page[32]", ACTION_PAGE_32, FALSE }, + { ".part_1", ACTION_PART_1, FALSE }, + { ".part_2", ACTION_PART_2, FALSE }, + { ".part_3", ACTION_PART_3, FALSE }, + { ".part_4", ACTION_PART_4, FALSE }, + { ".part_5", ACTION_PART_5, FALSE }, + { ".part_6", ACTION_PART_6, FALSE }, + { ".part_7", ACTION_PART_7, FALSE }, + { ".part_8", ACTION_PART_8, FALSE }, { ".other", ACTION_OTHER, FALSE }, /* empty suffix always matches -- check as last entry in InitSoundInfo() */ @@ -5543,6 +5551,20 @@ struct FontInfo font_info[NUM_FONTS + 1] = { NULL } }; +struct GlobalAnimInfo global_anim_info[NUM_GLOBAL_ANIMS + 1] = +{ + { "global.anim_1", }, + { "global.anim_2", }, + { "global.anim_3", }, + { "global.anim_4", }, + { "global.anim_5", }, + { "global.anim_6", }, + { "global.anim_7", }, + { "global.anim_8", }, + + { NULL } +}; + /* ------------------------------------------------------------------------- */ /* music token prefix definitions */ diff --git a/src/main.h b/src/main.h index 8b4948d7..2cbb77f0 100644 --- a/src/main.h +++ b/src/main.h @@ -1765,9 +1765,17 @@ #define ACTION_PAGE_30 81 #define ACTION_PAGE_31 82 #define ACTION_PAGE_32 83 -#define ACTION_OTHER 84 - -#define NUM_ACTIONS 85 +#define ACTION_PART_1 84 +#define ACTION_PART_2 85 +#define ACTION_PART_3 86 +#define ACTION_PART_4 87 +#define ACTION_PART_5 88 +#define ACTION_PART_6 89 +#define ACTION_PART_7 90 +#define ACTION_PART_8 91 +#define ACTION_OTHER 92 + +#define NUM_ACTIONS 93 #define ACTION_BORING_LAST ACTION_BORING_10 #define ACTION_SLEEPING_LAST ACTION_SLEEPING_3 @@ -1944,6 +1952,10 @@ #define NUM_FONTS 38 #define NUM_INITIAL_FONTS 4 +/* values for global animation configuration (must match those from main.c) */ +#define NUM_GLOBAL_ANIMS 8 +#define NUM_GLOBAL_ANIM_PARTS 8 + /* values for game_status (must match special image configuration suffixes) */ #define GAME_MODE_DEFAULT 0 #define GAME_MODE_LOADING 1 @@ -2743,6 +2755,14 @@ struct FontInfo /* internal bitmap ID for special graphics */ }; +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]; +}; + struct GraphicInfo { Bitmap **bitmaps; /* bitmaps in all required sizes */ @@ -3016,6 +3036,7 @@ extern struct ElementDirectionInfo element_direction_info[]; extern struct SpecialSuffixInfo special_suffix_info[]; extern struct TokenIntPtrInfo image_config_vars[]; extern struct FontInfo font_info[]; +extern struct GlobalAnimInfo global_anim_info[]; extern struct MusicPrefixInfo music_prefix_info[]; extern struct GraphicInfo *graphic_info; extern struct SoundInfo *sound_info;