|
| 1 | +/***************************************************************************** |
| 2 | + * |
| 3 | + * PROJECT: Multi Theft Auto |
| 4 | + * LICENSE: See LICENSE in the top level directory |
| 5 | + * FILE: game_sa/CFontSA.cpp |
| 6 | + * PURPOSE: Font class layer |
| 7 | + * |
| 8 | + * Multi Theft Auto is available from https://www.multitheftauto.com/ |
| 9 | + * |
| 10 | + *****************************************************************************/ |
| 11 | + |
| 12 | +#include "StdInc.h" |
| 13 | +#include "CFontSA.h" |
| 14 | + |
| 15 | +void CFontSA::PrintChar(float x, float y, char character) |
| 16 | +{ |
| 17 | + // Call CFont::PrintChar |
| 18 | + ((void(_cdecl*)(float, float, char))0x718A10)(x, y, character); |
| 19 | +} |
| 20 | + |
| 21 | +void CFontSA::PrintString(float x, float y, const char* text) |
| 22 | +{ |
| 23 | + // Call CFont::PrintString |
| 24 | + ((void(__cdecl*)(float, float, const char*))0x71A700)(x, y, text); |
| 25 | +} |
| 26 | + |
| 27 | +void CFontSA::PrintStringFromBottom(float x, float y, const char* text) |
| 28 | +{ |
| 29 | + // Call CFont::PrintStringFromBottom |
| 30 | + ((void(__cdecl*)(float, float, const char*))0x71A820)(x, y, text); |
| 31 | +} |
| 32 | + |
| 33 | +void CFontSA::SetScale(float w, float h) |
| 34 | +{ |
| 35 | + // Call CFont::SetScale |
| 36 | + ((void(__cdecl*)(float, float))0x719380)(w, h); |
| 37 | +} |
| 38 | + |
| 39 | +void CFontSA::SetScale(const CVector2D& scale) |
| 40 | +{ |
| 41 | + SetScale(scale.fX, scale.fY); |
| 42 | +} |
| 43 | + |
| 44 | +void CFontSA::SetScaleForCurrentLanguage(float w, float h) |
| 45 | +{ |
| 46 | + // Call CFont::SetScaleForCurrentLanguage |
| 47 | + ((void(__cdecl*)(float, float))0x7193A0)(w, h); |
| 48 | +} |
| 49 | + |
| 50 | +void CFontSA::SetSlantRefPoint(float x, float y) |
| 51 | +{ |
| 52 | + // Call CFont::SetSlantRefPoint |
| 53 | + ((void(__cdecl*)(float, float))0x719400)(x, y); |
| 54 | +} |
| 55 | + |
| 56 | +void CFontSA::SetSlant(float slant) |
| 57 | +{ |
| 58 | + // Call CFont::SetSlant |
| 59 | + ((void(__cdecl*)(float))0x719420)(slant); |
| 60 | +} |
| 61 | + |
| 62 | +void CFontSA::SetColor(const RwColor& color) |
| 63 | +{ |
| 64 | + // Call CFont::SetColor |
| 65 | + ((void(__cdecl*)(RwColor))0x719430)(color); |
| 66 | +} |
| 67 | + |
| 68 | +void CFontSA::SetDropColor(const RwColor& color) |
| 69 | +{ |
| 70 | + // Call CFont::SetDropColor |
| 71 | + ((void(__cdecl*)(RwColor))0x719510)(color); |
| 72 | +} |
| 73 | + |
| 74 | +void CFontSA::SetFontStyle(const eFontStyle& style) |
| 75 | +{ |
| 76 | + // Call CFont::SetFontStyle |
| 77 | + ((void(__cdecl*)(eFontStyle))0x719490)(style); |
| 78 | +} |
| 79 | + |
| 80 | +void CFontSA::SetWrapX(float wrapx) |
| 81 | +{ |
| 82 | + // Call CFont::SetWrapx |
| 83 | + ((void(__cdecl*)(float))0x7194D0)(wrapx); |
| 84 | +} |
| 85 | + |
| 86 | +void CFontSA::SetRightJustifyWrap(float wrap) |
| 87 | +{ |
| 88 | + // Call CFont::SetRightJustifyWrap |
| 89 | + ((void(__cdecl*)(float))0x7194F0)(wrap); |
| 90 | +} |
| 91 | + |
| 92 | +void CFontSA::SetCentreSize(float size) |
| 93 | +{ |
| 94 | + // Call CFont::SetCentreSize |
| 95 | + ((void(__cdecl*)(float))0x7194E0)(size); |
| 96 | +} |
| 97 | + |
| 98 | +void CFontSA::SetDropShadowPosition(std::int16_t offset) |
| 99 | +{ |
| 100 | + // Call CFont::SetDropShadowPosition |
| 101 | + ((void(__cdecl*)(std::int16_t))0x719570)(offset); |
| 102 | +} |
| 103 | + |
| 104 | +void CFontSA::SetEdge(std::int16_t edgeSize) |
| 105 | +{ |
| 106 | + // Call CFont::SetEdge |
| 107 | + ((void(__cdecl*)(std::int16_t))0x719590)(edgeSize); |
| 108 | +} |
| 109 | + |
| 110 | +void CFontSA::SetProportional(bool enable) |
| 111 | +{ |
| 112 | + // Call CFont::SetProportional |
| 113 | + ((void(__cdecl*)(bool))0x7195B0)(enable); |
| 114 | +} |
| 115 | + |
| 116 | +void CFontSA::SetBackground(bool enable, bool includeWrap) |
| 117 | +{ |
| 118 | + // Call CFont::SetBackground |
| 119 | + ((void(__cdecl*)(bool, bool))0x7195C0)(enable, includeWrap); |
| 120 | +} |
| 121 | + |
| 122 | +void CFontSA::SetBackgroundColor(const RwColor& color) |
| 123 | +{ |
| 124 | + // Call CFont::SetBackgroundColor |
| 125 | + ((void(__cdecl*)(RwColor))0x7195E0)(color); |
| 126 | +} |
| 127 | + |
| 128 | +void CFontSA::SetJustify(bool enable) |
| 129 | +{ |
| 130 | + // Call CFont::SetJustify |
| 131 | + ((void(__cdecl*)(bool))0x719600)(enable); |
| 132 | +} |
| 133 | + |
| 134 | +void CFontSA::SetOrientation(const eFontAlignment& alignment) |
| 135 | +{ |
| 136 | + // Call CFont::SetOrientation |
| 137 | + ((void(__cdecl*)(eFontAlignment))0x719610)(alignment); |
| 138 | +} |
| 139 | + |
| 140 | +float CFontSA::GetStringWidth(const char* string, bool spaces, bool scriptValues) |
| 141 | +{ |
| 142 | + // Call CFont::GetStringWidth |
| 143 | + return ((float(__cdecl*)(const char*, bool, bool))0x71A0E0)(string, spaces, scriptValues); |
| 144 | +} |
| 145 | + |
| 146 | +std::int16_t CFontSA::GetNumberLines(float x, float y, const char* text) |
| 147 | +{ |
| 148 | + // Call CFont::GetNumberLines |
| 149 | + return ((std::int16_t(__cdecl*)(float, float, const char*))0x71A5E0)(x, y, text); |
| 150 | +} |
| 151 | + |
| 152 | +float CFontSA::GetFontHeight(float scaleY) |
| 153 | +{ |
| 154 | + return scaleY * 16.0f + scaleY * 2.0f; |
| 155 | +} |
| 156 | + |
| 157 | +eFontAlignment CFontSA::GetOrientation() |
| 158 | +{ |
| 159 | + bool centerAlign = *reinterpret_cast<bool*>(VAR_CFont_CenterAlign); |
| 160 | + bool rightAlign = *reinterpret_cast<bool*>(VAR_CFont_RightAlign); |
| 161 | + |
| 162 | + if (centerAlign) |
| 163 | + return eFontAlignment::ALIGN_CENTER; |
| 164 | + else if (rightAlign) |
| 165 | + return eFontAlignment::ALIGN_RIGHT; |
| 166 | + |
| 167 | + return eFontAlignment::ALIGN_LEFT; |
| 168 | +} |
| 169 | + |
| 170 | +eFontStyle CFontSA::GetFontStyle() |
| 171 | +{ |
| 172 | + std::uint8_t style = *reinterpret_cast<std::uint8_t*>(VAR_CFont_FontStyle); |
| 173 | + |
| 174 | + switch (style) |
| 175 | + { |
| 176 | + case 0: |
| 177 | + return *reinterpret_cast<eFontStyle*>(VAR_CFont_TextureID); |
| 178 | + case 1: |
| 179 | + return eFontStyle::FONT_PRICEDOWN; |
| 180 | + case 2: |
| 181 | + return eFontStyle::FONT_MENU; |
| 182 | + } |
| 183 | +} |
0 commit comments