diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptLine.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptLine.java index c262a6877..57a13ed78 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptLine.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptLine.java @@ -226,6 +226,7 @@ public class ScriptLine { * Draw this line with syntax highlighting using Minecraft color codes. * Compatible with the existing rendering system. * Also draws curly underlines for tokens with errors (method call validation failures). + * Supports bold (§l) and italic (§o) formatting for certain token types. */ public void drawString(int x, int y, int defaultColor) { StringBuilder builder = new StringBuilder(); @@ -246,12 +247,16 @@ public class ScriptLine { } - // Append the colored token + // Append style codes (bold/italic) if applicable + String stylePrefix = t.getStylePrefix(); + + // Append the colored token with style builder.append(COLOR_CHAR) .append(t.getColorCode()) + .append(stylePrefix) .append(t.getText()) .append(COLOR_CHAR) - .append('f'); // Reset to white + .append('r'); // Reset all formatting (color + bold/italic) currentX += tokenWidth; lastIndex = tokenStart + t.getText().length(); @@ -295,10 +300,11 @@ public class ScriptLine { } // Add the colored token - segments.add(new TextSegment(fullText.length(), t.getText(), t.getHexColor(), true)); - fullText.append(t.getText()); + String styledText = t.getStylePrefix() + t.getText(); + segments.add(new TextSegment(fullText.length(), styledText, t.getHexColor(), true)); + fullText.append(styledText); - lastIndex = tokenStart + t.getText().length(); + lastIndex = tokenStart + styledText.length(); } // Add any remaining text after the last token diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/Token.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/Token.java index 69b89c15b..0371ee17f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/Token.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/Token.java @@ -248,6 +248,17 @@ public class Token { public char getColorCode() { return type.toColorCode(); } + + /** + * Get the Minecraft style prefix for this token (bold/italic codes). + * Returns empty string if no style, otherwise §l for bold, §o for italic, or both. + */ + public String getStylePrefix() { + StringBuilder sb = new StringBuilder(); + if (type.isBold()) sb.append('\u00A7').append('l'); + if (type.isItalic()) sb.append('\u00A7').append('o'); + return sb.toString(); + } @Override public String toString() { diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/TokenType.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/TokenType.java index b018c942f..0b7e8e252 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/TokenType.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/token/TokenType.java @@ -45,10 +45,18 @@ public enum TokenType { private final int hexColor; private final int priority; + private final boolean bold; + private final boolean italic; TokenType(int hexColor, int priority) { + this(hexColor, priority, false, false); + } + + TokenType(int hexColor, int priority, boolean bold, boolean italic) { this.hexColor = hexColor; this.priority = priority; + this.bold = bold; + this.italic = italic; } public int getHexColor() { @@ -59,6 +67,14 @@ public enum TokenType { return priority; } + public boolean isBold() { + return bold; + } + + public boolean isItalic() { + return italic; + } + public static int getColor(TypeInfo typeInfo) { if (typeInfo == null) return TokenType.IMPORTED_CLASS.getHexColor();