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