From 9e21e4b47f34eae113f1df105228dac4b0bfab0d Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Sat, 27 Dec 2025 19:31:14 +0200 Subject: [PATCH] Added error line separator for hover info --- .../interpreter/hover/TokenHoverRenderer.java | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverRenderer.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverRenderer.java index 7b8105445..4c5cc0c0b 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverRenderer.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverRenderer.java @@ -160,6 +160,12 @@ public class TokenHoverRenderer { int textX = x + PADDING; int currentY = y + PADDING; int lineHeight = ClientProxy.Font.height(); + + + String packageName = info.getPackageName(); + List declaration = info.getDeclaration(); + List docs = info.getDocumentation(); + List additionalInfo = info.getAdditionalInfo(); // Draw errors first List errors = info.getErrors(); @@ -171,11 +177,18 @@ public class TokenHoverRenderer { currentY += lineHeight + LINE_SPACING; } } + boolean onlyErrors = errors != null && !errors.isEmpty() && (packageName == null || packageName.isEmpty()) && (declaration == null || + declaration.isEmpty()) && (docs == null || docs.isEmpty()) && (additionalInfo == null || additionalInfo.isEmpty()); + + if (!onlyErrors) { //Add error separator line + currentY += SEPARATOR_HEIGHT + SEPARATOR_SPACING - 5; + Gui.drawRect(textX, currentY, x + boxWidth - PADDING, currentY + SEPARATOR_HEIGHT, BORDER_COLOR); + currentY += SEPARATOR_HEIGHT + SEPARATOR_SPACING; + } currentY += LINE_SPACING; } // Draw package name - String packageName = info.getPackageName(); if (packageName != null && !packageName.isEmpty()) { String packageText = "\u25CB " + packageName; List wrappedLines = wrapText(packageText, wrapWidth); @@ -186,13 +199,11 @@ public class TokenHoverRenderer { } // Draw declaration (colored segments with wrapping) - List declaration = info.getDeclaration(); if (!declaration.isEmpty()) { currentY = drawWrappedSegments(textX, currentY, wrapWidth, declaration); currentY += LINE_SPACING; } // Draw documentation - List docs = info.getDocumentation(); if (!docs.isEmpty()) { // Draw separator line before documentation Gui.drawRect(textX, currentY, x + boxWidth - PADDING, currentY + SEPARATOR_HEIGHT, BORDER_COLOR); @@ -207,7 +218,7 @@ public class TokenHoverRenderer { } // Draw additional info - List additionalInfo = info.getAdditionalInfo(); + if (!additionalInfo.isEmpty()) { currentY += LINE_SPACING; for (String infoLine : additionalInfo) { @@ -374,7 +385,12 @@ public class TokenHoverRenderer { private static int calculateContentHeight(TokenHoverInfo info, int contentWidth) { int lineHeight = ClientProxy.Font.height(); int totalHeight = 0; - + + String packageName = info.getPackageName(); + List declaration = info.getDeclaration(); + List docs = info.getDocumentation(); + List additionalInfo = info.getAdditionalInfo(); + // Errors List errors = info.getErrors(); if (!errors.isEmpty()) { @@ -382,11 +398,17 @@ public class TokenHoverRenderer { List wrappedLines = wrapText(error, contentWidth); totalHeight += wrappedLines.size() * (lineHeight + LINE_SPACING); } + + boolean onlyErrors = errors != null && !errors.isEmpty() && (packageName == null || packageName.isEmpty()) && (declaration == null || + declaration.isEmpty()) && (docs == null || docs.isEmpty()) && (additionalInfo == null || additionalInfo.isEmpty()); + + if (!onlyErrors) //Add error separator height + totalHeight += (SEPARATOR_SPACING + SEPARATOR_HEIGHT) * 2 - 5; + totalHeight += LINE_SPACING; // Extra space after errors } // Package name - String packageName = info.getPackageName(); if (packageName != null && !packageName.isEmpty()) { String packageText = "\u25CB " + packageName; List wrappedLines = wrapText(packageText, contentWidth); @@ -394,14 +416,12 @@ public class TokenHoverRenderer { } // Declaration (colored segments with wrapping) - List declaration = info.getDeclaration(); if (!declaration.isEmpty()) { totalHeight += calculateSegmentsHeight(contentWidth, declaration); totalHeight += LINE_SPACING; } // Documentation - List docs = info.getDocumentation(); if (!docs.isEmpty()) { // Add space for separator line and spacing totalHeight += SEPARATOR_SPACING + SEPARATOR_HEIGHT; @@ -412,7 +432,6 @@ public class TokenHoverRenderer { } // Additional info - List additionalInfo = info.getAdditionalInfo(); if (!additionalInfo.isEmpty()) { totalHeight += LINE_SPACING; for (String infoLine : additionalInfo) {