From c38984258486bc46e2edeedf42ce4a2f813364a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 4 Dec 2023 08:54:39 +0100 Subject: [PATCH] Fixed #2139 FLA Export - labels layer not counted as layer index causing masked layer parentindex wrong --- CHANGELOG.md | 4 +++- .../decompiler/flash/xfl/XFLConverter.java | 22 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b040caa17..903279484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,8 @@ All notable changes to this project will be documented in this file. - [#2133] Linux/Mac - ffdec.sh not correctly parsing java build number on javas without it - [#2135] FLA Export - framescripts handling when addFrameScript uses Multinames instead of QNames - [#1194] FLA Export - stream sound export -- [#2136] FLA export - optimized Shape fixer speed, repeated shape on timeline not exported twice +- [#2136] FLA Export - optimized Shape fixer speed, repeated shape on timeline not exported twice +- [#2139] FLA Export - labels layer not counted as layer index causing masked layer parentindex wrong ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class @@ -3342,6 +3343,7 @@ Major version of SWF to XML export changed to 2. [#2135]: https://www.free-decompiler.com/flash/issues/2135 [#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 [#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 4a957607b..f10f4952b 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 @@ -3123,9 +3123,7 @@ public class XFLConverter { return hasScript; } - private boolean convertLabelsLayer(ReadOnlyTagList tags, ReadOnlyTagList timeLineTags, String backgroundColor, XFLXmlWriter writer) throws XMLStreamException { - boolean hasLabel = false; - + private int convertLabelsLayers(ReadOnlyTagList tags, ReadOnlyTagList timeLineTags, String backgroundColor, XFLXmlWriter writer) throws XMLStreamException { Map> frameToLabels = new HashMap<>(); int frame = 0; int layerCount = 0; @@ -3145,7 +3143,7 @@ public class XFLConverter { } int frameCount = frame; - for (int lay = 0; lay < layerCount; lay++) { + for (int lay = 0; lay < layerCount; lay++) { writer.writeStartElement("DOMLayer", new String[]{"name", "Labels Layer" + (layerCount > 1 ? " " + (lay + 1) : ""), "color", randomOutlineColor()}); writer.writeStartElement("frames"); int duration = 0; @@ -3187,8 +3185,8 @@ public class XFLConverter { writer.writeEndElement(); // frames writer.writeEndElement(); // DOMLayer } - - return hasLabel; + + return layerCount; } private void convertSoundLayer(Scene scene, ReadOnlyTagList timeLineTags, HashMap files, XFLXmlWriter writer) throws XMLStreamException { @@ -3932,16 +3930,14 @@ public class XFLConverter { writer.writeStartElement("layers"); ReadOnlyTagList sceneTimelineTags = scene.timelineSubTags; - - boolean hasLabel = convertLabelsLayer(tags, sceneTimelineTags, backgroundColor, writer); + Reference labelLayerCountRef = new Reference<>(0); + int labelLayerCount = convertLabelsLayers(tags, sceneTimelineTags, backgroundColor, writer); boolean hasScript = convertActionScriptLayer(scene, initClipScript, abcIndex, spriteId, tags, sceneTimelineTags, backgroundColor, writer, scriptPack); int index = 0; - - if (hasLabel) { - index++; - } - + + index += labelLayerCount; + if (hasScript) { index++; }