diff --git a/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/CoatOfArmsRenderer.java b/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/CoatOfArmsRenderer.java index 15d8e11d..cdf83f40 100644 --- a/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/CoatOfArmsRenderer.java +++ b/pdxu-app/src/main/java/com/crschnick/pdxu/app/gui/game/CoatOfArmsRenderer.java @@ -183,14 +183,15 @@ public Color overlayColors(Color bottom, Color top) { private Color evaluateColorDefinition(String color, GameFileContext ctx) { // For inline colors like rgb { ... } - var tagged = Arrays.stream(TaggedNode.COLORS) - .filter(tagType -> color != null && color.startsWith(tagType.getId())) - .findAny() - .map(tagType -> new TaggedNode(tagType, Arrays.stream(color.substring(tagType.getId().length() + 2, color.length() - 1).split(" ")) - .filter(s -> s.length() > 0) - .map(s -> new ValueNode(s, false)).toList())); - if (tagged.isPresent()) { - return ColorHelper.fromGameColor(GameColor.fromColorNode(tagged.get())); + var taggedType = Arrays.stream(TaggedNode.COLORS).sorted(Comparator.comparingInt(value -> -value.getId().length())) + .filter(tagType -> color != null && color.startsWith(tagType.getId())) + .findFirst(); + if (taggedType.isPresent()) { + var values = Arrays.stream(color.substring(taggedType.get().getId().length() + 2, color.length() - 1).split(" ")) + .filter(s -> !s.isEmpty()) + .map(s -> new ValueNode(s, false)).toList(); + var node = new TaggedNode(taggedType.get(), values); + return ColorHelper.fromGameColor(GameColor.fromColorNode(node)); } var colors = getPredefinedColors(ctx); diff --git a/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/ColorHelper.java b/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/ColorHelper.java index ed8440e1..50b58d03 100644 --- a/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/ColorHelper.java +++ b/pdxu-app/src/main/java/com/crschnick/pdxu/app/util/ColorHelper.java @@ -65,7 +65,6 @@ public static Color fromGameColor(GameColor color) { var c = color.getValues(); try { - if (color.getType().equals(TaggedNode.TagType.HEX)) { var c0 = c.size() > 0 ? color.getValues().get(0) : "000000"; return Color.valueOf("#" + c0); @@ -77,12 +76,14 @@ public static Color fromGameColor(GameColor color) { return switch (color.getType()) { case HSV -> Color.hsb( d0 * 360, - d1, - d2); + Math.min(d1, 1.0), + Math.min(d2, 1.0) + ); case HSV360 -> Color.hsb( d0, - d1 / 100.0, - d2 / 100.0); + Math.min(d1 / 100.0, 1.0), + Math.min(d2 / 100.0, 1.0) + ); case RGB -> { var isDecimal = c.get(0).contains(".") || c.get(1).contains(".") || c.get(2).contains("."); var denominator = isDecimal ? 1.0 : 255.0;