2019-05-22 20:28:53 +02:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-19 13:35:48 +01:00
|
|
|
#include "Sprite2d.h"
|
|
|
|
|
2020-10-11 09:33:02 +02:00
|
|
|
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);
|
|
|
|
|
2019-05-22 20:28:53 +02:00
|
|
|
struct CFontDetails
|
|
|
|
{
|
|
|
|
CRGBA color;
|
|
|
|
float scaleX;
|
|
|
|
float scaleY;
|
|
|
|
float slant;
|
|
|
|
float slantRefX;
|
|
|
|
float slantRefY;
|
2021-01-16 15:05:27 +01:00
|
|
|
bool8 justify;
|
|
|
|
bool8 centre;
|
|
|
|
bool8 rightJustify;
|
|
|
|
bool8 background;
|
|
|
|
bool8 backgroundOnlyText;
|
|
|
|
bool8 proportional;
|
2019-05-22 20:28:53 +02:00
|
|
|
float alphaFade;
|
|
|
|
CRGBA backgroundColor;
|
|
|
|
float wrapX;
|
|
|
|
float centreSize;
|
|
|
|
float rightJustifyWrap;
|
|
|
|
int16 style;
|
|
|
|
int32 bank;
|
|
|
|
int16 dropShadowPosition;
|
|
|
|
CRGBA dropColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSprite2d;
|
|
|
|
|
2019-05-31 00:32:50 +02:00
|
|
|
enum {
|
2020-06-07 04:03:06 +02:00
|
|
|
FONT_BANK,
|
2019-05-31 00:37:14 +02:00
|
|
|
FONT_PAGER,
|
|
|
|
FONT_HEADING,
|
2020-03-31 07:38:22 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
FONT_JAPANESE,
|
|
|
|
#endif
|
2020-04-17 07:54:14 +02:00
|
|
|
MAX_FONTS
|
2019-05-31 00:32:50 +02:00
|
|
|
};
|
|
|
|
|
2019-06-25 02:34:29 +02:00
|
|
|
enum {
|
|
|
|
ALIGN_LEFT,
|
|
|
|
ALIGN_CENTER,
|
|
|
|
ALIGN_RIGHT,
|
|
|
|
};
|
|
|
|
|
2020-03-29 08:35:13 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FONT_LANGSET_EFIGS,
|
2020-03-31 07:38:22 +02:00
|
|
|
FONT_LANGSET_RUSSIAN,
|
2020-04-19 21:32:59 +02:00
|
|
|
FONT_LANGSET_POLISH,
|
2020-04-26 22:49:24 +02:00
|
|
|
FONT_LANGSET_JAPANESE,
|
2020-04-19 21:32:59 +02:00
|
|
|
LANGSET_MAX
|
2020-03-29 08:35:13 +02:00
|
|
|
};
|
|
|
|
|
2020-04-26 22:49:24 +02:00
|
|
|
#define FONT_LOCALE(style) (CFont::IsJapanese() ? FONT_JAPANESE : style)
|
|
|
|
#else
|
|
|
|
#define FONT_LOCALE(style) (style)
|
|
|
|
#endif
|
2020-03-31 07:38:22 +02:00
|
|
|
|
2020-11-05 16:05:16 +01: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 20:28:53 +02:00
|
|
|
class CFont
|
|
|
|
{
|
2020-03-29 08:35:13 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
2020-04-19 21:32:59 +02:00
|
|
|
static int16 Size[LANGSET_MAX][MAX_FONTS][193];
|
2020-03-29 08:35:13 +02:00
|
|
|
static uint8 LanguageSet;
|
|
|
|
static int32 Slot;
|
|
|
|
#else
|
2020-04-17 07:54:14 +02:00
|
|
|
static int16 Size[MAX_FONTS][193];
|
2020-03-29 08:35:13 +02:00
|
|
|
#endif
|
2021-01-16 15:05:27 +01:00
|
|
|
static bool16 NewLine;
|
2019-05-22 20:28:53 +02:00
|
|
|
public:
|
2020-08-03 03:00:12 +02:00
|
|
|
static CSprite2d Sprite[MAX_FONTS];
|
2020-04-17 07:54:14 +02:00
|
|
|
static CFontDetails Details;
|
2020-01-07 15:23:09 +01:00
|
|
|
|
2020-11-05 16:05:16 +01:00
|
|
|
#ifdef BUTTON_ICONS
|
2020-11-07 19:54:38 +01:00
|
|
|
static int32 ButtonsSlot;
|
2020-11-05 16:05:16 +01:00
|
|
|
static CSprite2d ButtonSprite[MAX_BUTTON_ICONS];
|
|
|
|
static int PS2Symbol;
|
|
|
|
|
2021-02-03 01:41:12 +01:00
|
|
|
static void LoadButtons(const char *txdPath);
|
2020-11-05 16:05:16 +01:00
|
|
|
static void DrawButton(float x, float y);
|
|
|
|
#endif // BUTTON_ICONS
|
|
|
|
|
|
|
|
|
2019-05-22 20:28:53 +02:00
|
|
|
static void Initialise(void);
|
|
|
|
static void Shutdown(void);
|
|
|
|
static void InitPerFrame(void);
|
2020-04-02 08:51:35 +02:00
|
|
|
static void PrintChar(float x, float y, wchar c);
|
|
|
|
static void PrintString(float x, float y, wchar *s);
|
2020-11-19 00:09:04 +01:00
|
|
|
static void PrintStringFromBottom(float x, float y, wchar *str);
|
2021-01-16 15:05:27 +01:00
|
|
|
#ifdef XBOX_SUBTITLES
|
2020-11-19 00:09:04 +01:00
|
|
|
static void PrintOutlinedString(float x, float y, wchar *str, float outlineStrength, bool fromBottom, CRGBA outlineColor);
|
|
|
|
#endif
|
2020-04-02 08:51:35 +02:00
|
|
|
static int GetNumberLines(float xstart, float ystart, wchar *s);
|
|
|
|
static void GetTextRect(CRect *rect, float xstart, float ystart, wchar *s);
|
2020-03-31 07:38:22 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
static bool PrintString(float x, float y, wchar *start, wchar* &end, float spwidth, float japX);
|
|
|
|
#else
|
2020-04-02 08:51:35 +02:00
|
|
|
static void PrintString(float x, float y, wchar *start, wchar *end, float spwidth);
|
2020-03-31 07:38:22 +02:00
|
|
|
#endif
|
2020-04-02 08:51:35 +02:00
|
|
|
static float GetCharacterWidth(wchar c);
|
|
|
|
static float GetCharacterSize(wchar c);
|
|
|
|
static float GetStringWidth(wchar *s, bool spaces = false);
|
2020-04-26 22:49:24 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
static float GetStringWidth_Jap(wchar* s);
|
|
|
|
#endif
|
2020-03-31 07:38:22 +02:00
|
|
|
static uint16 *GetNextSpace(wchar *s);
|
|
|
|
#ifdef MORE_LANGUAGES
|
|
|
|
static uint16 *ParseToken(wchar *s, wchar*, bool japShit = false);
|
|
|
|
#else
|
|
|
|
static uint16 *ParseToken(wchar *s, wchar*);
|
|
|
|
#endif
|
2019-05-22 20:28:53 +02:00
|
|
|
static void DrawFonts(void);
|
2020-03-31 07:38:22 +02:00
|
|
|
static uint16 character_code(uint8 c);
|
2019-05-22 20:28:53 +02:00
|
|
|
|
2020-03-31 07:38:22 +02:00
|
|
|
static void SetScale(float x, float y);
|
2021-01-16 15:05:27 +01:00
|
|
|
static void SetSlantRefPoint(float x, float y);
|
|
|
|
static void SetSlant(float s);
|
|
|
|
static void SetJustifyOn(void);
|
|
|
|
static void SetJustifyOff(void);
|
|
|
|
static void SetRightJustifyOn(void);
|
|
|
|
static void SetRightJustifyOff(void);
|
|
|
|
static void SetCentreOn(void);
|
|
|
|
static void SetCentreOff(void);
|
|
|
|
static void SetWrapx(float x);
|
|
|
|
static void SetCentreSize(float s);
|
|
|
|
static void SetBackgroundOn(void);
|
|
|
|
static void SetBackgroundOff(void);
|
|
|
|
static void SetBackGroundOnlyTextOn(void);
|
|
|
|
static void SetBackGroundOnlyTextOff(void);
|
|
|
|
static void SetPropOn(void);
|
|
|
|
static void SetPropOff(void);
|
|
|
|
static void SetFontStyle(int16 style);
|
|
|
|
static void SetRightJustifyWrap(float wrap);
|
|
|
|
static void SetAlphaFade(float fade);
|
|
|
|
static void SetDropShadowPosition(int16 pos);
|
2020-04-26 22:49:24 +02:00
|
|
|
static void SetBackgroundColor(CRGBA col);
|
|
|
|
static void SetColor(CRGBA col);
|
|
|
|
static void SetDropColor(CRGBA col);
|
2019-05-22 20:28:53 +02:00
|
|
|
|
2020-03-31 07:38:22 +02:00
|
|
|
#ifdef MORE_LANGUAGES
|
2020-03-29 08:35:13 +02:00
|
|
|
static void ReloadFonts(uint8 set);
|
2020-04-15 23:24:49 +02:00
|
|
|
|
|
|
|
// japanese stuff
|
|
|
|
static bool IsAnsiCharacter(wchar* s);
|
2020-04-26 22:49:24 +02:00
|
|
|
static bool IsJapanesePunctuation(wchar* str);
|
2020-04-15 23:24:49 +02: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 07:38:22 +02:00
|
|
|
#endif
|
2019-05-22 20:28:53 +02:00
|
|
|
};
|