Still working on my scrolling text and bug fixing.
This commit is contained in:
@ -55,4 +55,9 @@
|
||||
#include "util/array.h"
|
||||
#include "util/list.h"
|
||||
#include "util/math.h"
|
||||
#include "util/rand.h"
|
||||
#include "util/rand.h"
|
||||
|
||||
// Visual Novel Objects
|
||||
#include "vn/conversation.h"
|
||||
|
||||
#include "vn/gui/vntextbox.h"
|
@ -8,15 +8,24 @@
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
|
||||
#define TIMELINE_ACTION_COUNT_MAX 128
|
||||
/** Maximum number of actions a timeline can support, smaller than 0xFF */
|
||||
#define TIMELINE_ACTION_COUNT_MAX 32
|
||||
|
||||
/** Type forwarder for timeline_t */
|
||||
/** Type forwarders */
|
||||
typedef struct _timeline_t timeline_t;
|
||||
typedef struct _timelineaction_t timelineaction_t;
|
||||
|
||||
/** Callback for when a timeline event occurs */
|
||||
typedef void timelinecallback_t(timeline_t*);
|
||||
/**
|
||||
* Callback for when a timeline event occurs
|
||||
* @param timeline The timeline that fired this callback.
|
||||
* @param action The action that this callback is attached to.
|
||||
* @param i The index that this action is within the timeline.
|
||||
*/
|
||||
typedef void timelinecallback_t(timeline_t *timeline, timelineaction_t *action,
|
||||
uint8_t i
|
||||
);
|
||||
|
||||
typedef struct test_t {
|
||||
typedef struct _timelineaction_t {
|
||||
/**
|
||||
* The time that this action should occur within the timeline
|
||||
* set to 0 or less to start immediately.
|
||||
@ -33,6 +42,13 @@ typedef struct test_t {
|
||||
*/
|
||||
float duration;
|
||||
|
||||
/**
|
||||
* Enables animation looping. This works by forcing start to be equal to the
|
||||
* current time at the point in time that onEnd is called. This will also stop
|
||||
* onStart being called so ensure that your onStart and onEnd logic works.
|
||||
*/
|
||||
bool loop;
|
||||
|
||||
timelinecallback_t *onStart;
|
||||
timelinecallback_t *onDuration;
|
||||
timelinecallback_t *onEnd;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define FONT_FILL_MODE 1
|
||||
|
||||
/** Passed to STBTT for scaling the font nicely, essentially the font size. */
|
||||
#define FONT_TEXTURE_SIZE 112
|
||||
#define FONT_TEXTURE_SIZE 32
|
||||
|
||||
// Chars
|
||||
#define FONT_NEWLINE '\n'
|
||||
@ -36,25 +36,41 @@
|
||||
#define FONT_INITIAL_LINE FONT_LINE_HEIGHT*0.75
|
||||
#define FONT_SPACE_SIZE FONT_TEXTURE_SIZE*0.45
|
||||
|
||||
/** Maximum number of characters a font text info can hold. */
|
||||
#define FONT_TEXT_INFO_CHARS_MAX 1024
|
||||
|
||||
/** Maximum number of newlines that a font text info can hold. */
|
||||
#define FONT_TEXT_INFO_LINES_MAX FONT_TEXT_INFO_CHARS_MAX/50
|
||||
|
||||
/** Representation of a font that can be used to render text */
|
||||
typedef struct {
|
||||
texture_t texture;
|
||||
stbtt_bakedchar characterData[FONT_NUM_CHARS];
|
||||
} font_t;
|
||||
|
||||
typedef struct {
|
||||
/** What (real character) index the line starts at */
|
||||
int32_t start;
|
||||
/** How many (real) characters the line is in length */
|
||||
int32_t length;
|
||||
} fonttextinfoline_t;
|
||||
|
||||
typedef struct {
|
||||
/** How many raw chars are in the string */
|
||||
int32_t length;
|
||||
|
||||
/** How many rendered chars are in the string */
|
||||
/** How many real characters (non whitespace) are in the string */
|
||||
int32_t realLength;
|
||||
|
||||
/** How many lines is the string? Trailing newlines will count */
|
||||
int32_t lines;
|
||||
int32_t lineCount;
|
||||
|
||||
/** The real character info for each line */
|
||||
fonttextinfoline_t lines[FONT_TEXT_INFO_LINES_MAX];
|
||||
|
||||
/** Dimensions of the string */
|
||||
float width, height;
|
||||
|
||||
/** Array of precalculated quads */
|
||||
stbtt_aligned_quad *quads;
|
||||
stbtt_aligned_quad quads[FONT_TEXT_INFO_CHARS_MAX];
|
||||
} fonttextinfo_t;
|
@ -84,9 +84,6 @@ typedef struct {
|
||||
/** Frames to hold the world and GUI render outputs */
|
||||
framebuffer_t frameWorld, frameGui;
|
||||
|
||||
/** Game's Font */
|
||||
font_t font;
|
||||
|
||||
/** Game's Shader */
|
||||
shader_t shader;
|
||||
|
||||
@ -96,16 +93,6 @@ typedef struct {
|
||||
/** Refer to POKER_GUI_HEIGHT */
|
||||
float guiWidth;
|
||||
|
||||
/** Last frame's GUI width, used to track font wrapping */
|
||||
float textLastWidth;
|
||||
/** Primitive to hold talking text */
|
||||
primitive_t talkPrimitive;
|
||||
/** Current spoken text, tracked in-case of re-render */
|
||||
char *talkText;
|
||||
/** Information about the current rendered text */
|
||||
fonttextinfo_t *talkTextInfo;
|
||||
|
||||
|
||||
texture_t chipTexture;
|
||||
primitive_t chipPrimitive;
|
||||
|
||||
|
22
include/dawn/vn/conversation.h
Normal file
22
include/dawn/vn/conversation.h
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
|
||||
#define CONVERSATION_TEXT_COUNT_MAX 32
|
||||
|
||||
typedef struct {
|
||||
char *text;
|
||||
uint8_t speaker;
|
||||
} conversationtext_t;
|
||||
|
||||
typedef struct {
|
||||
conversationtext_t texts[CONVERSATION_TEXT_COUNT_MAX];
|
||||
uint8_t textCount;
|
||||
uint8_t textCurrent;
|
||||
} conversation_t;
|
46
include/dawn/vn/gui/vntextbox.h
Normal file
46
include/dawn/vn/gui/vntextbox.h
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/animation/timeline.h"
|
||||
#include "../../display/gui/font.h"
|
||||
|
||||
/** Amount of characters scrolled, per second */
|
||||
#define VN_TEXTBOX_SCROLL_SPEED 60
|
||||
|
||||
typedef struct {
|
||||
/** Stores the maximum width that this textbox can take up */
|
||||
float widthMax;
|
||||
|
||||
/** Font that the text box uses */
|
||||
font_t *font;
|
||||
|
||||
/** How many rows of text at most can be displayed in a single text box */
|
||||
int32_t linesMax;
|
||||
int32_t lineCurrent;
|
||||
|
||||
/** X, Y Position of the textbox */
|
||||
float x, y;
|
||||
|
||||
/** Animation of the textbox */
|
||||
timeline_t animTimeline;
|
||||
// timelineaction_t animActions;
|
||||
|
||||
/** Information about the current rendered text */
|
||||
fonttextinfo_t textInfo;
|
||||
|
||||
/** Primitive to hold talking text */
|
||||
primitive_t primitive;
|
||||
|
||||
// Testing assets
|
||||
primitive_t testPrimitive;
|
||||
texture_t testTexture;
|
||||
|
||||
/** Current spoken text, tracked in-case of re-render */
|
||||
char *text;
|
||||
} vntextbox_t;
|
Reference in New Issue
Block a user