This change adds the following new global animations event types,
which can be used like the already existing "click:anim_X.part_Y":
* init:anim_X.part_Y - triggers when animation is initialized
* start:anim_X.part_Y - triggers when animation is started
* end:anim_X.part_Y - triggers when animation ends
* post:anim_X.part_Y - triggers when animation post delay ends
The second part ".part_Y" is optional; if missing, events for every
animation part will trigger the animation for which this event is
defined.
The "init" event will trigger even if the animation is not yet
displayed, but starts waiting for its "init_delay" or "init_event",
while the "start" event will trigger when the first frame of the
animation is displayed.
The "end" event will trigger when the last frame of the animation is
displayed (either because the animation has stopped due to a click
event, due to the "anim_delay" being finished or because the animation
has completely moved off the screen), while the "post" event will
trigger when the "post_delay" is completely finished.
+static void HandleGlobalAnimEvent(struct GlobalAnimPartControlInfo *part,
+ int event_value, char *info_text)
+{
+#if DEBUG_ANIM_EVENTS
+ printf("::: %d.%d %s\n", part->old_anim_nr + 1, part->old_nr + 1, info_text);
+#endif
+
+ boolean anything_clicked = FALSE;
+ boolean any_event_action = FALSE;
+
+ // check if this event is defined to trigger other animations
+ InitGlobalAnim_Triggered(part, &anything_clicked, &any_event_action,
+ event_value);
+}
+
static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
int state)
{
static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
int state)
{
if (part->init_delay_counter == 0 &&
!part->init_event_state)
if (part->init_delay_counter == 0 &&
!part->init_event_state)
PlayGlobalAnimSoundAndMusic(part);
PlayGlobalAnimSoundAndMusic(part);
+
+ HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]");
+ }
+ else
+ {
+ HandleGlobalAnimEvent(part, ANIM_EVENT_INIT, "START [INIT_DELAY/EVENT]");
+ }
part->init_event_state = FALSE;
PlayGlobalAnimSoundAndMusic(part);
part->init_event_state = FALSE;
PlayGlobalAnimSoundAndMusic(part);
+
+ HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]");
}
return ANIM_STATE_WAITING;
}
return ANIM_STATE_WAITING;
{
StopGlobalAnimSoundAndMusic(part);
{
StopGlobalAnimSoundAndMusic(part);
+ HandleGlobalAnimEvent(part, ANIM_EVENT_END, "END [ANIM/OFF-SCREEN]");
+
part->post_delay_counter =
(c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
part->post_delay_counter =
(c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
StopGlobalAnimSoundAndMusic(part);
StopGlobalAnimSoundAndMusic(part);
+ HandleGlobalAnimEvent(part, ANIM_EVENT_END, "END [ANIM_DELAY/EVENT]");
+
part->post_delay_counter =
(c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
part->post_delay_counter =
(c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
part->post_delay_counter--;
if (part->post_delay_counter == 0)
part->post_delay_counter--;
if (part->post_delay_counter == 0)
+ {
+ HandleGlobalAnimEvent(part, ANIM_EVENT_POST, "END [POST_DELAY]");
+
return ANIM_STATE_RESTART;
return ANIM_STATE_RESTART;
return ANIM_STATE_WAITING;
}
return ANIM_STATE_WAITING;
}
+ ANIM_EVENT_CLICK,
+ ANIM_EVENT_INIT,
+ ANIM_EVENT_START,
+ ANIM_EVENT_END,
+ ANIM_EVENT_POST
+ "click:anim_",
+ "init:anim_",
+ "start:anim_",
+ "end:anim_",
+ "post:anim_"
};
char *pattern_2 = ".part_";
char *matching_char = NULL;
};
char *pattern_2 = ".part_";
char *matching_char = NULL;
#define ANIM_EVENT_SELF (1 << 16)
#define ANIM_EVENT_ANY (1 << 17)
#define ANIM_EVENT_CLICK (1 << 18)
#define ANIM_EVENT_SELF (1 << 16)
#define ANIM_EVENT_ANY (1 << 17)
#define ANIM_EVENT_CLICK (1 << 18)
+#define ANIM_EVENT_INIT (1 << 19)
+#define ANIM_EVENT_START (1 << 20)
+#define ANIM_EVENT_END (1 << 21)
+#define ANIM_EVENT_POST (1 << 22)
// anim number: bits 0-7
// part number: bits 8-15
// anim number: bits 0-7
// part number: bits 8-15