mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-14 17:04:22 +01:00
Timeline Manager: run next action in main queue immediatelly after the last one ended
This commit is contained in:
parent
9c414991dd
commit
655cce6abe
1 changed files with 37 additions and 28 deletions
|
@ -36,37 +36,46 @@ SYMBOL_EXPORT struct Timeline* TM_Init(struct Game* g, char* name) {
|
||||||
|
|
||||||
SYMBOL_EXPORT void TM_Process(struct Timeline* timeline) {
|
SYMBOL_EXPORT void TM_Process(struct Timeline* timeline) {
|
||||||
/* process first element from queue
|
/* process first element from queue
|
||||||
if returns true, delete it */
|
if returns true, delete it
|
||||||
if (timeline->queue) {
|
and repeat for the next one */
|
||||||
if (*timeline->queue->function) {
|
bool next = true;
|
||||||
if (!timeline->queue->active) {
|
while (next) {
|
||||||
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: run action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
|
if (timeline->queue) {
|
||||||
(*timeline->queue->function)(timeline->game, timeline->queue, TM_ACTIONSTATE_START);
|
if (*timeline->queue->function) {
|
||||||
}
|
if (!timeline->queue->active) {
|
||||||
timeline->queue->active = true;
|
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: run action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
|
||||||
if ((*timeline->queue->function)(timeline->game, timeline->queue, TM_ACTIONSTATE_RUNNING)) {
|
(*timeline->queue->function)(timeline->game, timeline->queue, TM_ACTIONSTATE_START);
|
||||||
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: destroy action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
|
}
|
||||||
timeline->queue->active=false;
|
timeline->queue->active = true;
|
||||||
struct TM_Action *tmp = timeline->queue;
|
if ((*timeline->queue->function)(timeline->game, timeline->queue, TM_ACTIONSTATE_RUNNING)) {
|
||||||
timeline->queue = timeline->queue->next;
|
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: destroy action (%d - %s)", timeline->name, timeline->queue->id, timeline->queue->name);
|
||||||
(*tmp->function)(timeline->game, tmp, TM_ACTIONSTATE_DESTROY);
|
timeline->queue->active=false;
|
||||||
TM_DestroyArgs(tmp->arguments);
|
struct TM_Action *tmp = timeline->queue;
|
||||||
free(tmp->name);
|
timeline->queue = timeline->queue->next;
|
||||||
free(tmp);
|
(*tmp->function)(timeline->game, tmp, TM_ACTIONSTATE_DESTROY);
|
||||||
}
|
TM_DestroyArgs(tmp->arguments);
|
||||||
} else {
|
free(tmp->name);
|
||||||
/* delay handling */
|
free(tmp);
|
||||||
if (timeline->queue->active) {
|
} else {
|
||||||
struct TM_Action *tmp = timeline->queue;
|
next = false;
|
||||||
timeline->queue = timeline->queue->next;
|
}
|
||||||
free(tmp->name);
|
|
||||||
free(tmp);
|
|
||||||
} else {
|
} else {
|
||||||
if (!al_get_timer_started(timeline->queue->timer)) {
|
/* delay handling */
|
||||||
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: delay started %d ms (%d - %s)", timeline->name, timeline->queue->delay, timeline->queue->id, timeline->queue->name);
|
if (timeline->queue->active) {
|
||||||
al_start_timer(timeline->queue->timer);
|
struct TM_Action *tmp = timeline->queue;
|
||||||
|
timeline->queue = timeline->queue->next;
|
||||||
|
free(tmp->name);
|
||||||
|
free(tmp);
|
||||||
|
} else {
|
||||||
|
if (!al_get_timer_started(timeline->queue->timer)) {
|
||||||
|
PrintConsole(timeline->game, "Timeline Manager[%s]: queue: delay started %d ms (%d - %s)", timeline->name, timeline->queue->delay, timeline->queue->id, timeline->queue->name);
|
||||||
|
al_start_timer(timeline->queue->timer);
|
||||||
|
}
|
||||||
|
next = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
next = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* process all elements from background marked as active */
|
/* process all elements from background marked as active */
|
||||||
|
|
Loading…
Reference in a new issue