11#include " ShulkerRenderer.h"
22
3- static HashedString flushString ( 0xA99285D21E94FC80 , " ui_flush " ) ;
3+ extern ItemStack shulkerInventory[ 27 ] ;
44
55// Texture loading
6- static auto itemSlotTexture = std::make_unique<mce::TexturePtr>();
6+ static HashedString flushString (0xA99285D21E94FC80 , " ui_flush" );
7+
8+ static const auto itemSlotTexture = std::make_unique<mce::TexturePtr>();
9+ static const auto backgroundTexture = std::make_unique<mce::TexturePtr>();
10+
711static ResourceLocation itemSlotLocation (" textures/gui/gui" );
12+ static ResourceLocation backgroundLocation (" textures/ui/purpleBorder" );
13+
814bool hasLoadedTexture = false ;
915
1016// Slot sizing
@@ -14,29 +20,28 @@ float borderSize = (slotSize - 16.f) / 2;
1420// Uv positions
1521glm::tvec2<float > itemSlotUvPos (188 .0f / 256 .0f , 184 .0f / 256 .0f );
1622glm::tvec2<float > itemSlotUvSize (22 .0f / 256 .0f , 22 .0f / 256 .0f );
17-
18- extern ItemStack shulkerInventory[27 ];
19-
20- mce::Color panelBackground (27 .0f / 255 .0f , 12 .0f / 255 .0f , 27 .0f / 255 .0f , 1 .0f );
23+ Amethyst::NinesliceHelper backgroundNineslice (16 , 16 , 4 , 4 );
2124
2225void ShulkerRenderer::Render (UIRenderContext* ctx, HoverRenderer* hoverRenderer) {
23- if (ctx == nullptr || ctx->mClient ->getLocalPlayer () == nullptr ) return ;
24-
2526 // Only load inventory resources once
2627 if (!hasLoadedTexture) {
2728 ctx->getTexture (itemSlotTexture.get (), &itemSlotLocation, true );
29+ ctx->getTexture (backgroundTexture.get (), &backgroundLocation, true );
2830 hasLoadedTexture = true ;
2931 }
3032
31- float textHeight = 20 .0f ;
33+ float textHeight = 30 .0f ;
3234 float panelWidth = slotSize * 9 ;
3335 float panelHeight = slotSize * 3 + textHeight;
3436
3537 float panelX = hoverRenderer->mCursorPosition .x + hoverRenderer->mOffset .x ;
3638 float panelY = hoverRenderer->mCursorPosition .y + hoverRenderer->mOffset .y ;
3739
38- RectangleArea background = {panelX, panelX + panelWidth, panelY, panelY + panelHeight};
39- ctx->drawRectangle (&background, &panelBackground, 1 .0f , 1 );
40+ // Draw the background panel
41+ // RectangleArea background = {panelX, panelX + panelWidth, panelY, panelY + panelHeight};
42+ RectangleArea background = {panelX - 4 , panelX + panelWidth + 4 , panelY - 4 , panelY + panelHeight + 4 };
43+ backgroundNineslice.Draw (background, backgroundTexture.get (), ctx);
44+ ctx->flushImages (mce::Color::WHITE, 1 .0f , flushString);
4045
4146 // Draw the item slots
4247 for (int x = 0 ; x < 9 ; x++) {
@@ -98,7 +103,8 @@ void ShulkerRenderer::Render(UIRenderContext* ctx, HoverRenderer* hoverRenderer)
98103
99104 ctx->flushText (0 .0f );
100105
106+ RectangleArea textArea = { panelX, panelX + panelWidth, panelY, panelY + textHeight };
101107 RectangleArea rect = { panelX, panelX + panelWidth, panelY, panelY + panelHeight };
102- ctx->drawDebugText (&background , &hoverRenderer->mFilteredContent , &mce::Color::WHITE, 1 .0f , ui::Left, &textData, &caretData);
108+ ctx->drawDebugText (&textArea , &hoverRenderer->mFilteredContent , &mce::Color::WHITE, 1 .0f , ui::Left, &textData, &caretData);
103109 ctx->flushText (0 .0f );
104110}
0 commit comments