LeviLamina
Loading...
Searching...
No Matches
Font.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/math/Color.h"
8#include "mc/deps/core/math/Vec2.h"
9#include "mc/deps/core/utility/NonOwnerPointer.h"
10#include "mc/deps/minecraft_renderer/renderer/MaterialPtr.h"
11#include "mc/deps/minecraft_renderer/renderer/Mesh.h"
12#include "mc/deps/minecraft_renderer/renderer/TexturePtr.h"
13#include "mc/deps/minecraft_renderer/renderer/Type.h"
14
15// auto generated forward declare list
16// clang-format off
19class ScreenContext;
20class Tessellator;
22namespace Core { class Path; }
23namespace mce { class TextureGroup; }
24namespace mce::Font { struct RenderingParameters; }
25// clang-format on
26
27class Font : public ::std::enable_shared_from_this<::Font> {
28public:
29 // Font inner types declare
30 // clang-format off
31 struct GlyphQuad;
32 struct TextObject;
33 class TextObjectCache;
34 // clang-format on
35
36 // Font inner types define
37 struct GlyphQuad {
38 public:
39 // member variables
40 // NOLINTBEGIN
41 ::ll::TypedStorage<4, 8, ::Vec2> meshUpperLeft;
42 ::ll::TypedStorage<4, 8, ::Vec2> meshSize;
43 ::ll::TypedStorage<4, 8, ::Vec2> textureUpperLeft;
44 ::ll::TypedStorage<4, 8, ::Vec2> textureBottomRight;
45 ::ll::TypedStorage<4, 4, int> shear;
46 ::ll::TypedStorage<4, 16, ::mce::Color> color;
47 // NOLINTEND
48 };
49
50 struct TextObject {
51 public:
52 // TextObject inner types declare
53 // clang-format off
54 struct Page;
55 // clang-format on
56
57 // TextObject inner types define
58 struct Page {
59 public:
60 // member variables
61 // NOLINTBEGIN
62 ::ll::TypedStorage<8, 616, ::mce::Mesh> mMesh;
63 ::ll::TypedStorage<8, 32, ::mce::TexturePtr> mTexture;
64 ::ll::TypedStorage<4, 4, int> mSheet;
65 // NOLINTEND
66 };
67
68 public:
69 // member variables
70 // NOLINTBEGIN
71 ::ll::TypedStorage<8, 24, ::std::vector<::Font::TextObject::Page>> mPages;
72 ::ll::TypedStorage<4, 16, ::mce::Color> mColor;
73 ::ll::TypedStorage<1, 1, bool> mContainsUnicode;
74 ::ll::TypedStorage<1, 1, bool> mShadow;
75 // NOLINTEND
76
77 public:
78 // member functions
79 // NOLINTBEGIN
80 MCAPI void render(
81 ::ScreenContext& screenContext,
82 ::Font const& font,
83 ::mce::MaterialPtr const* optionalMat,
84 ::OffscreenCaptureDescription const& offscreenCaptureDescription
85 ) const;
86 // NOLINTEND
87 };
88
89 class TextObjectCache {
90 public:
91 // TextObjectCache inner types define
92 using TextObjects = ::std::vector<::std::shared_ptr<::Font::TextObject>>;
93
94 using TextObjectsPtr = ::std::shared_ptr<::std::vector<::std::shared_ptr<::Font::TextObject>>>;
95
96 public:
97 // member variables
98 // NOLINTBEGIN
99 ::ll::TypedStorage<
100 8,
101 16,
102 ::std::map<
103 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
104 ::std::shared_ptr<::std::vector<::std::shared_ptr<::Font::TextObject>>>,
105 ::std::less<void>>>
106 mEntries;
107 // NOLINTEND
108 };
109
110 using CurrentLineCallback = ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> const;
111
112 using StringCacheStoredKey = ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>;
113
114 using StringCacheLookupKey = ::std::tuple<::std::string_view, ::mce::Color, float, float, bool, bool>;
115
116public:
117 // member variables
118 // NOLINTBEGIN
119 ::ll::TypedStorage<4, 512, ::mce::Color[32]> mColors;
120 ::ll::TypedStorage<4, 4, float> mScalarOverride;
121 ::ll::TypedStorage<8, 24, ::std::vector<::std::tuple<int, int, float>>> mScaleOverrideCharacter;
122 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::mce::TextureGroup>> mTextureGroup;
123 ::ll::TypedStorage<8, 16, ::Font::TextObjectCache> mStringCache;
124 ::ll::TypedStorage<4, 4, int> mObfuscatedIndex;
125 ::ll::TypedStorage<4, 4, float> mObfuscatedTextTime;
126 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderPosition;
127 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderSize;
128 ::ll::TypedStorage<1, 1, bool> mAlwaysUnicode;
129 ::ll::TypedStorage<1, 1, bool> mAutoResetFormat;
130 ::ll::TypedStorage<1, 1, bool> mUseCache;
131 ::ll::TypedStorage<4, 16, ::mce::Color> mCurrentColor;
132 ::ll::TypedStorage<4, 4, int> mFontTexture;
133 ::ll::TypedStorage<4, 16, ::mce::Color> mCaretColor;
134 ::ll::TypedStorage<1, 1, bool> mItalic;
135 ::ll::TypedStorage<1, 1, bool> mBold;
136 ::ll::TypedStorage<1, 1, bool> mStrikethrough;
137 ::ll::TypedStorage<1, 1, bool> mUnderlined;
138 ::ll::TypedStorage<1, 1, bool> mObfuscated;
139 ::ll::TypedStorage<8, 16, ::mce::MaterialPtr> mFontMat;
140 // NOLINTEND
141
142public:
143 // prevent constructor by default
144 Font& operator=(Font const&);
145 Font();
146
147public:
148 // virtual functions
149 // NOLINTBEGIN
150 virtual ~Font();
151
152 virtual void switchFontsource(::Core::Path const& asciiName, ::Core::Path const& unicodeName) = 0;
153
154 virtual ::std::pair<::Core::PathBuffer<::std::string> const&, ::Core::PathBuffer<::std::string> const&>
155 getFontSources() const = 0;
156
157 virtual void fetchPage(int page);
158
159 virtual void drawCached(
160 ::ScreenContext& screenContext,
161 ::std::string_view str,
162 float x,
163 float y,
164 ::mce::Color const& color,
165 bool ignoreColorFormatting,
166 bool darken,
167 bool drawColorSymbol,
168 ::mce::MaterialPtr const* optionalMat,
169 int caretPosition,
170 bool shadow,
171 float linePadding,
172 ::mce::Color const& resetColorOverride,
173 ::mce::Color const& shaderDarkColor,
174 float outlineWidth,
175 float yCaretOffset,
176 ::OffscreenCaptureDescription const& offscreenCaptureDescription,
177 bool autoGenNormalsAndTangents
178 );
179
180 virtual bool supportsChar(int const& character) = 0;
181
182 virtual int getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
183
184 virtual float getWrapHeight() const = 0;
185
186 virtual float getScaleFactor() const = 0;
187
188 virtual float getScaleFactor(int uniChar) const;
189
190 virtual ::Vec2 getTranslationFactor() const;
191
192 virtual bool isScreenPixelAligned() const = 0;
193
194 virtual bool materialCanBeOverridden() const = 0;
195
196 virtual void uploadTextureToGPU() = 0;
197
198 virtual void setTextConstantsInScreenContext(
199 ::ScreenContext& screenContext,
200 int glyphSheet,
201 float guiScale,
202 ::mce::Color const& textColor,
203 bool hasShadow
204 ) const;
205
206 virtual ::mce::Font::Type getType(int glyphSheet) const;
207
208 virtual ::std::optional<::mce::Font::RenderingParameters> tryGetRenderingParameters(
209 ::ScreenContext const& screenContext,
210 int glyphSheet,
211 float guiScale,
212 ::mce::Color const& textColor,
213 bool hasShadow,
214 uint textureWidth,
215 uint textureHeight
216 ) const;
217
218 virtual void onAppSuspended();
219
220 virtual void onDeviceLost();
221
222 virtual void
223 reloadFontTextures(::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager, bool blockingLoad);
224
225 virtual bool isReloadingTextures();
226
227 virtual void unloadTextures();
228
229 virtual void onLanguageChanged(::std::string_view languageCode);
230
231 virtual float buildChar(
232 ::std::vector<::Font::GlyphQuad>& quads,
233 int i,
234 ::mce::Color const& color,
235 bool italic,
236 float x,
237 float y,
238 bool unicode
239 ) = 0;
240
241 virtual ::mce::MaterialPtr const& getMaterial(int sheet, bool isOddGuiScale) const = 0;
242
243 virtual void loadFontData(bool uploadTextureImmediately) = 0;
244
245 virtual int _getReplacementCharacter();
246
247 virtual bool _supportsShadowInSingleDraw() = 0;
248
249 virtual float _getCharWidth(int uniChar, bool forceUnicode) = 0;
250
251 virtual void _scanUnicodeCharacterSize(int character, int sheet, bool forceUnicode) = 0;
252
253 virtual ::ResourceLocation _getFontSheetLocation(int sheet, bool forceUnicode) const = 0;
254
255 virtual ::std::string _remapString(::std::string_view str) const;
256 // NOLINTEND
257
258public:
259 // member functions
260 // NOLINTBEGIN
261 MCAPI Font(::Font const& rhs);
262
263 MCAPI explicit Font(::std::shared_ptr<::mce::TextureGroup> textureGroup);
264
265 MCAPI bool _chopString(
266 ::std::string& currentLine,
267 ::std::string& activeFormatting,
268 float& totalHeight,
269 uint& remainingLineCount,
270 float maxWidth,
271 bool showColorSymbol,
272 bool centered,
273 float fontSize,
274 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> const currentLineCallback
275 );
276
277 MCAPI int _drawWordWrap(
278 ::ScreenContext& screenContext,
279 ::std::string_view str,
280 float x,
281 float y,
282 float w,
283 ::mce::Color const& color,
284 uint maxLine,
285 float fontSize,
286 bool shadow,
287 bool centered,
288 bool showColorSymbol,
289 ::mce::MaterialPtr* optionalMat
290 );
291
292 MCAPI ::std::shared_ptr<::Font::TextObject> _makeTextObject(
293 ::Tessellator& tessellator,
294 ::std::string_view str,
295 ::mce::Color const& ccolor,
296 bool showColorSymbol,
297 bool ignoreColorFormatting,
298 int caretPosition,
299 bool shadow,
300 float linePadding,
301 bool isOddGuiScale,
302 ::mce::Color const& resetColorOverride,
303 bool uiMaterial,
304 float outlineWidth,
305 float yCaretOffset,
306 bool autoGenNormalsAndTangents
307 );
308
309 MCAPI int _processHeightWrap(
310 ::std::string_view str,
311 float startX,
312 float startY,
313 float maxWidth,
314 uint maxLine,
315 bool showColorSymbol,
316 bool centered,
317 float fontSize,
318 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> currentLineCallback
319 );
320
321 MCAPI void calculateTextWidths(::std::string_view text, ::std::vector<int>& widths);
322
323 MCAPI void drawShadow(
324 ::ScreenContext& screenContext,
325 ::std::string_view str,
326 float x,
327 float y,
328 ::mce::Color const& color,
329 bool showColorSymbol,
330 ::mce::MaterialPtr* optionalMat,
331 float linePadding
332 );
333
334 MCAPI void drawTransformed(
335 ::ScreenContext& screenContext,
336 ::std::string_view str,
337 float x,
338 float y,
339 ::mce::Color const& color,
340 float angle,
341 float s,
342 bool centered,
343 float maxWidth,
344 bool shadow
345 );
346
347 MCAPI void drawWithColorResetOverride(
348 ::ScreenContext& screenContext,
349 ::std::string_view str,
350 float x,
351 float y,
352 ::mce::Color const& color,
353 ::mce::Color const& resetColor,
354 bool showColorSymbol,
355 ::mce::MaterialPtr* optionalMat,
356 int caretPosition,
357 float linePadding,
358 float yCaretOffset
359 );
360
361 MCAPI ::std::unordered_set<::ResourceLocation> const& getGlyphLocations() const;
362
363 MCAPI ::std::vector<::ResourceLocation> getReloadFontTextures() const;
364
365 MCAPI int processLinesInBox(
366 ::std::string_view str,
367 float maxWidth,
368 uint maxLines,
369 bool showColorSymbol,
370 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> currentLineCallback
371 );
372
373 MCAPI void resetFontData(bool uploadTextureImmediately);
374
375 MCAPI bool supportsString(::std::string_view str);
376 // NOLINTEND
377
378public:
379 // static variables
380 // NOLINTBEGIN
381 MCAPI static ::Core::PathBuffer<::std::string> const& NOT_FOUND_PAGE();
382
383 MCAPI static int const& UNICODE_REPLACEMENT_CHARACTER_CODE();
384 // NOLINTEND
385
386public:
387 // constructor thunks
388 // NOLINTBEGIN
389 MCAPI void* $ctor(::Font const& rhs);
390
391 MCAPI void* $ctor(::std::shared_ptr<::mce::TextureGroup> textureGroup);
392 // NOLINTEND
393
394public:
395 // destructor thunk
396 // NOLINTBEGIN
397 MCAPI void $dtor();
398 // NOLINTEND
399
400public:
401 // virtual function thunks
402 // NOLINTBEGIN
403 MCFOLD void $fetchPage(int page);
404
405 MCAPI void $drawCached(
406 ::ScreenContext& screenContext,
407 ::std::string_view str,
408 float x,
409 float y,
410 ::mce::Color const& color,
411 bool ignoreColorFormatting,
412 bool darken,
413 bool drawColorSymbol,
414 ::mce::MaterialPtr const* optionalMat,
415 int caretPosition,
416 bool shadow,
417 float linePadding,
418 ::mce::Color const& resetColorOverride,
419 ::mce::Color const& shaderDarkColor,
420 float outlineWidth,
421 float yCaretOffset,
422 ::OffscreenCaptureDescription const& offscreenCaptureDescription,
423 bool autoGenNormalsAndTangents
424 );
425
426 MCAPI int $getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
427
428 MCAPI float $getScaleFactor(int uniChar) const;
429
430 MCFOLD ::Vec2 $getTranslationFactor() const;
431
432 MCFOLD void $setTextConstantsInScreenContext(
433 ::ScreenContext& screenContext,
434 int glyphSheet,
435 float guiScale,
436 ::mce::Color const& textColor,
437 bool hasShadow
438 ) const;
439
440 MCFOLD ::mce::Font::Type $getType(int glyphSheet) const;
441
442 MCAPI ::std::optional<::mce::Font::RenderingParameters> $tryGetRenderingParameters(
443 ::ScreenContext const& screenContext,
444 int glyphSheet,
445 float guiScale,
446 ::mce::Color const& textColor,
447 bool hasShadow,
448 uint textureWidth,
449 uint textureHeight
450 ) const;
451
452 MCFOLD void $onAppSuspended();
453
454 MCFOLD void $onDeviceLost();
455
456 MCAPI void $reloadFontTextures(
457 ::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager,
458 bool blockingLoad
459 );
460
461 MCAPI bool $isReloadingTextures();
462
463 MCFOLD void $unloadTextures();
464
465 MCFOLD void $onLanguageChanged(::std::string_view languageCode);
466
467 MCAPI int $_getReplacementCharacter();
468
469 MCAPI ::std::string $_remapString(::std::string_view str) const;
470 // NOLINTEND
471
472public:
473 // vftables
474 // NOLINTBEGIN
475 MCNAPI static void** $vftable();
476 // NOLINTEND
477};
Definition Path.h:11
Definition Font.h:28
Definition Font.h:5
static MCAPI void ** $vftable()
Definition ResourceLoadManager.h:18
Definition ResourceLocation.h:15
Definition ScreenContext.h:5
Definition Tessellator.h:5
Definition TextureGroup.h:7
Definition Font.h:15
Definition Font.h:25
Definition Font.h:17
Definition OffscreenCaptureDescription.h:5
Definition RenderingParameters.h:7