Conversation code cleaned up a lot.
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
// Display / Rendering
|
||||
#include "display/animation/easing.h"
|
||||
#include "display/animation/queue.h"
|
||||
#include "display/animation/timeline.h"
|
||||
#include "display/debug/grid.h"
|
||||
|
||||
|
58
include/dawn/display/animation/queue.h
Normal file
58
include/dawn/display/animation/queue.h
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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;
|
@ -26,6 +26,9 @@ typedef void timelinecallback_t(timeline_t *timeline, timelineaction_t *action,
|
||||
);
|
||||
|
||||
typedef struct _timelineaction_t {
|
||||
/** Pointer to any custom user data the timeline action wants to use. */
|
||||
void *data;
|
||||
|
||||
/**
|
||||
* The time that this action should occur within the timeline
|
||||
* set to 0 or less to start immediately.
|
||||
@ -50,7 +53,9 @@ typedef struct _timelineaction_t {
|
||||
bool loop;
|
||||
|
||||
timelinecallback_t *onStart;
|
||||
|
||||
timelinecallback_t *onDuration;
|
||||
|
||||
timelinecallback_t *onEnd;
|
||||
} timelineaction_t;
|
||||
|
||||
|
@ -7,62 +7,30 @@
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../display/animation/queue.h"
|
||||
#include "vntextbox.h"
|
||||
|
||||
#define VN_CONVERSATION_TEXT_COUNT_MAX 32
|
||||
|
||||
// Type Forwarders
|
||||
|
||||
typedef struct _vnconversationtext_t vnconversationtext_t;
|
||||
typedef struct _vnconversation_t vnconversation_t;
|
||||
|
||||
/**
|
||||
* Callback for conversation text events.
|
||||
* @param conversation Conversation this text is attached to.
|
||||
* @param text Text item that is being used in the callback
|
||||
*/
|
||||
typedef void vnconversationcallback_t(vnconversation_t *conversation,
|
||||
vnconversationtext_t *text
|
||||
);
|
||||
typedef struct {
|
||||
/** Pointer to the original conversation */
|
||||
vnconversation_t *conversation;
|
||||
|
||||
typedef struct _vnconversationtext_t {
|
||||
/** Pointer to any custom user data for this text action. */
|
||||
void *data;
|
||||
|
||||
/** Conversation Type to decide what this data is used for */
|
||||
uint8_t type;
|
||||
|
||||
/** Pointer to the string for text to display */
|
||||
/** Storage for pointer to text for text conversation elements */
|
||||
char *text;
|
||||
|
||||
/** Time in seconds to delay if type is delay */
|
||||
float delay;
|
||||
|
||||
/** Callback to fire the moment the text is active in the conversation */
|
||||
vnconversationcallback_t *onStart;
|
||||
|
||||
/** Callback to fire every update tick of this conversation element */
|
||||
vnconversationcallback_t *onUpdate;
|
||||
|
||||
/** Callback to fire when this conversation element is ended */
|
||||
vnconversationcallback_t *onEnd;
|
||||
} vnconversationtext_t;
|
||||
/** Character this conversation piece belongs to */
|
||||
vncharacter_t *character;
|
||||
} vnconversationitemdata_t;
|
||||
|
||||
/** Representation of a conversation, laid out similarly to a timeline. */
|
||||
typedef struct _vnconversation_t {
|
||||
/** Internal Textbox for text elements */
|
||||
vntextbox_t textbox;
|
||||
|
||||
/** Array of text elements */
|
||||
vnconversationtext_t texts[VN_CONVERSATION_TEXT_COUNT_MAX];
|
||||
uint8_t textCount;
|
||||
/** Data Storage for items' data */
|
||||
vnconversationitemdata_t itemData[ANIMATION_QUEUE_ITEM_MAX];
|
||||
|
||||
/** Internal timeline tracking */
|
||||
float timeline;
|
||||
|
||||
/** When the current text was first attached */
|
||||
float delayStart;
|
||||
|
||||
/** Current index within the array of texts that is currently processing */
|
||||
uint8_t textCurrent;
|
||||
/** Internal Queue for queueing the conversation */
|
||||
queue_t actionQueue;
|
||||
} vnconversation_t;
|
Reference in New Issue
Block a user