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