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