Skip to content

Commit 32816b7

Browse files
committed
Adjusted Enchantment Handler UI
1 parent d79fdd9 commit 32816b7

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/main/java/net/wurstclient/hacks/EnchantmentHandlerHack.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ private void renderOverlay(DrawContext context)
278278
int headerMargin = Math.max(1, Math.round(HEADER_MARGIN * scale));
279279
int entryMargin = Math.max(1, Math.round(ENTRY_MARGIN * scale));
280280

281-
int titleY = panelY + PANEL_PADDING;
282-
int titleX = panelX + PANEL_PADDING;
283-
int titleHeight = Math.max(1, Math.round(tr.fontHeight * scale));
284-
285281
context.fill(panelX, panelY, panelX + panelWidth, panelY + panelHeight,
286282
0xC0101010);
287283
context.fill(panelX, panelY, panelX + panelWidth, panelY + 1,
@@ -293,10 +289,8 @@ private void renderOverlay(DrawContext context)
293289
context.fill(panelX + panelWidth - 1, panelY, panelX + panelWidth,
294290
panelY + panelHeight, 0xFF202020);
295291

296-
drawScaledText(context, tr, "Enchantment Handler", titleX, titleY,
297-
TITLE_COLOR, scale);
298-
299-
int contentTop = titleY + titleHeight + headerMargin + 1;
292+
int contentTop = panelY + PANEL_PADDING;
293+
int titleX = panelX + PANEL_PADDING;
300294
int contentBottom = panelY + panelHeight - PANEL_PADDING;
301295
int innerHeight = contentBottom - contentTop;
302296
if(innerHeight <= 0)
@@ -355,7 +349,11 @@ private double renderGearSection(DrawContext context, TextRenderer tr,
355349
int sectionTitleY = (int)Math.round(cursorY - offset);
356350
drawScaledText(context, tr, "Enchanted Gear", titleX, sectionTitleY,
357351
TITLE_COLOR, scale);
358-
cursorY += lineHeight + headerMargin;
352+
int underlineY = sectionTitleY
353+
+ Math.max(1, Math.round(MC.textRenderer.fontHeight * scale)) + 2;
354+
context.fill(panelX + 2, underlineY, panelX + panelWidth - 2,
355+
underlineY + 1, 0xFFD0D0D0);
356+
cursorY += lineHeight + headerMargin + 4;
359357

360358
for(GearCategory category : GearCategory.ORDERED)
361359
{
@@ -388,7 +386,11 @@ private double renderBookSection(DrawContext context, TextRenderer tr,
388386
int sectionTitleY = (int)Math.round(cursorY - offset);
389387
drawScaledText(context, tr, "Enchanted Books", titleX, sectionTitleY,
390388
TITLE_COLOR, scale);
391-
cursorY += lineHeight + headerMargin;
389+
int underlineY = sectionTitleY
390+
+ Math.max(1, Math.round(MC.textRenderer.fontHeight * scale)) + 2;
391+
context.fill(panelX + 2, underlineY, panelX + panelWidth - 2,
392+
underlineY + 1, 0xFFD0D0D0);
393+
cursorY += lineHeight + headerMargin + 4;
392394

393395
for(BookCategory category : BookCategory.ORDERED)
394396
{
@@ -504,6 +506,19 @@ else if(cyclePos <= travel + HOVER_SCROLL_PAUSE)
504506
return cursorY;
505507
}
506508

509+
private void drawSectionHeader(DrawContext context, TextRenderer tr, int x,
510+
int y, String text, float scale)
511+
{
512+
int textWidth = Math.max(1, Math.round(tr.getWidth(text) * scale));
513+
int textHeight = Math.max(1, Math.round(tr.fontHeight * scale));
514+
int left = Math.round(x - 4);
515+
int right = Math.round(x + textWidth + 4);
516+
int top = Math.round(y - 4);
517+
int bottom = Math.round(y + textHeight + 4);
518+
context.fill(left, top, right, bottom, 0xC0282828);
519+
drawScaledText(context, tr, text, x, y, TITLE_COLOR, scale);
520+
}
521+
507522
private void rescan(GenericContainerScreen screen)
508523
{
509524
refreshEntries(screen.getScreenHandler());

0 commit comments

Comments
 (0)