diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 9ad13c603..4d9f18c49 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -1201,8 +1201,7 @@ public class SWFOutputStream extends OutputStream { if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) || (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { writeGRADIENT(value.gradient, shapeNum); - } - if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { + } else if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { writeFOCALGRADIENT((FOCALGRADIENT) value.gradient, shapeNum); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java index 0972138ab..02f1b1f4a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FILLSTYLE.java @@ -26,13 +26,14 @@ import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import java.io.Serializable; +import java.lang.reflect.Field; import java.util.Set; /** * * @author JPEXS */ -public class FILLSTYLE implements NeedsCharacters, Serializable { +public class FILLSTYLE implements NeedsCharacters, FieldChangeObserver, Serializable { @SWFType(BasicType.UI8) @EnumValue(value = SOLID, text = "Solid") @@ -120,4 +121,26 @@ public class FILLSTYLE implements NeedsCharacters, Serializable { } return false; } + + @Override + public void fieldChanged(Field field) { + if ((fillStyleType == FILLSTYLE.LINEAR_GRADIENT) + || (fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { + if (gradient instanceof FOCALGRADIENT) { + GRADIENT g = new GRADIENT(); + g.spreadMode = gradient.spreadMode; + g.interpolationMode = gradient.interpolationMode; + g.gradientRecords = gradient.gradientRecords; + gradient = g; + } + } else if (fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { + if (!(gradient instanceof FOCALGRADIENT)) { + FOCALGRADIENT g = new FOCALGRADIENT(); + g.spreadMode = gradient.spreadMode; + g.interpolationMode = gradient.interpolationMode; + g.gradientRecords = gradient.gradientRecords; + gradient = g; + } + } + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FieldChangeObserver.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FieldChangeObserver.java new file mode 100644 index 000000000..715b6ff54 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/FieldChangeObserver.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010-2016 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.types; + +import java.lang.reflect.Field; + +/** + * + * @author JPEXS + */ +public interface FieldChangeObserver { + + void fieldChanged(Field field); +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java index a38bac4bc..aed833be2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/annotations/parser/ConditionEvaluator.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.types.annotations.parser; import com.jpexs.decompiler.flash.types.annotations.Conditional; +import com.jpexs.decompiler.flash.types.annotations.ConditionalType; import java.io.IOException; import java.io.StringReader; import java.util.EmptyStackException; @@ -31,10 +32,14 @@ import java.util.Stack; */ public class ConditionEvaluator { - private final Conditional cond; + private final String[] values; public ConditionEvaluator(Conditional cond) { - this.cond = cond; + values = cond.value(); + } + + public ConditionEvaluator(ConditionalType cond) { + values = cond.value(); } private void expressionRest(Map fields, Stack stack, ConditionLexer lex) throws IOException, AnnotationParseException { @@ -114,7 +119,7 @@ public class ConditionEvaluator { } private String prepareCond() { - String[] vals = cond.value(); + String[] vals = values; if (vals == null || vals.length == 0) { return ""; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java index 67c6398a1..f903dbb6c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java @@ -16,6 +16,7 @@ */ package com.jpexs.helpers; +import com.jpexs.decompiler.flash.types.FieldChangeObserver; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFField; import java.lang.reflect.Array; @@ -125,8 +126,15 @@ public class ReflectionTools { return 0; } + private static void notifyFieldChanged(Object obj, Field field) { + if (obj != null && obj instanceof FieldChangeObserver) { + ((FieldChangeObserver) obj).fieldChanged(field); + } + } + public static void setValue(Object obj, Field field, Object newValue) throws IllegalArgumentException, IllegalAccessException { field.set(obj, newValue); + notifyFieldChanged(obj, field); } @SuppressWarnings("unchecked") @@ -146,6 +154,7 @@ public class ReflectionTools { Array.set(value, index, newValue); } else { field.set(obj, newValue); + notifyFieldChanged(obj, field); } } @@ -303,6 +312,7 @@ public class ReflectionTools { } try { field.set(object, copy); + notifyFieldChanged(object, field); } catch (IllegalArgumentException | IllegalAccessException ex) { logger.log(Level.SEVERE, null, ex); return false; diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 7d6e3f643..1eb98113d 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -701,7 +701,6 @@ public class GenericTagTreePanel extends GenericTagPanel { } } - // todo: check other condition filters if (condEnabled) { type = cond.type(); } @@ -790,8 +789,8 @@ public class GenericTagTreePanel extends GenericTagPanel { String parentPath = currentPath.indexOf('.') == -1 ? "" : currentPath.substring(0, currentPath.lastIndexOf('.')); try { for (String cname : ev.getFields()) { - String fullParh = parentPath + "." + cname; - if (fullParh.equals(dependence)) { + String fullPath = parentPath + "." + cname; + if (fullPath.equals(dependence)) { ret.add(fnode); break; }