2017-09-12 03:28:15 +02:00
|
|
|
/*
|
2019-08-03 19:43:48 +02:00
|
|
|
* This software is licensed under the terms of the MIT License.
|
2017-09-12 03:28:15 +02:00
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
2024-05-16 23:30:41 +02:00
|
|
|
* Copyright (c) 2011-2024, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2024, Andrei Alexeyev <akari@taisei-project.org>.
|
2017-09-12 03:28:15 +02:00
|
|
|
*/
|
2017-04-02 16:06:18 +02:00
|
|
|
|
2021-08-12 23:09:01 +02:00
|
|
|
#pragma once
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
2017-04-02 16:06:18 +02:00
|
|
|
|
|
|
|
#include "color.h"
|
|
|
|
#include "resource/font.h"
|
|
|
|
|
|
|
|
typedef struct StageText StageText;
|
2018-06-01 20:40:18 +02:00
|
|
|
typedef LIST_ANCHOR(StageText) StageTextList;
|
2019-04-11 11:23:24 +02:00
|
|
|
typedef void (*StageTextUpdateFunc)(StageText* txt, int t, float alpha);
|
2017-04-02 16:06:18 +02:00
|
|
|
|
|
|
|
typedef struct StageTextTable StageTextTable;
|
|
|
|
|
2019-04-07 00:55:13 +02:00
|
|
|
// NOTE: tweaked to consume all padding in StageText, assuming x86_64 ABI
|
|
|
|
#define STAGETEXT_BUF_SIZE 76
|
|
|
|
|
2017-04-02 16:06:18 +02:00
|
|
|
struct StageText {
|
2019-04-12 10:36:40 +02:00
|
|
|
LIST_INTERFACE(StageText);
|
2017-04-02 16:06:18 +02:00
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
Font *font;
|
2019-11-22 04:37:11 +01:00
|
|
|
cmplx pos;
|
2019-04-07 00:55:13 +02:00
|
|
|
|
|
|
|
struct {
|
2019-04-11 11:23:24 +02:00
|
|
|
StageTextUpdateFunc update;
|
2019-04-07 00:55:13 +02:00
|
|
|
void *data1;
|
|
|
|
void *data2;
|
|
|
|
} custom;
|
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
Color color;
|
2019-04-07 00:55:13 +02:00
|
|
|
Alignment align;
|
2017-04-02 16:06:18 +02:00
|
|
|
|
2018-01-12 19:26:07 +01:00
|
|
|
struct {
|
|
|
|
int spawn;
|
|
|
|
int life;
|
|
|
|
int fadein;
|
|
|
|
int fadeout;
|
|
|
|
} time;
|
2017-04-02 16:06:18 +02:00
|
|
|
|
2019-04-07 00:55:13 +02:00
|
|
|
char text[STAGETEXT_BUF_SIZE];
|
2017-04-02 16:06:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void stagetext_free(void);
|
2019-04-11 11:23:24 +02:00
|
|
|
void stagetext_update(void);
|
2017-04-02 16:06:18 +02:00
|
|
|
void stagetext_draw(void);
|
2019-11-22 04:37:11 +01:00
|
|
|
StageText *stagetext_add(const char *text, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
|
|
|
|
StageText *stagetext_add_numeric(int n, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime);
|
2019-04-14 06:16:10 +02:00
|
|
|
StageText *stagetext_list_head(void);
|
2017-04-02 16:06:18 +02:00
|
|
|
|
|
|
|
struct StageTextTable {
|
2019-11-22 04:37:11 +01:00
|
|
|
cmplx pos;
|
2018-01-12 19:26:07 +01:00
|
|
|
double width;
|
|
|
|
Color clr;
|
|
|
|
int lifetime;
|
|
|
|
int fadeintime;
|
|
|
|
int fadeouttime;
|
|
|
|
int delay;
|
|
|
|
ListContainer *elems;
|
2017-04-02 16:06:18 +02:00
|
|
|
};
|
|
|
|
|
2018-07-23 19:07:59 +02:00
|
|
|
void stagetext_begin_table(StageTextTable *tbl, const char *title, const Color *titleclr, const Color *clr, double width, int delay, int lifetime, int fadeintime, int fadeouttime);
|
2017-04-02 16:06:18 +02:00
|
|
|
void stagetext_end_table(StageTextTable *tbl);
|
|
|
|
void stagetext_table_add(StageTextTable *tbl, const char *title, const char *val);
|
|
|
|
void stagetext_table_add_numeric(StageTextTable *tbl, const char *title, int n);
|
2017-04-04 02:57:38 +02:00
|
|
|
void stagetext_table_add_numeric_nonzero(StageTextTable *tbl, const char *title, int n);
|
|
|
|
void stagetext_table_add_separator(StageTextTable *tbl);
|