1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-14 06:39:17 +00:00
re3/src/render/Font.h

252 lines
6.4 KiB
C
Raw Normal View History

2019-05-22 18:28:53 +00:00
#pragma once
void AsciiToUnicode(const char *src, wchar *dst);
void UnicodeStrcpy(wchar *dst, const wchar *src);
void UnicodeStrcat(wchar *dst, wchar *append);
int UnicodeStrlen(const wchar *str);
2020-10-11 07:39:04 +00:00
void UnicodeMakeUpperCase(wchar *dst, const wchar *src);
2019-05-22 18:28:53 +00:00
struct CFontDetails
{
CRGBA color;
float scaleX;
float scaleY;
float slant;
float slantRefX;
float slantRefY;
bool justify;
bool centre;
bool rightJustify;
bool background;
bool backgroundOnlyText;
bool proportional;
2020-06-07 01:11:10 +00:00
bool bIsShadow;
bool bFlash;
bool bBold;
2019-05-22 18:28:53 +00:00
float alphaFade;
CRGBA backgroundColor;
float wrapX;
float centreSize;
float rightJustifyWrap;
int16 style;
2020-06-07 01:11:10 +00:00
bool bFontHalfTexture;
uint32 bank;
2019-05-22 18:28:53 +00:00
int16 dropShadowPosition;
CRGBA dropColor;
2020-06-07 07:43:33 +00:00
bool bFlashState;
2020-06-07 01:11:10 +00:00
int nFlashTimer;
2020-06-07 07:36:37 +00:00
bool anonymous_23;
2020-06-07 01:11:10 +00:00
uint32 anonymous_25;
};
struct CFontRenderState
{
uint32 anonymous_0;
float fTextPosX;
float fTextPosY;
2020-06-07 07:36:37 +00:00
float scaleX;
float scaleY;
2020-06-07 01:11:10 +00:00
CRGBA color;
float fExtraSpace;
2020-06-07 07:36:37 +00:00
float slant;
float slantRefX;
float slantRefY;
2020-06-07 01:11:10 +00:00
bool bIsShadow;
bool bFontHalfTexture;
2020-06-07 07:36:37 +00:00
bool proportional;
2020-06-07 01:11:10 +00:00
bool anonymous_14;
2020-06-07 07:36:37 +00:00
int16 style;
2019-05-22 18:28:53 +00:00
};
class CSprite2d;
2019-05-30 22:32:50 +00:00
enum {
2019-05-30 22:37:14 +00:00
FONT_BANK,
2020-06-07 01:20:02 +00:00
FONT_STANDARD,
2019-05-30 22:37:14 +00:00
FONT_HEADING,
2020-03-31 05:38:22 +00:00
#ifdef MORE_LANGUAGES
FONT_JAPANESE,
#endif
2020-06-07 07:36:37 +00:00
MAX_FONTS = FONT_HEADING
2019-05-30 22:32:50 +00:00
};
enum {
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT,
};
2020-03-29 06:35:13 +00:00
#ifdef MORE_LANGUAGES
enum
{
FONT_LANGSET_EFIGS,
2020-03-31 05:38:22 +00:00
FONT_LANGSET_RUSSIAN,
2020-04-19 19:32:59 +00:00
FONT_LANGSET_POLISH,
2020-04-26 20:49:24 +00:00
FONT_LANGSET_JAPANESE,
2020-04-19 19:32:59 +00:00
LANGSET_MAX
2020-03-29 06:35:13 +00:00
};
2020-04-26 20:49:24 +00:00
#define FONT_LOCALE(style) (CFont::IsJapanese() ? FONT_JAPANESE : style)
#else
#define FONT_LOCALE(style) (style)
#endif
2020-03-31 05:38:22 +00:00
2020-11-05 15:05:16 +00:00
#ifdef BUTTON_ICONS
enum
{
BUTTON_NONE = -1,
#if 0 // unused
BUTTON_UP,
BUTTON_DOWN,
BUTTON_LEFT,
BUTTON_RIGHT,
#endif
BUTTON_CROSS,
BUTTON_CIRCLE,
BUTTON_SQUARE,
BUTTON_TRIANGLE,
BUTTON_L1,
BUTTON_L2,
BUTTON_L3,
BUTTON_R1,
BUTTON_R2,
BUTTON_R3,
MAX_BUTTON_ICONS
};
#endif // BUTTON_ICONS
2019-05-22 18:28:53 +00:00
class CFont
{
2020-03-29 06:35:13 +00:00
#ifdef MORE_LANGUAGES
2020-04-19 19:32:59 +00:00
static int16 Size[LANGSET_MAX][MAX_FONTS][193];
2020-03-29 06:35:13 +00:00
static uint8 LanguageSet;
static int32 Slot;
#else
2020-06-07 01:11:10 +00:00
static int16 Size[MAX_FONTS][210];
2020-03-29 06:35:13 +00:00
#endif
2020-04-17 05:54:14 +00:00
static int16 NewLine;
2019-05-22 18:28:53 +00:00
public:
2020-05-23 23:59:30 +00:00
static CSprite2d Sprite[MAX_FONTS];
2020-04-17 05:54:14 +00:00
static CFontDetails Details;
2020-06-07 01:11:10 +00:00
static CFontRenderState RenderState;
2020-11-05 15:05:16 +00:00
#ifdef BUTTON_ICONS
2020-11-07 18:54:38 +00:00
static int32 ButtonsSlot;
2020-11-05 15:05:16 +00:00
static CSprite2d ButtonSprite[MAX_BUTTON_ICONS];
static int PS2Symbol;
static void DrawButton(float x, float y);
#endif // BUTTON_ICONS
2019-05-22 18:28:53 +00:00
static void Initialise(void);
static void Shutdown(void);
static void InitPerFrame(void);
2020-04-02 06:51:35 +00:00
static void PrintChar(float x, float y, wchar c);
static void PrintString(float x, float y, wchar *s);
2020-11-18 23:09:04 +00:00
#ifdef XBOX_SUBTITLES
static void PrintStringFromBottom(float x, float y, wchar *str);
static void PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor);
#endif
2020-04-02 06:51:35 +00:00
static int GetNumberLines(float xstart, float ystart, wchar *s);
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
2020-03-31 05:38:22 +00:00
#ifdef MORE_LANGUAGES
static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
#else
2020-06-07 07:36:37 +00:00
static void PrintString(float x, float y, uint32, wchar *start, wchar *end, float spwidth);
2020-03-31 05:38:22 +00:00
#endif
2020-06-07 07:36:37 +00:00
static void PrintStringFromBottom(float x, float y, wchar *str);
2020-04-02 06:51:35 +00:00
static float GetCharacterWidth(wchar c);
static float GetCharacterSize(wchar c);
static float GetStringWidth(wchar *s, bool spaces = false);
2020-04-26 20:49:24 +00:00
#ifdef MORE_LANGUAGES
static float GetStringWidth_Jap(wchar* s);
#endif
2020-03-31 05:38:22 +00:00
static uint16 *GetNextSpace(wchar *s);
#ifdef MORE_LANGUAGES
2020-06-07 02:12:01 +00:00
static uint16 *ParseToken(wchar *s, bool japShit = false);
2020-03-31 05:38:22 +00:00
#else
2020-06-07 02:12:01 +00:00
static uint16 *ParseToken(wchar *s);
static uint16* ParseToken(wchar *s, CRGBA &color, bool &flash, bool &bold);
2020-03-31 05:38:22 +00:00
#endif
2019-05-22 18:28:53 +00:00
static void DrawFonts(void);
2020-06-07 01:11:10 +00:00
static void RenderFontBuffer(void);
2020-03-31 05:38:22 +00:00
static uint16 character_code(uint8 c);
2019-05-22 18:28:53 +00:00
static CFontDetails GetDetails() { return Details; }
2020-03-31 05:38:22 +00:00
static void SetScale(float x, float y);
2019-05-22 18:28:53 +00:00
static void SetSlantRefPoint(float x, float y) { Details.slantRefX = x; Details.slantRefY = y; }
static void SetSlant(float s) { Details.slant = s; }
static void SetJustifyOn(void) {
Details.justify = true;
Details.centre = false;
Details.rightJustify = false;
}
static void SetJustifyOff(void) {
Details.justify = false;
Details.rightJustify = false;
}
static void SetRightJustifyOn(void) {
Details.rightJustify = true;
Details.justify = false;
Details.centre = false;
}
static void SetRightJustifyOff(void) {
Details.rightJustify = false;
Details.justify = false;
Details.centre = false;
}
static void SetCentreOn(void) {
Details.centre = true;
Details.justify = false;
Details.rightJustify = false;
}
static void SetCentreOff(void) {
Details.centre = false;
}
static void SetAlignment(uint8 alignment) {
if (alignment == ALIGN_LEFT) {
CFont::Details.justify = true;
CFont::Details.centre = false;
CFont::Details.rightJustify = false;
}
else if (alignment == ALIGN_CENTER) {
CFont::Details.justify = false;
CFont::Details.centre = true;
CFont::Details.rightJustify = false;
}
else if (alignment == ALIGN_RIGHT) {
CFont::Details.justify = false;
CFont::Details.centre = false;
CFont::Details.rightJustify = true;
}
}
2019-05-22 18:28:53 +00:00
static void SetWrapx(float x) { Details.wrapX = x; }
static void SetCentreSize(float s) { Details.centreSize = s; }
static void SetBackgroundOn(void) { Details.background = true; }
static void SetBackgroundOff(void) { Details.background = false; }
static void SetBackGroundOnlyTextOn(void) { Details.backgroundOnlyText = true; }
static void SetBackGroundOnlyTextOff(void) { Details.backgroundOnlyText = false; }
static void SetPropOn(void) { Details.proportional = true; }
static void SetPropOff(void) { Details.proportional = false; }
2020-06-07 07:36:37 +00:00
static void SetFontStyle(int16 style);
2019-05-22 18:28:53 +00:00
static void SetRightJustifyWrap(float wrap) { Details.rightJustifyWrap = wrap; }
static void SetAlphaFade(float fade) { Details.alphaFade = fade; }
static void SetDropShadowPosition(int16 pos) { Details.dropShadowPosition = pos; }
2020-04-26 20:49:24 +00:00
static void SetBackgroundColor(CRGBA col);
static void SetColor(CRGBA col);
static void SetDropColor(CRGBA col);
2020-06-07 01:11:10 +00:00
static wchar FindNewCharacter(wchar c);
static void FilterOutTokensFromString(wchar*);
2020-03-31 05:38:22 +00:00
#ifdef MORE_LANGUAGES
2020-03-29 06:35:13 +00:00
static void ReloadFonts(uint8 set);
2020-04-15 21:24:49 +00:00
// japanese stuff
static bool IsAnsiCharacter(wchar* s);
2020-04-26 20:49:24 +00:00
static bool IsJapanesePunctuation(wchar* str);
2020-04-15 21:24:49 +00:00
static bool IsJapanese() { return LanguageSet == FONT_LANGSET_JAPANESE; }
static bool IsJapaneseFont() { return IsJapanese() && (Details.style == FONT_JAPANESE || Details.style == FONT_PAGER); }
2020-03-31 05:38:22 +00:00
#endif
2019-05-22 18:28:53 +00:00
};