From 516304449427f2aae1e5a1f1f5dd4bb5185bf3fd Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Sun, 4 Jan 2026 00:55:50 +0200 Subject: [PATCH] Added args to autocomplete methods and highlighted them in dark gray --- .../script/autocomplete/AutocompleteItem.java | 23 +++++++++++-- .../script/autocomplete/AutocompleteMenu.java | 33 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteItem.java b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteItem.java index 79140da21..b5ddc7ae5 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteItem.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteItem.java @@ -82,8 +82,23 @@ public class AutocompleteItem implements Comparable { String signature = buildMethodSignature(method); + // Build display name with parameters like "read(byte[] b)" + StringBuilder displayName = new StringBuilder(name); + displayName.append("("); + for (int i = 0; i < method.getParameterCount(); i++) { + if (i > 0) displayName.append(", "); + FieldInfo param = method.getParameters().get(i); + String paramType = param.getTypeInfo() != null ? + param.getTypeInfo().getSimpleName() : "?"; + displayName.append(paramType); + if (param.getName() != null && !param.getName().isEmpty()) { + displayName.append(" ").append(param.getName()); + } + } + displayName.append(")"); + return new AutocompleteItem( - name, + displayName.toString(), insertText.toString(), Kind.METHOD, returnType, @@ -165,8 +180,12 @@ public class AutocompleteItem implements Comparable { insertText.append("("); insertText.append(")"); + // Use signature for display name if available, otherwise just name + String displayName = method.getSignature() != null && method.getSignature().contains("(") ? + method.getSignature().substring(method.getSignature().indexOf(name)) : name + "()"; + return new AutocompleteItem( - name, + displayName, insertText.toString(), Kind.METHOD, method.getReturnType(), diff --git a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteMenu.java b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteMenu.java index 95ba9bebe..b73ac42a3 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteMenu.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/AutocompleteMenu.java @@ -301,9 +301,14 @@ public class AutocompleteMenu extends Gui { font.drawString(icon, textX + (ICON_WIDTH - font.getStringWidth(icon)) / 2, textY, iconColor); textX += ICON_WIDTH; - // Draw name with match highlighting - drawHighlightedText(item.getName(), item.getMatchIndices(), textX, textY, - item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR); + // Draw name with match highlighting and parameter coloring for methods + if (item.getKind() == AutocompleteItem.Kind.METHOD) { + drawMethodName(item.getName(), item.getMatchIndices(), textX, textY, + item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR); + } else { + drawHighlightedText(item.getName(), item.getMatchIndices(), textX, textY, + item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR); + } // Draw type label on the right if (item.getTypeLabel() != null && !item.getTypeLabel().isEmpty()) { @@ -314,6 +319,28 @@ public class AutocompleteMenu extends Gui { } } + /** + * Draw method name with parameters colored gray. + */ + private void drawMethodName(String text, int[] matchIndices, int x, int y, int baseColor) { + // Find the opening parenthesis + int parenIndex = text.indexOf('('); + if (parenIndex == -1) { + // No parameters, just draw normally + drawHighlightedText(text, matchIndices, x, y, baseColor); + return; + } + + // Draw method name part with highlighting + String methodName = text.substring(0, parenIndex); + drawHighlightedText(methodName, matchIndices, x, y, baseColor); + + // Draw parameters part in gray (no highlighting) + String params = text.substring(parenIndex); + int paramX = x + font.getStringWidth(methodName); + font.drawString(params, paramX, y, DIM_TEXT_COLOR); + } + /** * Draw text with specific characters highlighted. */