timeline: add TM_AddActionAfter

This commit is contained in:
Sebastian Krzyszkowiak 2018-07-05 22:31:18 +02:00
parent c4ceb188f5
commit ab17bd8050
2 changed files with 28 additions and 10 deletions

View file

@ -183,17 +183,8 @@ SYMBOL_EXPORT void TM_Process(struct Timeline* timeline, double delta) {
}
}
SYMBOL_EXPORT struct TM_Action* TM_AddNamedAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, char* name) {
static struct TM_Action* CreateAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, char* name) {
struct TM_Action* action = malloc(sizeof(struct TM_Action));
if (timeline->queue) {
struct TM_Action* pom = timeline->queue;
while (pom->next != NULL) {
pom = pom->next;
}
pom->next = action;
} else {
timeline->queue = action;
}
action->next = NULL;
action->function = func;
action->arguments = args;
@ -211,6 +202,27 @@ SYMBOL_EXPORT struct TM_Action* TM_AddNamedAction(struct Timeline* timeline, TM_
return action;
}
SYMBOL_EXPORT struct TM_Action* TM_AddNamedAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, char* name) {
struct TM_Action* action = CreateAction(timeline, func, args, name);
if (timeline->queue) {
struct TM_Action* pom = timeline->queue;
while (pom->next != NULL) {
pom = pom->next;
}
pom->next = action;
} else {
timeline->queue = action;
}
return action;
}
SYMBOL_EXPORT struct TM_Action* TM_AddNamedActionAfter(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, struct TM_Action* after, char* name) {
struct TM_Action* action = CreateAction(timeline, func, args, name);
action->next = after->next;
after->next = action;
return action;
}
SYMBOL_EXPORT struct TM_Action* TM_AddNamedBackgroundAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, int delay, char* name) {
struct TM_Action* action = malloc(sizeof(struct TM_Action));
if (timeline->background) {

View file

@ -75,6 +75,9 @@ void TM_Process(struct Timeline*, double delta);
/*! \brief Add new action to main queue, with specified name. */
struct TM_Action* TM_AddNamedAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, char* name);
/*! \brief Add new action to main queue, with specified name, placed after specified action. */
struct TM_Action* TM_AddNamedActionAfter(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, struct TM_Action* after, char* name);
/*! \brief Add new action to background queue, with specified name. */
struct TM_Action* TM_AddNamedBackgroundAction(struct Timeline* timeline, TM_ActionCallback* func, struct TM_Arguments* args, int delay, char* name);
@ -84,6 +87,9 @@ struct TM_Action* TM_AddQueuedNamedBackgroundAction(struct Timeline* timeline, T
/*! \brief Add new action to main queue. */
#define TM_AddAction(timeline, func, args) TM_AddNamedAction(timeline, func, args, #func)
/*! \brief Add new action to main queue placed after specified action.. */
#define TM_AddActionAfter(timeline, func, args, after) TM_AddNamedAction(timeline, func, args, after, #func)
/*! \brief Add new action to background queue. */
#define TM_AddBackgroundAction(timeline, func, args, delay) TM_AddNamedBackgroundAction(timeline, func, args, delay, #func)