2020-01-01 21:29:24 +01:00
|
|
|
#ifndef TEXTBOX_H
|
|
|
|
#define TEXTBOX_H
|
|
|
|
|
2023-01-13 05:11:39 +01:00
|
|
|
#include <stdint.h>
|
2020-01-01 21:29:24 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
Save textbox state, allow lang switches w/ textbox
This allows switching languages while a text box is on screen by saving
the necessary state for a text box to be retranslated when the language
is switched.
This saves the state of the position and direction of the crewmate that
the text box position is based off of (if applicable), and the text
case of the text box, the script name of the script, and the original
(English) lines of the text box. I did not explicitly label the original
lines as English lines except in a main game context, because
technically, custom levels could have original lines in a different
language.
Unfortunately, this doesn't work for every text box in the game.
Notably, the Level Complete, Game Complete, number of crewmates
remaining, trinket collection, Intermission 1 guides, etc. text boxes
are special and require further fixes, but that will be coming in later
commits.
2024-01-19 05:21:02 +01:00
|
|
|
/* Position of the crewmate that the text box position is based off of.
|
|
|
|
* NOT a crewmate sprite inside the text box (that's a TextboxSprite). */
|
|
|
|
struct TextboxCrewmatePosition
|
|
|
|
{
|
|
|
|
bool override_x;
|
|
|
|
bool override_y;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int dir;
|
|
|
|
bool text_above;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TextboxOriginalContext
|
|
|
|
{
|
|
|
|
std::vector<std::string> lines;
|
|
|
|
std::string script_name;
|
|
|
|
char text_case;
|
|
|
|
};
|
|
|
|
|
2023-08-06 00:34:15 +02:00
|
|
|
struct TextboxSprite
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int col;
|
|
|
|
int tile;
|
|
|
|
};
|
|
|
|
|
2023-08-20 19:11:44 +02:00
|
|
|
enum TextboxImage
|
|
|
|
{
|
|
|
|
TEXTIMAGE_NONE,
|
|
|
|
TEXTIMAGE_LEVELCOMPLETE,
|
|
|
|
TEXTIMAGE_GAMECOMPLETE
|
|
|
|
};
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
class textboxclass
|
|
|
|
{
|
|
|
|
public:
|
2024-01-17 20:26:52 +01:00
|
|
|
textboxclass(int gap);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
2023-08-06 00:34:15 +02:00
|
|
|
void addsprite(int x, int y, int tile, int col);
|
|
|
|
|
2023-08-20 19:11:44 +02:00
|
|
|
void setimage(TextboxImage image);
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void centerx(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void centery(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void adjust(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
void initcol(int rr, int gg, int bb);
|
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void update(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void remove(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void removefast(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.
This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.
I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 23:23:59 +01:00
|
|
|
void resize(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
|
Save textbox state, allow lang switches w/ textbox
This allows switching languages while a text box is on screen by saving
the necessary state for a text box to be retranslated when the language
is switched.
This saves the state of the position and direction of the crewmate that
the text box position is based off of (if applicable), and the text
case of the text box, the script name of the script, and the original
(English) lines of the text box. I did not explicitly label the original
lines as English lines except in a main game context, because
technically, custom levels could have original lines in a different
language.
Unfortunately, this doesn't work for every text box in the game.
Notably, the Level Complete, Game Complete, number of crewmates
remaining, trinket collection, Intermission 1 guides, etc. text boxes
are special and require further fixes, but that will be coming in later
commits.
2024-01-19 05:21:02 +01:00
|
|
|
void repositionfromcrewmate(void);
|
|
|
|
|
2021-09-07 00:41:49 +02:00
|
|
|
void addline(const std::string& t);
|
2022-12-30 22:57:24 +01:00
|
|
|
|
|
|
|
void pad(size_t left_pad, size_t right_pad);
|
|
|
|
|
|
|
|
void padtowidth(size_t new_w);
|
|
|
|
|
2023-03-18 23:24:14 +01:00
|
|
|
void centertext(void);
|
Save textbox state, allow lang switches w/ textbox
This allows switching languages while a text box is on screen by saving
the necessary state for a text box to be retranslated when the language
is switched.
This saves the state of the position and direction of the crewmate that
the text box position is based off of (if applicable), and the text
case of the text box, the script name of the script, and the original
(English) lines of the text box. I did not explicitly label the original
lines as English lines except in a main game context, because
technically, custom levels could have original lines in a different
language.
Unfortunately, this doesn't work for every text box in the game.
Notably, the Level Complete, Game Complete, number of crewmates
remaining, trinket collection, Intermission 1 guides, etc. text boxes
are special and require further fixes, but that will be coming in later
commits.
2024-01-19 05:21:02 +01:00
|
|
|
|
|
|
|
void translate(void);
|
2020-01-01 21:29:24 +01:00
|
|
|
public:
|
|
|
|
//Fundamentals
|
2021-09-13 06:02:15 +02:00
|
|
|
std::vector<std::string> lines;
|
2021-09-06 08:04:34 +02:00
|
|
|
int xp, yp, w, h;
|
2020-01-01 21:29:24 +01:00
|
|
|
int r,g,b;
|
2024-01-17 20:26:52 +01:00
|
|
|
int linegap;
|
2020-01-01 21:29:24 +01:00
|
|
|
int timer;
|
|
|
|
|
|
|
|
float tl;
|
2020-04-29 06:49:15 +02:00
|
|
|
float prev_tl;
|
2020-01-01 21:29:24 +01:00
|
|
|
int tm;
|
|
|
|
|
2021-03-20 03:51:36 +01:00
|
|
|
/* Whether to flip text box y-position in Flip Mode. */
|
|
|
|
bool flipme;
|
2021-03-23 22:29:32 +01:00
|
|
|
|
|
|
|
int rand;
|
2023-01-13 05:11:39 +01:00
|
|
|
|
2022-11-30 18:56:44 +01:00
|
|
|
bool large;
|
|
|
|
|
2024-01-21 02:02:35 +01:00
|
|
|
bool should_centerx;
|
|
|
|
bool should_centery;
|
|
|
|
|
2023-01-13 05:11:39 +01:00
|
|
|
uint32_t print_flags;
|
2023-03-18 22:31:13 +01:00
|
|
|
bool fill_buttons;
|
2023-08-06 00:34:15 +02:00
|
|
|
|
|
|
|
std::vector<TextboxSprite> sprites;
|
2023-08-20 19:11:44 +02:00
|
|
|
TextboxImage image;
|
Save textbox state, allow lang switches w/ textbox
This allows switching languages while a text box is on screen by saving
the necessary state for a text box to be retranslated when the language
is switched.
This saves the state of the position and direction of the crewmate that
the text box position is based off of (if applicable), and the text
case of the text box, the script name of the script, and the original
(English) lines of the text box. I did not explicitly label the original
lines as English lines except in a main game context, because
technically, custom levels could have original lines in a different
language.
Unfortunately, this doesn't work for every text box in the game.
Notably, the Level Complete, Game Complete, number of crewmates
remaining, trinket collection, Intermission 1 guides, etc. text boxes
are special and require further fixes, but that will be coming in later
commits.
2024-01-19 05:21:02 +01:00
|
|
|
|
|
|
|
TextboxCrewmatePosition crewmate_position;
|
|
|
|
TextboxOriginalContext original;
|
2020-01-01 21:29:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* TEXTBOX_H */
|