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