From d0a69b18504c96c7e519b07a1d5c7262dcf6982e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 14 Oct 2023 22:47:15 +0200 Subject: [PATCH] Fixed Generic tag editor - brackets display --- .../types/filters/GRADIENTBEVELFILTER.java | 6 ++- .../types/filters/GRADIENTGLOWFILTER.java | 6 ++- .../flash/gui/GenericTagTreePanel.java | 46 ++++++------------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java index abaa29512..55f449f35 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.types.filters; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.RGBA; +import com.jpexs.decompiler.flash.types.annotations.SWFArray; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.SerializableImage; import java.awt.Color; @@ -37,7 +38,7 @@ public class GRADIENTBEVELFILTER extends FILTER { /** * Gradient colors */ - @SWFType(countField = "numColors") + @SWFArray(value = "color", countField = "numColors") public RGBA[] gradientColors = new RGBA[] { new RGBA(Color.WHITE), new RGBA(255, 0, 0, 0), @@ -47,7 +48,8 @@ public class GRADIENTBEVELFILTER extends FILTER { /** * Gradient ratios */ - @SWFType(value = BasicType.UI8, countField = "numColors") + @SWFType(value = BasicType.UI8) + @SWFArray(value = "ratio", countField = "numColors") public int[] gradientRatio = new int[] { 0, 128, 255 }; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java index cdbc2c611..98926df9d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.types.filters; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.RGBA; +import com.jpexs.decompiler.flash.types.annotations.SWFArray; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.SerializableImage; import java.awt.Color; @@ -37,7 +38,7 @@ public class GRADIENTGLOWFILTER extends FILTER { /** * Gradient colors */ - @SWFType(countField = "numColors") + @SWFArray(value = "color", countField = "numColors") public RGBA[] gradientColors = new RGBA[] { new RGBA(255, 255, 255, 0), new RGBA(Color.BLACK) @@ -46,7 +47,8 @@ public class GRADIENTGLOWFILTER extends FILTER { /** * Gradient ratios */ - @SWFType(value = BasicType.UI8, countField = "numColors") + @SWFType(value = BasicType.UI8) + @SWFArray(value = "ratio", countField = "numColors") public int[] gradientRatio = new int[] { 0, 255 }; diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 53bf21219..e7d22c327 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -956,23 +956,21 @@ public class GenericTagTreePanel extends GenericTagPanel { if (swfType.value() != BasicType.OTHER) { typeStr = "" + swfType.value(); } - if (isArrayParent) { - if (swfType.count() > 0) { - typeStr += "[" + swfType.count(); - if (swfType.countAdd() > 0) { - typeStr += " + " + swfType.countAdd(); - } - typeStr += "]"; - bracketsDetected = true; - } else if (!swfType.countField().isEmpty()) { - typeStr += "[" + swfType.countField(); - if (swfType.countAdd() > 0) { - typeStr += " + " + swfType.countAdd(); - } - typeStr += "]"; - bracketsDetected = true; + if (swfType.count() > 0) { + typeStr += "[" + swfType.count(); + if (swfType.countAdd() > 0) { + typeStr += " + " + swfType.countAdd(); } - } + typeStr += "]"; + bracketsDetected = true; + } else if (!swfType.countField().isEmpty()) { + typeStr += "[" + swfType.countField(); + if (swfType.countAdd() > 0) { + typeStr += " + " + swfType.countAdd(); + } + typeStr += "]"; + bracketsDetected = true; + } } String arrayBrackets = ""; @@ -1516,28 +1514,20 @@ public class GenericTagTreePanel extends GenericTagPanel { private void addItem(Object obj, Field field, int index, Class cls) { SWFArray swfArray = field.getAnnotation(SWFArray.class); - SWFType swfType = field.getAnnotation(SWFType.class); String countFieldName = null; if (swfArray != null && !swfArray.countField().isEmpty()) { countFieldName = swfArray.countField(); } - if (swfType != null && !swfType.countField().isEmpty()) { - countFieldName = swfType.countField(); - } if (countFieldName != null) { //Fields with same countField must be enlarged too Field[] fields = obj.getClass().getDeclaredFields(); List sameFlds = new ArrayList<>(); for (int f = 0; f < fields.length; f++) { SWFArray fieldSwfArray = fields[f].getAnnotation(SWFArray.class); - SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class); String fieldCountFieldName = null; if (fieldSwfArray != null && !fieldSwfArray.countField().isEmpty()) { fieldCountFieldName = fieldSwfArray.countField(); } - if (fieldSwfType != null && !fieldSwfType.countField().isEmpty()) { - fieldCountFieldName = fieldSwfType.countField(); - } if (fieldCountFieldName != null && fieldCountFieldName.equals(countFieldName)) { sameFlds.add(f); if (cls == null && !ReflectionTools.canAddToField(obj, fields[f])) { @@ -1612,26 +1602,18 @@ public class GenericTagTreePanel extends GenericTagPanel { private void removeItem(Object obj, Field field, int index) { SWFArray swfArray = field.getAnnotation(SWFArray.class); - SWFType swfType = field.getAnnotation(SWFType.class); String countFieldName = null; if (swfArray != null && !swfArray.countField().isEmpty()) { countFieldName = swfArray.countField(); } - if (swfType != null && !swfType.countField().isEmpty()) { - countFieldName = swfType.countField(); - } if (countFieldName != null) { //Fields with same countField must be removed from too Field[] fields = obj.getClass().getDeclaredFields(); for (int f = 0; f < fields.length; f++) { SWFArray fieldSwfArray = fields[f].getAnnotation(SWFArray.class); - SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class); String fieldCountFieldName = null; if (fieldSwfArray != null && !fieldSwfArray.countField().isEmpty()) { fieldCountFieldName = fieldSwfArray.countField(); } - if (fieldSwfType != null && !fieldSwfType.countField().isEmpty()) { - fieldCountFieldName = fieldSwfType.countField(); - } if (fieldCountFieldName != null && fieldCountFieldName.equals(countFieldName)) { ReflectionTools.removeFromField(obj, fields[f], index);