From 757188b270388c705f80bae2782aec93e81c8e74 Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Sat, 19 Apr 2025 10:03:22 -0500 Subject: [PATCH] named colors in % (#10682) * named colors in % * bad copying + needs closing bracket * fix formatt * some other (now fixed) bug gave me trouble, now I can remove this * shouldn't need access to Pal now --- core/src/mindustry/logic/LAssembler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/mindustry/logic/LAssembler.java b/core/src/mindustry/logic/LAssembler.java index 4995bb7e89..d8ca04079b 100644 --- a/core/src/mindustry/logic/LAssembler.java +++ b/core/src/mindustry/logic/LAssembler.java @@ -93,6 +93,12 @@ public class LAssembler{ if(symbol.startsWith("0x")) return Strings.parseLong(symbol, 16, 2, symbol.length(), invalidNum); if(symbol.startsWith("+0x")) return Strings.parseLong(symbol, 16, 3, symbol.length(), invalidNum); if(symbol.startsWith("-0x")) return -Strings.parseLong(symbol, 16, 3, symbol.length(), invalidNum);//FIXME: breaks with Long.MIN_VALUE + if(symbol.startsWith("%[") && symbol.endsWith("]") && symbol.length() > 3){ + double color = parseNamedColor(symbol); + if(color != -1d){ + return color; + } + } if(symbol.startsWith("%") && (symbol.length() == 7 || symbol.length() == 9)) return parseColor(symbol); return Strings.parseDouble(symbol, invalidNum); @@ -108,6 +114,12 @@ public class LAssembler{ return Color.toDoubleBits(r, g, b, a); } + double parseNamedColor(String symbol){ + Color color = Colors.get(symbol.substring(2, symbol.length() - 1)); + + return color == null ? -1d : color.toDoubleBits(); + } + /** Adds a constant value by name. */ public LVar putConst(String name, Object value){ LVar var = putVar(name);