mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 09:54:10 +03:00
Save special text box state using functions
This adds a way to save the text box state of the crew remaining, ACTION prompt, etc. text boxes by just letting there be a function that is called to retranslate the text box when needed. It also adds a way to ignore translating a text box and to leave it alone, in case there's actually no text in the text box, which is the case with Level Complete and Game Complete. Both ways are now in an enum, TextboxTranslate. The former is TEXTTRANSLATE_FUNCTION and the latter is TEXTTRANSLATE_NONE. The existing way of translating text boxes became TEXTTRANSLATE_CUTSCENE, since it's only used for cutscene scripts. Here's a quick guide to the three ways of creating a text box now. - TEXTTRANSLATE_NONE: You must call graphics.textboxoriginalcontextauto() to save the existing text to the original context of the text box, as that will be copied back to the text box after the text of the text box is updated due to not having a translation. - TEXTTRANSLATE_CUTSCENE: Translates the text from cutscenes.xml, and overrides the spacing (padding and text centering). Shouldn't need to be used outside of scriptclass. - TEXTTRANSLATE_FUNCTION: You must pass in a function that takes in a single parameter, a pointer to the textboxclass object to be modified. General advice when retranslating text is to clear the `lines` vector and then push_back the retranslated text. The function is also solely responsible for spacing. In most cases, you will also need to call graphics.textboxapplyposition() or graphics.textboxadjust() afterwards. (Some text boxes shouldn't use graphics.textboxadjust() as they are within the 10-pixel inner border around the screen that textboxclass::adjust tries to push the text box out of.) This commit doesn't fix every text box just yet, though. But it fixes the Level Complete, Game Complete, crew remaining, and ACTION prompt text boxes, for a start.
This commit is contained in:
@@ -24,6 +24,15 @@ struct TextboxOriginalContext
|
||||
char text_case;
|
||||
};
|
||||
|
||||
/* Similar to, but NOT the same as a loc::TextboxFormat. */
|
||||
struct TextboxSpacing
|
||||
{
|
||||
bool centertext;
|
||||
unsigned char pad_left;
|
||||
unsigned char pad_right;
|
||||
unsigned short padtowidth;
|
||||
};
|
||||
|
||||
struct TextboxSprite
|
||||
{
|
||||
int x;
|
||||
@@ -39,6 +48,16 @@ enum TextboxImage
|
||||
TEXTIMAGE_GAMECOMPLETE
|
||||
};
|
||||
|
||||
enum TextboxTranslate
|
||||
{
|
||||
TEXTTRANSLATE_NONE,
|
||||
TEXTTRANSLATE_CUTSCENE,
|
||||
TEXTTRANSLATE_FUNCTION
|
||||
};
|
||||
|
||||
class textboxclass;
|
||||
typedef void (*TextboxFunction)(textboxclass* THIS);
|
||||
|
||||
class textboxclass
|
||||
{
|
||||
public:
|
||||
@@ -52,6 +71,8 @@ public:
|
||||
|
||||
void centery(void);
|
||||
|
||||
void applyposition(void);
|
||||
|
||||
void adjust(void);
|
||||
|
||||
void initcol(int rr, int gg, int bb);
|
||||
@@ -74,7 +95,13 @@ public:
|
||||
|
||||
void centertext(void);
|
||||
|
||||
void translate(void);
|
||||
void copyoriginaltext(void);
|
||||
|
||||
void applyoriginalspacing(void);
|
||||
|
||||
void updatetext(void);
|
||||
|
||||
void translatecutscene(void);
|
||||
public:
|
||||
//Fundamentals
|
||||
std::vector<std::string> lines;
|
||||
@@ -98,6 +125,7 @@ public:
|
||||
bool should_centery;
|
||||
|
||||
uint32_t print_flags;
|
||||
TextboxTranslate translate;
|
||||
bool fill_buttons;
|
||||
|
||||
std::vector<TextboxSprite> sprites;
|
||||
@@ -105,6 +133,8 @@ public:
|
||||
|
||||
TextboxCrewmatePosition crewmate_position;
|
||||
TextboxOriginalContext original;
|
||||
TextboxSpacing spacing;
|
||||
TextboxFunction function;
|
||||
};
|
||||
|
||||
#endif /* TEXTBOX_H */
|
||||
|
||||
Reference in New Issue
Block a user