From 1e844444cfe6c70e6374b0587552d729cab139a8 Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Fri, 9 Jan 2026 05:11:07 +0200 Subject: [PATCH] Colored Autocomplete items according to their token types --- .../script/autocomplete/AutocompleteMenu.java | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) 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 5fede61bf..52b8fd86f 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 @@ -378,19 +378,10 @@ public class AutocompleteMenu extends Gui { } // Determine text color - gray for inherited Object methods - int textColor; - if (item.isInheritedObjectMethod()) { - textColor = DIM_TEXT_COLOR; - } else if (item.isDeprecated()) { - textColor = DIM_TEXT_COLOR; - } else { - textColor = TEXT_COLOR; - } - - // Draw name with match highlighting and parameter coloring for methods + int textColor = getColor(item); if (item.getKind() == AutocompleteItem.Kind.METHOD) { - drawMethodNameTruncated(item.getName(), item.getMatchIndices(), textX, textY, - textColor, availableWidth); + drawMethodNameTruncated(item.getName(), item.getMatchIndices(), textX, textY, + textColor, availableWidth); } else { drawHighlightedTextTruncated(item.getName(), item.getMatchIndices(), textX, textY, textColor, availableWidth); @@ -407,6 +398,28 @@ public class AutocompleteMenu extends Gui { font.drawString(typeLabel, typeLabelX, textY, col); } } + + public int getColor(AutocompleteItem item) { + if (item.isInheritedObjectMethod() || item.isDeprecated()) + return DIM_TEXT_COLOR; + + switch (item.getKind()) { + case METHOD: + return TokenType.METHOD_CALL.getHexColor(); + case FIELD: + return TokenType.GLOBAL_FIELD.getHexColor(); + case ENUM_CONSTANT: + return TokenType.ENUM_CONSTANT.getHexColor(); + case CLASS: + return TokenType.getColor(item.getTypeInfo()); + case VARIABLE: + return TokenType.LOCAL_FIELD.getHexColor(); + case KEYWORD: + return TokenType.KEYWORD.getHexColor(); + default: + return TEXT_COLOR; + } + } /** * Draw method name with parameters colored gray.