#include "screens.h"
+#define DEBUG_ANIM_DELAY 0
#define DEBUG_ANIM_EVENTS 0
};
// 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);
}
}
+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)
{
{
PlayGlobalAnimSoundAndMusic(part);
+ HandleGlobalAnimDelay(part, ANIM_DELAY_INIT, "START [INIT_DELAY]");
HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]");
}
else
PlayGlobalAnimSoundAndMusic(part);
+ HandleGlobalAnimDelay(part, ANIM_DELAY_INIT, "START [INIT_DELAY]");
HandleGlobalAnimEvent(part, ANIM_EVENT_START, "START [ANIM]");
}
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));
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;
#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 ?
{ ".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 },
{
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) ||
#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 *);
{
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);
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;
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];
#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
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,
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