diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 2fb25658d..a172d5ad0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -938,12 +938,11 @@ public final class SWF implements TreeItem, Timelined { list2.addAll(tags); List list = createASTagList(list2, this); - TagNode.setExport(list, true); if (!outdir.endsWith(File.separator)) { outdir += File.separator; } outdir += "scripts" + File.separator; - ret.addAll(TagNode.exportNodeAS(handler, list, outdir, exportMode, evl)); + ret.addAll(TagNode.exportNodeAS(handler, list, list, outdir, exportMode, evl)); return ret; } @@ -1036,38 +1035,31 @@ public final class SWF implements TreeItem, Timelined { public static List createASTagList(List list, Timelined parent) { List ret = new ArrayList<>(); - int frame = 1; + int frame = 0; List frames = new ArrayList<>(); - List exportAssetsTags = new ArrayList<>(); for (ContainerItem t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } TreeNode addNode = null; if (t instanceof ShowFrameTag) { // do not add PlaceObjects (+etc) to script nodes FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), frame, parent, false), null, true); for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).getItem() instanceof DefineSpriteTag)) { - if (!(ret.get(r).getItem() instanceof DefineButtonTag)) { - if (!(ret.get(r).getItem() instanceof DefineButton2Tag)) { - if (!(ret.get(r).getItem() instanceof DoInitActionTag)) { - if (!(ret.get(r).getItem() instanceof AS2PackageNodeItem)) { - tti.subNodes.add(ret.get(r)); - ret.remove(r); - } - } - } - } + TreeNode node = ret.get(r); + TreeItem item = node.getItem(); + if (!(item instanceof DefineSpriteTag + || item instanceof DefineButtonTag + || item instanceof DefineButton2Tag + || item instanceof DoInitActionTag + || item instanceof AS2PackageNodeItem)) { + tti.subNodes.add(node); + ret.remove(r); } } frame++; frames.add(tti); } else if (t instanceof ASMSource) { ContainerNode tti = new ContainerNode(t); - //ret.add(tti); addNode = tti; } else if (t instanceof Container) { if (((Container) t).getItemCount() > 0) { @@ -1078,7 +1070,6 @@ public final class SWF implements TreeItem, Timelined { Timelined timelined = t instanceof Timelined ? (Timelined) t : null; tti.subNodes = createASTagList(subItems, timelined); addNode = tti; - //ret.add(tti); } } if (addNode != null) { @@ -1088,24 +1079,15 @@ public final class SWF implements TreeItem, Timelined { if (path == null) { path = ""; } - String[] pathParts; - if (path.contains(".")) { - pathParts = path.split("\\."); - } else { - pathParts = new String[]{path}; - } + String[] pathParts = path.contains(".") ? path.split("\\.") : new String[]{ path }; List items = ret; - int pos = 0; - TreeNode selNode = null; - do { - if (pos == pathParts.length - 1) { - break; - } - selNode = null; + for (int pos = 0; pos < pathParts.length - 1; pos++) { + String pathPart = pathParts[pos]; + TreeNode selNode = null; for (TreeNode node : items) { if (node.getItem() instanceof AS2PackageNodeItem) { AS2PackageNodeItem pkg = (AS2PackageNodeItem) node.getItem(); - if (pkg.packageName.equals(pathParts[pos])) { + if (pkg.packageName.equals(pathPart)) { selNode = node; break; } @@ -1114,8 +1096,8 @@ public final class SWF implements TreeItem, Timelined { int pkgCount = 0; for (; pkgCount < items.size(); pkgCount++) { if (items.get(pkgCount).getItem() instanceof AS3PackageNodeItem) { - AS2PackageNodeItem pkg = (AS2PackageNodeItem) items.get(pkgCount).getItem(); - if (pkg.packageName.compareTo(pathParts[pos]) > 0) { + AS3PackageNodeItem pkg = (AS3PackageNodeItem) items.get(pkgCount).getItem(); + if (pkg.packageName.compareTo(pathPart) > 0) { break; } } else { @@ -1123,16 +1105,14 @@ public final class SWF implements TreeItem, Timelined { } } if (selNode == null) { - items.add(pkgCount, selNode = new AS2PackageNode(new AS2PackageNodeItem(pathParts[pos], t.getSwf()))); + items.add(pkgCount, selNode = new AS2PackageNode(new AS2PackageNodeItem(pathPart, t.getSwf()))); } pos++; - if (selNode != null) { - items = selNode.subNodes; - } - - } while (selNode != null); + items = selNode.subNodes; + } int clsCount = 0; + String addNodeName = addNode.getItem().getClass().getName() + "_" + pathParts[pathParts.length - 1]; for (; clsCount < items.size(); clsCount++) { if (items.get(clsCount).getItem() instanceof CharacterIdTag) { CharacterIdTag ct = (CharacterIdTag) items.get(clsCount).getItem(); @@ -1143,7 +1123,7 @@ public final class SWF implements TreeItem, Timelined { if (expName.contains(".")) { expName = expName.substring(expName.lastIndexOf('.') + 1); } - if ((ct.getClass().getName() + "_" + expName).compareTo(addNode.getItem().getClass().getName() + "_" + pathParts[pos]) > 0) { + if ((ct.getClass().getName() + "_" + expName).compareTo(addNodeName) > 0) { break; } } @@ -1157,25 +1137,15 @@ public final class SWF implements TreeItem, Timelined { } ret.addAll(frames); for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).getItem() instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).getItem() instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).getItem() instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - /*if (ret.get(i).tag instanceof DoInitActionTag) { - //((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - }*/ - if (ret.get(i).getItem() instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).getItem(); + TreeNode node = ret.get(i); + TreeItem item = node.getItem(); + if (item instanceof ASMSource) { + ASMSource ass = (ASMSource) item; if (ass.containsSource()) { continue; } } - if (ret.get(i).subNodes.isEmpty()) { + if (node.subNodes.isEmpty()) { ret.remove(i); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 5cc176d4d..2d7ed7de5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -205,6 +205,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { return pathParts[pathParts.length - 1]; } + @Override public GraphTextWriter getActionSourcePrefix(GraphTextWriter writer) { return writer; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java index dc9dfc260..75a0c840a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java @@ -12,16 +12,13 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.helpers.ByteArrayRange; -import java.util.ArrayList; -import java.util.List; /** * @@ -34,11 +31,7 @@ public abstract class CharacterIdTag extends Tag { } public abstract int getCharacterId(); - /** - * List of ExportAssetsTag used for converting to String - */ - @Internal - public List exportAssetsTags = new ArrayList<>(); + protected String exportName; public void setExportName(String exportName) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java index a8435841e..9151fa5d1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.treeitems; import com.jpexs.decompiler.flash.SWF; @@ -48,7 +49,7 @@ public class FrameNodeItem implements TreeItem { @Override public String toString() { - return "frame " + frame; + return "frame " + (frame + 1); } public int getFrame() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TagNode.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TagNode.java index 6766af776..7ea8712d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TagNode.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TagNode.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.treenodes; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -51,39 +52,30 @@ public class TagNode extends ContainerNode { return (Tag) item; } - public static void setExport(List nodeList, boolean export) { - for (TreeNode node : nodeList) { - node.export = export; - setExport(node.subNodes, export); - } - } - public static int getTagCountRecursive(List nodeList) { int count = 0; for (TreeNode node : nodeList) { - if (node.subNodes.isEmpty()) { - if ((node.item instanceof ASMSource) && (node.export)) { - count += 1; - } - } else { + if (node.item instanceof ASMSource) { + count += 1; + } + if (!node.subNodes.isEmpty()) { count += getTagCountRecursive(node.subNodes); } - } return count; } - public static List exportNodeAS(final AbortRetryIgnoreHandler handler, final List nodeList, final String outdir, final ScriptExportMode exportMode, final EventListener ev) throws IOException { + public static List exportNodeAS(final AbortRetryIgnoreHandler handler, final List nodesList, final List nodesToExport, final String outdir, final ScriptExportMode exportMode, final EventListener ev) throws IOException { try { List result = CancellableWorker.call(new Callable>() { @Override public List call() throws Exception { AtomicInteger cnt = new AtomicInteger(1); - int totalCount = TagNode.getTagCountRecursive(nodeList); - return exportNodeAS(handler, nodeList, outdir, exportMode, cnt, totalCount, ev); + int totalCount = TagNode.getTagCountRecursive(nodesToExport); + return exportNodeAS(handler, nodesList, nodesToExport, false, outdir, exportMode, cnt, totalCount, ev); } }, Configuration.exportTimeout.get(), TimeUnit.SECONDS); return result; @@ -92,14 +84,14 @@ public class TagNode extends ContainerNode { return new ArrayList<>(); } - private static List exportNodeAS(AbortRetryIgnoreHandler handler, List nodeList, String outdir, ScriptExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException { + private static List exportNodeAS(AbortRetryIgnoreHandler handler, List nodesList, List nodesToExport, boolean exportAll, String outdir, ScriptExportMode exportMode, AtomicInteger index, int count, EventListener ev) throws IOException { File dir = new File(outdir); List ret = new ArrayList<>(); if (!outdir.endsWith(File.separator)) { outdir += File.separator; } List existingNames = new ArrayList<>(); - for (TreeNode node : nodeList) { + for (TreeNode node : nodesList) { String name = ""; if (node.item instanceof Exportable) { name = Helper.makeFileName(((Exportable) node.item).getExportFileName()); @@ -113,76 +105,76 @@ public class TagNode extends ContainerNode { name = baseName + "_" + i; } existingNames.add(name); - if (node.subNodes.isEmpty()) { - if ((node.item instanceof ASMSource) && (node.export)) { - boolean retry; - do { - retry = false; - try { - int currentIndex = index.getAndIncrement(); + boolean exportNode = nodesToExport.contains(node); + if (node.item instanceof ASMSource && (exportAll || exportNode)) { + boolean retry; + do { + retry = false; + try { + int currentIndex = index.getAndIncrement(); - if (!dir.exists()) { - if (!dir.mkdirs()) { - if (!dir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - - String f = outdir + name + ".as"; - if (ev != null) { - ev.handleEvent("exporting", "Exporting " + currentIndex + "/" + count + " " + f); - } - - long startTime = System.currentTimeMillis(); - - File file = new File(f); - ASMSource asm = ((ASMSource) node.item); - try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) { - if (exportMode == ScriptExportMode.HEX) { - asm.getActionSourcePrefix(writer); - asm.getActionBytesAsHex(writer); - asm.getActionSourceSuffix(writer); - } else if (exportMode != ScriptExportMode.AS) { - asm.getActionSourcePrefix(writer); - asm.getASMSource(exportMode, writer, null); - asm.getActionSourceSuffix(writer); - } else { - List as = asm.getActions(); - Action.setActionsAddresses(as, 0); - Action.actionsToSource(asm, as, ""/*FIXME*/, writer); - } - } - - long stopTime = System.currentTimeMillis(); - - if (ev != null) { - long time = stopTime - startTime; - ev.handleEvent("exported", "Exported " + currentIndex + "/" + count + " " + f + ", " + Helper.formatTimeSec(time)); - } - - ret.add(file); - } catch (InterruptedException ex) { - } catch (IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) { - Logger.getLogger(TagNode.class.getName()).log(Level.SEVERE, "Decompilation error in file: " + name + ".as", ex); - if (handler != null) { - int action = handler.getNewInstance().handle(ex); - switch (action) { - case AbortRetryIgnoreHandler.ABORT: - throw ex; - case AbortRetryIgnoreHandler.RETRY: - retry = true; - break; - case AbortRetryIgnoreHandler.IGNORE: - retry = false; - break; + if (!dir.exists()) { + if (!dir.mkdirs()) { + if (!dir.exists()) { + throw new IOException("Cannot create directory " + outdir); } } } - } while (retry); - } - } else { - ret.addAll(exportNodeAS(handler, node.subNodes, outdir + name, exportMode, index, count, ev)); + + String f = outdir + name + ".as"; + if (ev != null) { + ev.handleEvent("exporting", "Exporting " + currentIndex + "/" + count + " " + f); + } + + long startTime = System.currentTimeMillis(); + + File file = new File(f); + ASMSource asm = ((ASMSource) node.item); + try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) { + if (exportMode == ScriptExportMode.HEX) { + asm.getActionSourcePrefix(writer); + asm.getActionBytesAsHex(writer); + asm.getActionSourceSuffix(writer); + } else if (exportMode != ScriptExportMode.AS) { + asm.getActionSourcePrefix(writer); + asm.getASMSource(exportMode, writer, null); + asm.getActionSourceSuffix(writer); + } else { + List as = asm.getActions(); + Action.setActionsAddresses(as, 0); + Action.actionsToSource(asm, as, ""/*FIXME*/, writer); + } + } + + long stopTime = System.currentTimeMillis(); + + if (ev != null) { + long time = stopTime - startTime; + ev.handleEvent("exported", "Exported " + currentIndex + "/" + count + " " + f + ", " + Helper.formatTimeSec(time)); + } + + ret.add(file); + } catch (InterruptedException ex) { + } catch (IOException | OutOfMemoryError | TranslateException | StackOverflowError ex) { + Logger.getLogger(TagNode.class.getName()).log(Level.SEVERE, "Decompilation error in file: " + name + ".as", ex); + if (handler != null) { + int action = handler.getNewInstance().handle(ex); + switch (action) { + case AbortRetryIgnoreHandler.ABORT: + throw ex; + case AbortRetryIgnoreHandler.RETRY: + retry = true; + break; + case AbortRetryIgnoreHandler.IGNORE: + retry = false; + break; + } + } + } + } while (retry); + } + if (!node.subNodes.isEmpty()) { + ret.addAll(exportNodeAS(handler, node.subNodes, nodesToExport, exportAll || exportNode, outdir + name, exportMode, index, count, ev)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java index 01aec426d..6c9ea5379 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treenodes/TreeNode.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.treenodes; import com.jpexs.decompiler.flash.treeitems.TreeItem; @@ -28,7 +29,6 @@ import java.util.logging.Logger; public abstract class TreeNode { protected TreeItem item; - public boolean export = false; public List subNodes; public TreeNode(TreeItem item) { @@ -51,13 +51,4 @@ public abstract class TreeNode { } return item.toString(); } - - public List getAllSubs() { - List ret = new ArrayList<>(); - ret.addAll(subNodes); - for (TreeNode n : subNodes) { - ret.addAll(n.getAllSubs()); - } - return ret; - } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index dfbd1ad7a..2c908b3ff 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1060,7 +1060,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec FrameNodeItem fni = (FrameNodeItem) d.getItem(); Timelined parent = fni.getParent(); - int frame = fni.getFrame() - 1; //Fix to zero based + int frame = fni.getFrame(); int parentId = 0; if (parent instanceof CharacterTag) { parentId = ((CharacterTag) parent).getCharacterId(); @@ -1109,25 +1109,17 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec new FramesExportSettings(export.getValue(FramesExportMode.class), export.getZoom()))); } List abcList = swf.abcList; - if (abcPanel != null) { + if (swf.isAS3) { for (int i = 0; i < as3scripts.size(); i++) { ScriptPack tls = as3scripts.get(i); Main.startWork(translate("work.exporting") + " " + (i + 1) + "/" + as3scripts.size() + " " + tls.getPath() + " ..."); ret.add(tls.export(selFile, abcList, scriptMode, Configuration.parallelSpeedUp.get())); } } else { - List allNodes = new ArrayList<>(); - List allAs12Scripts = new ArrayList<>(); - - if (abcPanel == null) { - allAs12Scripts = getASTreeNodes(tagTree); - } - for (TreeNode asn : allAs12Scripts) { - allNodes.add(asn); - TagNode.setExport(allNodes, false); - TagNode.setExport(as12scripts, true); - ret.addAll(TagNode.exportNodeAS(handler, allNodes, selFile, scriptMode, null)); - } + TagTreeModel ttm = (TagTreeModel) tagTree.getModel(); + List scriptNodeList = new ArrayList<>(1); + scriptNodeList.add(ttm.getSwfNode(swf).scriptsNode); + ret.addAll(TagNode.exportNodeAS(handler, scriptNodeList, as12scripts, selFile, scriptMode, null)); } } return ret; @@ -2417,7 +2409,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec totalFrameCount = parentSprite.frameCount; timelined = parentSprite; } - previewPanel.showImagePanel(timelined, swf, fn.getFrame() - 1); + previewPanel.showImagePanel(timelined, swf, fn.getFrame()); } else if ((tagObj instanceof SoundTag)) { //&& isInternalFlashViewerSelected() && (Arrays.asList("mp3", "wav").contains(((SoundTag) tagObj).getExportFormat())))) { showCard(CARDPREVIEWPANEL); previewPanel.showImagePanel(new SerializableImage(View.loadImage("sound32"))); diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewImage.java b/src/com/jpexs/decompiler/flash/gui/PreviewImage.java index a8ccd1ecd..ad7cfcc46 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewImage.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewImage.java @@ -176,7 +176,7 @@ public class PreviewImage extends JPanel { if (treeItem instanceof FrameNodeItem) { FrameNodeItem fn = (FrameNodeItem) treeItem; RECT rect = swf.displayRect; - imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame() - 1, 0, null, 0, rect, new Matrix(), new ColorTransform(), null, true, 1.0); + imgSrc = SWF.frameToImageGet(swf.getTimeline(), fn.getFrame(), 0, null, 0, rect, new Matrix(), new ColorTransform(), null, true, 1.0); width = (imgSrc.getWidth()); height = (imgSrc.getHeight()); } else if (treeItem instanceof ImageTag) { diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index b41efc119..5a8ac889c 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -530,7 +530,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { Timelined parent = fn.getParent(); List subs = parent.getTimeline().tags; List doneCharacters = new ArrayList<>(); - int frameCnt = 1; + int frameCnt = 0; for (ContainerItem item : subs) { if (item instanceof ShowFrameTag) { frameCnt++; diff --git a/src/com/jpexs/decompiler/flash/gui/TagTree.java b/src/com/jpexs/decompiler/flash/gui/TagTree.java index e606f4521..598572548 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTree.java @@ -499,7 +499,7 @@ public class TagTree extends JTree implements ActionListener { tagsToRemove.add((Tag) tag); } else if (tag instanceof FrameNodeItem) { FrameNodeItem frameNode = (FrameNodeItem) tag; - Frame frame = frameNode.getParent().getTimeline().frames.get(frameNode.getFrame() - 1); + Frame frame = frameNode.getParent().getTimeline().frames.get(frameNode.getFrame()); if (frame.showFrameTag != null) { tagsToRemove.add(frame.showFrameTag); } else { diff --git a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 7086890f2..482dab457 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -89,9 +89,7 @@ public class TagTreeModel implements TreeModel { } public SWFNode createSwfNode(SWF swf) { - ClassesListTreeModel classTreeModel = new ClassesListTreeModel(swf); - SWFNode swfNode = new SWFNode(swf, swf.getShortFileName()); - swfNode.list = createTagList(swf.tags, swf, swfNode, classTreeModel); + SWFNode swfNode = createTagList(swf.tags, swf); swfToSwfNode.put(swf, swfNode); return swfNode; } @@ -110,10 +108,13 @@ public class TagTreeModel implements TreeModel { return ret; } - private List createTagList(List list, SWF swf, SWFNode swfNode, ClassesListTreeModel classTreeModel) { + private SWFNode createTagList(List list, SWF swf) { + ClassesListTreeModel classTreeModel = new ClassesListTreeModel(swf); + SWFNode swfNode = new SWFNode(swf, swf.getShortFileName()); + boolean hasAbc = swf.abcList != null && !swf.abcList.isEmpty(); - List ret = new ArrayList<>(); + List nodeList = new ArrayList<>(); List frames = new ArrayList<>(); List shapes = new ArrayList<>(); List morphShapes = new ArrayList<>(); @@ -176,7 +177,7 @@ public class TagTreeModel implements TreeModel { Timeline timeline = swf.getTimeline(); for (int i = 0; i < timeline.getFrameCount(); i++) { - frames.add(new FrameNode(new FrameNodeItem(swf, i + 1, swf, true), timeline.frames.get(i).innerTags, false)); + frames.add(new FrameNode(new FrameNodeItem(swf, i, swf, true), timeline.frames.get(i).innerTags, false)); } for (int i = 0; i < sounds.size(); i++) { @@ -239,50 +240,51 @@ public class TagTreeModel implements TreeModel { } swfNode.scriptsNode = actionScriptNode; - ret.add(new HeaderNode(new HeaderItem(swf, AppStrings.translate("node.header")))); + nodeList.add(new HeaderNode(new HeaderItem(swf, AppStrings.translate("node.header")))); if (!shapesNode.subNodes.isEmpty()) { - ret.add(shapesNode); + nodeList.add(shapesNode); } if (!morphShapesNode.subNodes.isEmpty()) { - ret.add(morphShapesNode); + nodeList.add(morphShapesNode); } if (!spritesNode.subNodes.isEmpty()) { - ret.add(spritesNode); + nodeList.add(spritesNode); } if (!textsNode.subNodes.isEmpty()) { - ret.add(textsNode); + nodeList.add(textsNode); } if (!imagesNode.subNodes.isEmpty()) { - ret.add(imagesNode); + nodeList.add(imagesNode); } if (!moviesNode.subNodes.isEmpty()) { - ret.add(moviesNode); + nodeList.add(moviesNode); } if (!soundsNode.subNodes.isEmpty()) { - ret.add(soundsNode); + nodeList.add(soundsNode); } if (!buttonsNode.subNodes.isEmpty()) { - ret.add(buttonsNode); + nodeList.add(buttonsNode); } if (!fontsNode.subNodes.isEmpty()) { - ret.add(fontsNode); + nodeList.add(fontsNode); } if (!binaryDataNode.subNodes.isEmpty()) { - ret.add(binaryDataNode); + nodeList.add(binaryDataNode); } if (!framesNode.subNodes.isEmpty()) { - ret.add(framesNode); + nodeList.add(framesNode); } if (!otherNode.subNodes.isEmpty()) { - ret.add(otherNode); + nodeList.add(otherNode); } if ((!actionScriptNode.subNodes.isEmpty()) || hasAbc) { - ret.add(actionScriptNode); + nodeList.add(actionScriptNode); } - return ret; + swfNode.list = nodeList; + return swfNode; } private List createSubTagList(List list, Timelined parent, SWF swf, List actionScriptTags) { @@ -305,7 +307,7 @@ public class TagTreeModel implements TreeModel { Timeline timeline = ((Timelined) parent).getTimeline(); for (int i = 0; i < timeline.getFrameCount(); i++) { - frames.add(new FrameNode(new FrameNodeItem(swf, i + 1, parent, true), timeline.frames.get(i).innerTags, false)); + frames.add(new FrameNode(new FrameNodeItem(swf, i, parent, true), timeline.frames.get(i).innerTags, false)); } ret.addAll(frames);