From: Holger Schemel Date: Sat, 23 Mar 2019 21:58:54 +0000 (+0100) Subject: added global animation actions executed after init/anim/post delay X-Git-Tag: 4.1.3.0~19 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=56d8384fddc8e74f5327b28986f366927c3b2040 added global animation actions executed after init/anim/post delay This change adds the following new options for global animations: * .init_delay_action * .anim_delay_action * .post_delay_action They can be set to the same values as ".init_event_action" and ".anim_event_action" (buttons, gadgets and key actions). --- diff --git a/src/anim.c b/src/anim.c index ff44369c..eccd0185 100644 --- a/src/anim.c +++ b/src/anim.c @@ -19,6 +19,7 @@ #include "screens.h" +#define DEBUG_ANIM_DELAY 0 #define DEBUG_ANIM_EVENTS 0 @@ -209,6 +210,7 @@ struct AnimClassGameMode }; // forward declaration for internal use +static void DoGlobalAnim_DelayAction(struct GlobalAnimPartControlInfo *, int); static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *); static void HandleGlobalAnim(int, int); static void DoAnimationExt(void); @@ -1155,6 +1157,16 @@ static void InitGlobalAnim_Triggered(struct GlobalAnimPartControlInfo *part, } } +static void HandleGlobalAnimDelay(struct GlobalAnimPartControlInfo *part, + int delay_type, char *info_text) +{ +#if DEBUG_ANIM_DELAY + printf("::: %d.%d %s\n", part->old_anim_nr + 1, part->old_nr + 1, info_text); +#endif + + DoGlobalAnim_DelayAction(part, delay_type); +} + static void HandleGlobalAnimEvent(struct GlobalAnimPartControlInfo *part, int event_value, char *info_text) { @@ -1294,6 +1306,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, { PlayGlobalAnimSoundAndMusic(part); + HandleGlobalAnimDelay(part, ANIM_DELAY_INIT, "START [INIT_DELAY]"); HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]"); } else @@ -1333,6 +1346,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, PlayGlobalAnimSoundAndMusic(part); + HandleGlobalAnimDelay(part, ANIM_DELAY_INIT, "START [INIT_DELAY]"); HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]"); } @@ -1383,7 +1397,8 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, StopGlobalAnimSoundAndMusic(part); - HandleGlobalAnimEvent(part, ANIM_EVENT_END, "END [ANIM_DELAY/EVENT]"); + HandleGlobalAnimDelay(part, ANIM_DELAY_ANIM, "END [ANIM_DELAY]"); + HandleGlobalAnimEvent(part, ANIM_EVENT_END, "END [ANIM_DELAY/EVENT]"); part->post_delay_counter = (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random)); @@ -1402,6 +1417,7 @@ static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part, if (part->post_delay_counter == 0) { + HandleGlobalAnimDelay(part, ANIM_DELAY_POST, "END [POST_DELAY]"); HandleGlobalAnimEvent(part, ANIM_EVENT_POST, "END [POST_DELAY]"); return ANIM_STATE_RESTART; @@ -1633,6 +1649,21 @@ static void DoAnimationExt(void) #endif } +static void DoGlobalAnim_DelayAction(struct GlobalAnimPartControlInfo *part, + int delay_type) +{ + int delay_action = + (delay_type == ANIM_DELAY_INIT ? part->control_info.init_delay_action : + delay_type == ANIM_DELAY_ANIM ? part->control_info.anim_delay_action : + delay_type == ANIM_DELAY_POST ? part->control_info.post_delay_action : + ANIM_DELAY_ACTION_NONE); + + if (delay_action == ANIM_DELAY_ACTION_NONE) + return; + + PushUserEvent(USEREVENT_ANIM_DELAY_ACTION, delay_action, 0); +} + static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part) { int event_action = (part->init_event_state ? diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 7ea34072..bc6e1e5e 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -56,10 +56,13 @@ struct ConfigTypeInfo image_config_suffix[] = { ".draw_order", ARG_UNDEFINED, TYPE_INTEGER }, { ".init_delay_fixed", ARG_UNDEFINED, TYPE_INTEGER }, { ".init_delay_random", ARG_UNDEFINED, TYPE_INTEGER }, + { ".init_delay_action", ARG_UNDEFINED, TYPE_STRING }, { ".anim_delay_fixed", ARG_UNDEFINED, TYPE_INTEGER }, { ".anim_delay_random", ARG_UNDEFINED, TYPE_INTEGER }, + { ".anim_delay_action", ARG_UNDEFINED, TYPE_STRING }, { ".post_delay_fixed", ARG_UNDEFINED, TYPE_INTEGER }, { ".post_delay_random", ARG_UNDEFINED, TYPE_INTEGER }, + { ".post_delay_action", ARG_UNDEFINED, TYPE_STRING }, { ".init_event", ARG_UNDEFINED, TYPE_STRING }, { ".init_event_action", ARG_UNDEFINED, TYPE_STRING }, { ".anim_event", ARG_UNDEFINED, TYPE_STRING }, diff --git a/src/events.c b/src/events.c index 17f528e9..3a22c742 100644 --- a/src/events.c +++ b/src/events.c @@ -1607,6 +1607,7 @@ void HandleUserEvent(UserEvent *event) { switch (event->code) { + case USEREVENT_ANIM_DELAY_ACTION: case USEREVENT_ANIM_EVENT_ACTION: // execute action functions until matching action was found if (DoKeysymAction(event->value1) || diff --git a/src/events.h b/src/events.h index deba7439..823670bc 100644 --- a/src/events.h +++ b/src/events.h @@ -16,7 +16,8 @@ #define USEREVENT_NONE 0 -#define USEREVENT_ANIM_EVENT_ACTION 1 +#define USEREVENT_ANIM_DELAY_ACTION 1 +#define USEREVENT_ANIM_EVENT_ACTION 2 boolean NextValidEvent(Event *); diff --git a/src/files.c b/src/files.c index cfba947d..cf3c80a9 100644 --- a/src/files.c +++ b/src/files.c @@ -10290,7 +10290,10 @@ int get_parameter_value(char *value_raw, char *suffix, int type) { result = get_anim_parameter_values(value); } - else if (strEqual(suffix, ".init_event_action") || + else if (strEqual(suffix, ".init_delay_action") || + strEqual(suffix, ".anim_delay_action") || + strEqual(suffix, ".post_delay_action") || + strEqual(suffix, ".init_event_action") || strEqual(suffix, ".anim_event_action")) { result = get_anim_action_parameter_value(value_raw); diff --git a/src/init.c b/src/init.c index d3b33ec2..2bbc6238 100644 --- a/src/init.c +++ b/src/init.c @@ -1297,10 +1297,13 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->clone_from = -1; // do not use clone graphic g->init_delay_fixed = 0; g->init_delay_random = 0; + g->init_delay_action = -1; g->anim_delay_fixed = 0; g->anim_delay_random = 0; + g->anim_delay_action = -1; g->post_delay_fixed = 0; g->post_delay_random = 0; + g->post_delay_action = -1; g->init_event = ANIM_EVENT_UNDEFINED; g->anim_event = ANIM_EVENT_UNDEFINED; g->init_event_action = -1; @@ -1531,6 +1534,12 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->init_event_action = parameter[GFX_ARG_INIT_EVENT_ACTION]; if (parameter[GFX_ARG_ANIM_EVENT_ACTION] != ARG_UNDEFINED_VALUE) g->anim_event_action = parameter[GFX_ARG_ANIM_EVENT_ACTION]; + if (parameter[GFX_ARG_INIT_DELAY_ACTION] != ARG_UNDEFINED_VALUE) + g->init_delay_action = parameter[GFX_ARG_INIT_DELAY_ACTION]; + if (parameter[GFX_ARG_ANIM_DELAY_ACTION] != ARG_UNDEFINED_VALUE) + g->anim_delay_action = parameter[GFX_ARG_ANIM_DELAY_ACTION]; + if (parameter[GFX_ARG_POST_DELAY_ACTION] != ARG_UNDEFINED_VALUE) + g->post_delay_action = parameter[GFX_ARG_POST_DELAY_ACTION]; // used for toon animations and global animations g->step_offset = parameter[GFX_ARG_STEP_OFFSET]; diff --git a/src/libgame/system.h b/src/libgame/system.h index cf49d86f..4e64c326 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -352,6 +352,16 @@ #define STYLE_DEFAULT STYLE_NONE +// values for special global animation delay types +#define ANIM_DELAY_UNDEFINED -1 +#define ANIM_DELAY_NONE 0 +#define ANIM_DELAY_INIT 1 +#define ANIM_DELAY_ANIM 2 +#define ANIM_DELAY_POST 3 + +// values for special global animation delay actions +#define ANIM_DELAY_ACTION_NONE -1 + // values for special global animation events #define ANIM_EVENT_UNDEFINED -1 #define ANIM_EVENT_NONE 0 diff --git a/src/main.h b/src/main.h index 93874a7e..3350513f 100644 --- a/src/main.h +++ b/src/main.h @@ -2370,10 +2370,13 @@ enum GFX_ARG_DRAW_ORDER, GFX_ARG_INIT_DELAY_FIXED, GFX_ARG_INIT_DELAY_RANDOM, + GFX_ARG_INIT_DELAY_ACTION, GFX_ARG_ANIM_DELAY_FIXED, GFX_ARG_ANIM_DELAY_RANDOM, + GFX_ARG_ANIM_DELAY_ACTION, GFX_ARG_POST_DELAY_FIXED, GFX_ARG_POST_DELAY_RANDOM, + GFX_ARG_POST_DELAY_ACTION, GFX_ARG_INIT_EVENT, GFX_ARG_INIT_EVENT_ACTION, GFX_ARG_ANIM_EVENT, @@ -3461,10 +3464,13 @@ struct GraphicInfo int init_delay_fixed; // optional initial delay values for global int init_delay_random; // animations (pause interval before start) + int init_delay_action; // optional action called on animation start int anim_delay_fixed; // optional delay values for bored/sleeping int anim_delay_random; // and global animations (animation length) + int anim_delay_action; // optional action called on animation end int post_delay_fixed; // optional delay values after bored/global int post_delay_random; // animations (pause before next animation) + int post_delay_action; // optional action called after post delay int init_event; // optional event triggering animation start int init_event_action; // optional action called on animation start