/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../../libs.h" #define ANIMATION_QUEUE_ITEM_MAX 128 #define ANIMATION_QUEUE_START 0xFF typedef struct _queueaction_t queueaction_t; typedef struct _queue_t queue_t; /** * Callback for queue events. * @param conversation Conversation this text is attached to. * @param text Text item that is being used in the callback * @param i Index of the item in the queue. */ typedef void queuecallback_t(queue_t *queue, queueaction_t *action, uint8_t i); typedef struct _queueaction_t { /** Index that the action is within the queue */ uint8_t index; /** Pointer to any custom user data */ void *data; /** Callback to fire the moment the action is active in the queue */ queuecallback_t *onStart; /** Callback to fire when this action has ended */ queuecallback_t *onEnd; /** Callback to fire every update of this queue while action is active. */ queuecallback_t *onUpdate; } queueaction_t; typedef struct _queue_t { /** Array of items within the queue. */ queueaction_t items[ANIMATION_QUEUE_ITEM_MAX]; uint8_t count; /** Current index within the array of actions that is currently processing */ uint8_t current; /** Internal timeline tracking */ float timeline; /** Time that the current aciton started */ float actionStarted; /** Delay Queue Item Storage */ float delays[ANIMATION_QUEUE_ITEM_MAX]; } queue_t;