1+ #pragma once
2+ #include < cstdint>
3+ #include < glm/glm.hpp>
4+ #include < gsl/gsl>
5+
6+ #include < api/mc/client/ClientInstance.hpp>
7+
8+ #pragma pack(push, 4)
9+ struct RectangleArea {
10+ float _x0;
11+ float _x1;
12+ float _y0;
13+ float _y1;
14+ };
15+ #pragma pack(pop)
16+
17+ namespace mce {
18+ class Color {
19+ public:
20+ float r;
21+ float g;
22+ float b;
23+ float a;
24+
25+ Color (float r, float g, float b, float a)
26+ {
27+ this ->r = r;
28+ this ->g = g;
29+ this ->b = b;
30+ this ->a = a;
31+ }
32+
33+ Color (unsigned int color)
34+ {
35+ this ->r = (float )((color & 0xFF000000 ) >> 24 ) / 255 .0f ;
36+ this ->g = (float )((color & 0x00FF0000 ) >> 16 ) / 255 .0f ;
37+ this ->b = (float )((color & 0x0000FF00 ) >> 8 ) / 255 .0f ;
38+ this ->a = (float )((color & 0x000000FF )) / 255 .0f ;
39+ }
40+
41+ Color ()
42+ {
43+ this ->r = 0 .0f ;
44+ this ->g = 0 .0f ;
45+ this ->b = 0 .0f ;
46+ this ->a = 0 .0f ;
47+ }
48+
49+ uint32_t As32 () const
50+ {
51+ struct PackedColors {
52+ union {
53+ struct {
54+ char r;
55+ char g;
56+ char b;
57+ char a;
58+ };
59+ unsigned int intValue;
60+ };
61+ };
62+
63+ PackedColors result{};
64+ result.r = static_cast <char >(this ->r * 255 .0f );
65+ result.g = static_cast <char >(this ->g * 255 .0f );
66+ result.b = static_cast <char >(this ->b * 255 .0f );
67+ result.a = static_cast <char >(this ->a * 255 .0f );
68+
69+ return result.intValue ;
70+ }
71+ };
72+
73+ class TexturePtr ;
74+ };
75+
76+ class Font ;
77+ class NinesliceInfo ;
78+ class HashedString ;
79+ class ComponentRenderBatch ;
80+ class CustomRenderComponent ;
81+ class ResourceLocation ;
82+
83+ namespace Core {
84+ class Path ;
85+ };
86+
87+ class TextMeasureData ;
88+ class CaretMeasureData ;
89+
90+ namespace ui {
91+ class TextAlignment ;
92+ };
93+
94+ class MinecraftUIRenderContext {
95+ public:
96+ MinecraftUIRenderContext (ClientInstance& client, void * screenContext, void * currentScene);
97+ virtual ~MinecraftUIRenderContext ();
98+ virtual float getLineLength (Font& font, const std::string& text, float fontSize, bool showColorSymbol);
99+ virtual float getTextAlpha ();
100+ virtual void setTextAlpha (float alpha);
101+ virtual void drawDebugText (const RectangleArea& rect, const std::string& text, const mce::Color& color, float alpha, ui::TextAlignment alignment, const TextMeasureData& textData, const CaretMeasureData& caretData);
102+ virtual void drawText (Font& font, const RectangleArea& rect, const std::string& text, const mce::Color& color, float alpha, ui::TextAlignment alignment, const TextMeasureData& textData, const CaretMeasureData& caretData);
103+ virtual void flushText (float deltaTime);
104+ virtual void drawImage (const mce::TexturePtr& texture, const glm::tvec2<float >& position, const glm::tvec2<float >& size, glm::tvec2<float >& uv, glm::tvec2<float >& uvSize, int degree);
105+ virtual void drawNineslice (const mce::TexturePtr& texture, const NinesliceInfo& nineslice);
106+ virtual void flushImages (const mce::Color& color, float alpha, const HashedString& materialNameHash);
107+ virtual void beginSharedMeshBatch (ComponentRenderBatch& renderBatch);
108+ virtual void endSharedMeshBatch (ComponentRenderBatch& renderBatch);
109+ virtual void drawRectangle (const RectangleArea& rect, const mce::Color& color, float alpha, int thickness);
110+ virtual void fillRectangle (const RectangleArea& rect, const mce::Color& color, float alpha);
111+ virtual void increaseStencilRef ();
112+ virtual void decreaseStencilRef ();
113+ virtual void resetStencilRef ();
114+ virtual void fillRectangleStencil (const RectangleArea& rect);
115+ virtual void enableScissorTest (const RectangleArea& rect);
116+ virtual void disableScissorTest ();
117+ virtual void setClippingRectangle (const RectangleArea& rect);
118+ virtual void setFullClippingRectangle ();
119+ virtual void saveCurrentClippingRectangle ();
120+ virtual void restoreSavedClippingRectangle ();
121+ virtual RectangleArea getFullClippingRectangle ();
122+ virtual bool updateCustom (gsl::not_null<CustomRenderComponent*> customRenderer);
123+ virtual void renderCustom (gsl::not_null<CustomRenderComponent*> customRenderer, int pass, RectangleArea& renderAABB);
124+ virtual void cleanup ();
125+ virtual void removePersistentMeshes ();
126+ virtual mce::TexturePtr getTexture (const ResourceLocation& resourceLocation, bool forceReload);
127+ virtual mce::TexturePtr getZippedTexture (const Core::Path& zippedFolderPath, const ResourceLocation& resourceLocation, bool forceReload);
128+ virtual void unloadTexture (ResourceLocation const &);
129+ };
0 commit comments