From daff3f7aea5d55dde40cf379bf420bf0a0ee063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 10 Dec 2023 16:12:21 +0100 Subject: [PATCH] Fixed #2145 FLA Export - missing frames, cliping layers order, nullpointer, empty sound layers --- CHANGELOG.md | 4 +- .../decompiler/flash/xfl/XFLConverter.java | 64 +++-- .../exp/nested_masks/DOMDocument.xml | 231 ++++++++++++++++++ .../nested_masks/LIBRARY/MaskedSymbol 14.xml | 64 +++++ .../nested_masks/LIBRARY/MaskedSymbol 15.xml | 64 +++++ .../exp/nested_masks/LIBRARY/Symbol 10.xml | 27 ++ .../exp/nested_masks/LIBRARY/Symbol 13.xml | 32 +++ .../exp/nested_masks/LIBRARY/Symbol 4.xml | 30 +++ .../exp/nested_masks/LIBRARY/Symbol 5.xml | 27 ++ .../exp/nested_masks/LIBRARY/Symbol 6.xml | 32 +++ .../exp/nested_masks/LIBRARY/Symbol 7.xml | 27 ++ .../exp/nested_masks/LIBRARY/Symbol 8.xml | 27 ++ .../exp/nested_masks/LIBRARY/Symbol 9.xml | 66 +++++ .../exp/nested_masks/PublishSettings.xml | 206 ++++++++++++++++ .../exp/nested_masks/nested_masks.xfl | 1 + 15 files changed, 883 insertions(+), 19 deletions(-) create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/DOMDocument.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 14.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 15.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 10.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 13.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 4.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 5.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 6.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 7.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 8.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 9.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/PublishSettings.xml create mode 100644 libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/nested_masks.xfl diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be177648..4acfff966 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ All notable changes to this project will be documented in this file. - [#2138] FLA Export - Missing morphshapes (incorrect holes calculation) - [#2138] FLA Export - Mask layer was visible when did not contain a masked layer - FLA Export - frame numbering problem +- [#2145] FLA Export - missing frames, cliping layers order, nullpointer, empty sound layers ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class @@ -3335,6 +3336,7 @@ Major version of SWF to XML export changed to 2. [#2124]: https://www.free-decompiler.com/flash/issues/2124 [#2134]: https://www.free-decompiler.com/flash/issues/2134 [#2132]: https://www.free-decompiler.com/flash/issues/2132 +[#2138]: https://www.free-decompiler.com/flash/issues/2138 [#2021]: https://www.free-decompiler.com/flash/issues/2021 [#2000]: https://www.free-decompiler.com/flash/issues/2000 [#2116]: https://www.free-decompiler.com/flash/issues/2116 @@ -3349,7 +3351,7 @@ Major version of SWF to XML export changed to 2. [#1194]: https://www.free-decompiler.com/flash/issues/1194 [#2136]: https://www.free-decompiler.com/flash/issues/2136 [#2139]: https://www.free-decompiler.com/flash/issues/2139 -[#2138]: https://www.free-decompiler.com/flash/issues/2138 +[#2145]: https://www.free-decompiler.com/flash/issues/2145 [#2120]: https://www.free-decompiler.com/flash/issues/2120 [#1130]: https://www.free-decompiler.com/flash/issues/1130 [#1220]: https://www.free-decompiler.com/flash/issues/1220 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 8d61520c0..a358a793b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -174,7 +174,6 @@ import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -237,7 +236,7 @@ public class XFLConverter { /** * Adds "(depth xxx)" to layer name */ - private final boolean DEBUG_EXPORT_LAYER_DEPTHS = true; + private final boolean DEBUG_EXPORT_LAYER_DEPTHS = false; private static final DecimalFormat EDGE_DECIMAL_FORMAT = new DecimalFormat("0.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH)); @@ -254,12 +253,16 @@ public class XFLConverter { this.progressListener = progressListener; } + public String getStatusString() { + return String.join(", ", statuses); + } + private void update() { if (progressListener == null) { return; } - String status = String.join(", ", statuses); - progressListener.status(status); + + progressListener.status(getStatusString()); } public void pushStatus(String status) { @@ -1677,7 +1680,7 @@ public class XFLConverter { convertMedia(swf, characterVariables, characterClasses, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer, statusStack); statusStack.popStatus(); statusStack.pushStatus("symbols"); - convertSymbols(swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer, placeToMaskedSymbol, multiUsageMorphShapes, statusStack); + convertSymbols(swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer, placeToMaskedSymbol, multiUsageMorphShapes, statusStack); statusStack.popStatus(); } @@ -2545,7 +2548,7 @@ public class XFLConverter { } private static void convertFrames(Scene scene, SWF swf, List onlyFrames, int startFrame, int endFrame, String prevStr, String afterStr, List nonLibraryShapes, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap characters, int depth, FLAVersion flaVersion, HashMap files, XFLXmlWriter writer, List multiUsageMorphShapes, StatusStack statusStack) throws XMLStreamException { - boolean lastIn = true; + boolean lastIn = false; XFLXmlWriter writer2 = new XFLXmlWriter(); prevStr += ""; int frame = -1; @@ -2691,12 +2694,17 @@ public class XFLConverter { frame++; if (frame < startFrame || frame > endFrame || (onlyFrames != null && !onlyFrames.contains(frame))) { if (lastIn) { + if (!lastElements.isEmpty()) { + convertFrame(scene, false, null, null, frame - duration, duration, "", lastElements, files, writer2, null); + duration = 1; + } else { + duration++; + } lastElements = ""; lastIn = false; lastCharacter = null; lastMatrix = null; - } - if (frame == 0) { + } else if (frame == 0) { duration = 1; } else { duration++; @@ -2800,9 +2808,11 @@ public class XFLConverter { } } - if (!lastElements.isEmpty() || writer2.length() > 0) { - frame++; - convertFrame(scene, false, null, null, frame - duration, duration, "", lastElements, files, writer2, null); + if ((!lastElements.isEmpty() || writer2.length() > 0) && lastIn) { + if (frame >= startFrame && frame <= endFrame && (onlyFrames == null || onlyFrames.contains(frame))) { + frame++; + convertFrame(scene, false, null, null, frame - duration, duration, "", lastElements, files, writer2, null); + } } afterStr = "" + afterStr; @@ -3211,6 +3221,13 @@ public class XFLConverter { } for (int i = 0; i < soundStreamRanges.size(); i++) { + if (soundStreamRanges.get(i).startFrame < scene.startFrame) { + continue; + } + if (soundStreamRanges.get(i).startFrame >= scene.startFrame + frame) { + continue; + } + writer.writeStartElement("DOMLayer", new String[]{"name", "Sound Layer " + (soundLayerIndex++), "color", randomOutlineColor()}); writer.writeStartElement("frames"); @@ -3303,6 +3320,8 @@ public class XFLConverter { ) throws XMLStreamException { XFLXmlWriter symbolStr = new XFLXmlWriter(); + extractMultilevelClips(timelineTags, writer, swf, nextClipId, nonLibraryShapes, backgroundColor, characters, flaVersion, files, placeToMaskedSymbol, multiUsageMorphShapes, statusStack); + if (nextClipId.getVal() < 0) { nextClipId.setVal(swf.getNextCharacterId()); } else { @@ -3317,7 +3336,7 @@ public class XFLConverter { "name", generateMaskedSymbolName(objectId), "lastModified", Long.toString(getTimestamp(swf))}); symbolStr.writeAttribute("symbolType", "graphic"); - + convertTimelines(swf, swf.getAbcIndex(), objectId, "", nonLibraryShapes, backgroundColor, timelineTags, timelineTags, characters, generateMaskedSymbolName(objectId), flaVersion, files, symbolStr, null, placeToMaskedSymbol, multiUsageMorphShapes, statusStack); symbolStr.writeEndElement(); // DOMSymbolItem @@ -3334,7 +3353,6 @@ public class XFLConverter { } writer.writeEndElement(); - extractMultilevelClips(timelineTags, writer, swf, nextClipId, nonLibraryShapes, backgroundColor, characters, flaVersion, files, placeToMaskedSymbol, multiUsageMorphShapes, statusStack); } private String generateMaskedSymbolName(int symbolId) { @@ -3754,7 +3772,7 @@ public class XFLConverter { private void convertTimelines(SWF swf, AbcIndexing abcIndex, int spriteId, String linkageIdentifier, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap characters, String spriteName, FLAVersion flaVersion, HashMap files, XFLXmlWriter writer, ScriptPack scriptPack, Map placeToMaskedSymbol, List multiUsageMorphShapes, StatusStack statusStack) throws XMLStreamException { - List classNames = new ArrayList<>(); + List classNames = new ArrayList<>(); //Searches for Object.registerClass("linkageIdentifier",mypkg.MyClass); ActionTreeOperation getRegisterClassOp = new ActionTreeOperation() { @Override @@ -4108,7 +4126,7 @@ public class XFLConverter { int parentIndex = index; index++; - + for (int fx = clipFrame; fx <= lastFrame; fx++) { for (int nd = po.getClipDepth() - 1; nd > po.getDepth(); nd--) { if (!depthToFramesList.containsKey(nd) || !depthToFramesList.get(nd).contains(fx)) { @@ -4123,9 +4141,19 @@ public class XFLConverter { continue; } handledClips.add(po2); - + + for (int ndx = po.getClipDepth() - 1; ndx > po2.getClipDepth(); ndx--) { + boolean nonEmpty = writeLayer(scene, swf, index, depthToFramesList.get(ndx), ndx, clipFrame, lastFrame, parentIndex, writer, nonLibraryShapes, tags, sceneTimelineTags, characters, flaVersion, files, multiUsageMorphShapes, statusStack); + for (int i = clipFrame; i <= lastFrame; i++) { + depthToFramesList.get(ndx).remove((Integer) i); + } + if (nonEmpty) { + index++; + } + } + MultiLevelClip mlc = placeToMaskedSymbol.get(po2); - + writer.writeStartElement("DOMLayer", new String[]{ "name", "Layer " + (index + 1) + (DEBUG_EXPORT_LAYER_DEPTHS ? " (depth " + po2.getDepth() + " clipdepth:" + po2.getClipDepth() + " maskedid:" + mlc.symbol + ")" : ""), "color", randomOutlineColor(), @@ -4190,7 +4218,7 @@ public class XFLConverter { } } } - + for (int nd = po.getClipDepth() - 1; nd > po.getDepth(); nd--) { boolean nonEmpty = writeLayer(scene, swf, index, depthToFramesList.get(nd), nd, clipFrame, lastFrame, parentIndex, writer, nonLibraryShapes, tags, sceneTimelineTags, characters, flaVersion, files, multiUsageMorphShapes, statusStack); for (int i = clipFrame; i <= lastFrame; i++) { diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/DOMDocument.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/DOMDocument.xml new file mode 100644 index 000000000..844349420 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/DOMDocument.xml @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 14.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 14.xml new file mode 100644 index 000000000..ca95fa458 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 14.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 15.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 15.xml new file mode 100644 index 000000000..8b2abde8f --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/MaskedSymbol 15.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 10.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 10.xml new file mode 100644 index 000000000..33d5b7455 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 10.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 13.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 13.xml new file mode 100644 index 000000000..cd2355ea8 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 13.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 4.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 4.xml new file mode 100644 index 000000000..1e42f10f4 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 4.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 5.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 5.xml new file mode 100644 index 000000000..335e73cfc --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 5.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 6.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 6.xml new file mode 100644 index 000000000..20ecefccd --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 6.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 7.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 7.xml new file mode 100644 index 000000000..c5842cdf8 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 7.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 8.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 8.xml new file mode 100644 index 000000000..853e34a3e --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 8.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 9.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 9.xml new file mode 100644 index 000000000..d8443c2af --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/LIBRARY/Symbol 9.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/PublishSettings.xml b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/PublishSettings.xml new file mode 100644 index 000000000..627d3a75d --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/PublishSettings.xml @@ -0,0 +1,206 @@ + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + nested_masks.swf + nested_masks.exe + nested_masks.app + nested_masks.html + nested_masks.gif + nested_masks.jpg + nested_masks.png + 1 + nested_masks.smil + nested_masks.swc + + + 0 + 12,0,0,0;11,2,0,0;11,1,0,0;10,3,0,0;10,2,153,0;10,1,52,0;9,0,124,0;8,0,24,0;7,0,14,0;6,0,79,0;5,0,58,0;4,0,32,0;3,0,8,0;2,0,1,12;1,0,0,1; + 1 + 1 + nested_masks_content.html + nested_masks_alternate.html + 0 + + 550.0 + 400.0 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 4 + 0 + 0 + 1 + 0 + + 1 + + + + + 0 + 0 + 0 + 80 + 0 + 0 + 7 + 0 + 7 + 0 + 15 + FlashPlayer11.2 + 2 + 1 + + . + CONFIG::FLASH_AUTHORING="true"; + 0 + + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + 2 + 4 + 4096 + AS3 + 1 + 1 + 0 + 15 + 1 + 0 + 4102 + rsl + wrap + $(AppConfig)/ActionScript 3.0/rsls/loader_animation.swf + + + $(AppConfig)/ActionScript 3.0/libs + merge + + + $(AppConfig)/ActionScript 3.0/libs/11.0/textLayout.swc + rsl + http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz + http://fpdownload.adobe.com/pub/swz/crossdomain.xml + textLayout_2.0.0.232.swz + + + + + $(AppConfig)/ActionScript 3.0/libs/11.0/textLayout.swc + + http://fpdownload.adobe.com/pub/swz/tlf/2.0.0.232/textLayout_2.0.0.232.swz + http://fpdownload.adobe.com/pub/swz/crossdomain.xml + textLayout_2.0.0.232.swz + + + + + 550.0 + 400.0 + 0 + 4718592 + 0 + 80 + 1 + + + 1 + 0 + 1 + 0 + 0 + 100000 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + 550.0 + 400.0 + 0 + 1 + 1 + + 1 + 0 + 1 + 0 + 0 + + 128 + + + 255 + + + + 550.0 + 400.0 + 1 + 0 + 0 + 1 + 0 + 0 + 1 + + + + 24-bit with Alpha + 255 + + + + 550.0 + 400.0 + 1 + 0 + + + 00000000 + 0 + 0 + 0 + 0 + 1 + + + \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/nested_masks.xfl b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/nested_masks.xfl new file mode 100644 index 000000000..860a820ec --- /dev/null +++ b/libsrc/ffdec_lib/testdata/nested_masks/exp/nested_masks/nested_masks.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file