From c4df6c7ace36adfc4f14153ff60305c368c3af3b Mon Sep 17 00:00:00 2001 From: honfika Date: Thu, 29 May 2014 23:20:10 +0200 Subject: [PATCH] removing frame fixed --- src/com/jpexs/decompiler/flash/SWF.java | 8 ++++---- .../jpexs/decompiler/flash/gui/MainPanel.java | 17 ++++++++++------ .../decompiler/flash/gui/PreviewPanel.java | 13 +++--------- .../decompiler/flash/gui/TagTreeModel.java | 20 +++++++++---------- .../decompiler/flash/timeline/Frame.java | 2 ++ .../decompiler/flash/timeline/Timeline.java | 1 + .../flash/treeitems/FrameNodeItem.java | 8 ++++---- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/SWF.java b/src/com/jpexs/decompiler/flash/SWF.java index 8180bade2..c55061326 100644 --- a/src/com/jpexs/decompiler/flash/SWF.java +++ b/src/com/jpexs/decompiler/flash/SWF.java @@ -1052,7 +1052,7 @@ public final class SWF implements TreeItem, Timelined { return ret; } - public static List createASTagList(List list, Tag parent) { + public static List createASTagList(List list, Timelined parent) { List ret = new ArrayList<>(); int frame = 1; List frames = new ArrayList<>(); @@ -1093,8 +1093,8 @@ public final class SWF implements TreeItem, Timelined { ContainerNode tti = new ContainerNode(t); List subItems = ((Container) t).getSubItems(); - Tag tag = t instanceof Tag ? (Tag) t : null; - tti.subNodes = createASTagList(subItems, tag); + Timelined timelined = t instanceof Timelined ? (Timelined) t : null; + tti.subNodes = createASTagList(subItems, timelined); addNode = tti; //ret.add(tti); } @@ -2945,7 +2945,7 @@ public final class SWF implements TreeItem, Timelined { tags.remove(t); timelined.resetTimeline(); } else { - // timeline shuold be always the swf here + // timeline should be always the swf here if (removeDependencies) { removeTagWithDependenciesFromTimeline(t, timelined.getTimeline()); } else { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index f9bc09117..4b7056e0c 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1242,11 +1242,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (!fn.scriptsNode) { FrameNodeItem fni = (FrameNodeItem) d.getItem(); - Tag par = fni.getParent(); + Timelined parent = fni.getParent(); int frame = fni.getFrame() - 1; //Fix to zero based int parentId = 0; - if (par != null) { - parentId = ((CharacterTag) par).getCharacterId(); + if (parent instanceof CharacterTag) { + parentId = ((CharacterTag) parent).getCharacterId(); } if (!frames.containsKey(parentId)) { frames.put(parentId, new ArrayList()); @@ -2252,9 +2252,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (tag instanceof Tag) { tagsToRemove.add((Tag) tag); } else if (tag instanceof FrameNodeItem) { - FrameNodeItem frame = (FrameNodeItem) tag; - // todo: honfika: remove frame - //tagsToRemove.add(frame.getShowFrameTag()); + FrameNodeItem frameNode = (FrameNodeItem) tag; + Frame frame = frameNode.getParent().getTimeline().frames.get(frameNode.getFrame() - 1); + if (frame.showFrameTag != null) { + tagsToRemove.add(frame.showFrameTag); + } else { + // this should be the last frame, so remove the inner tags + tagsToRemove.addAll(frame.innerTags); + } } } diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 8bfb93479..bece97e9b 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -476,7 +476,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { if (tagObj instanceof FrameNodeItem) { FrameNodeItem fn = (FrameNodeItem) tagObj; swf = fn.getSwf(); - if (fn.getParent() == null) { + if (fn.getParent() == swf) { for (Tag t : swf.tags) { if (t instanceof SetBackgroundColorTag) { backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor(); @@ -530,15 +530,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener { if (tagObj instanceof FrameNodeItem) { FrameNodeItem fn = (FrameNodeItem) tagObj; - Tag parent = fn.getParent(); - List subs = new ArrayList<>(); - if (parent == null) { - subs.addAll(swf.tags); - } else { - if (parent instanceof Container) { - subs = ((Container) parent).getSubItems(); - } - } + Timelined parent = fn.getParent(); + List subs = parent.getTimeline().tags; List doneCharacters = new ArrayList<>(); int frameCnt = 1; for (ContainerItem item : subs) { diff --git a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 18d72c37e..e9527330b 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -93,7 +93,7 @@ public class TagTreeModel implements TreeModel { private SWFNode createSwfNode(SWF swf) { ClassesListTreeModel classTreeModel = new ClassesListTreeModel(swf); SWFNode swfNode = new SWFNode(swf, swf.getShortFileName()); - swfNode.list = createTagList(swf.tags, null, swf, swfNode, classTreeModel); + swfNode.list = createTagList(swf.tags, swf, swfNode, classTreeModel); swfToSwfNode.put(swf, swfNode); return swfNode; } @@ -102,7 +102,7 @@ public class TagTreeModel implements TreeModel { return mainFrame.translate(key); } - private List createTagList(List list, Tag parent, SWF swf, SWFNode swfNode, ClassesListTreeModel classTreeModel) { + private List createTagList(List list, SWF swf, SWFNode swfNode, ClassesListTreeModel classTreeModel) { boolean hasAbc = swf.abcList != null && !swf.abcList.isEmpty(); List ret = new ArrayList<>(); @@ -179,7 +179,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, parent, true), timeline.frames.get(i).innerTags, false)); + frames.add(new FrameNode(new FrameNodeItem(swf, i + 1, swf, true), timeline.frames.get(i).innerTags, false)); } for (int i = 0; i < sounds.size(); i++) { @@ -193,8 +193,8 @@ public class TagTreeModel implements TreeModel { } for (TreeNode n : sprites) { - Tag tag = n.getItem() instanceof Tag ? (Tag) n.getItem() : null; - n.subNodes = createSubTagList(((DefineSpriteTag) n.getItem()).subTags, tag, swf, actionScriptTags); + Timelined timelined = n.getItem() instanceof Timelined ? (Timelined) n.getItem() : null; + n.subNodes = createSubTagList(((DefineSpriteTag) n.getItem()).subTags, timelined, swf, actionScriptTags); } StringNode textsNode = new StringNode(new StringItem(translate("node.texts"), FOLDER_TEXTS, swf)); @@ -286,7 +286,7 @@ public class TagTreeModel implements TreeModel { return ret; } - private List createSubTagList(List list, Tag parent, SWF swf, List actionScriptTags) { + private List createSubTagList(List list, Timelined parent, SWF swf, List actionScriptTags) { List ret = new ArrayList<>(); List frames = new ArrayList<>(); List others = new ArrayList<>(); @@ -304,11 +304,9 @@ public class TagTreeModel implements TreeModel { } } - if (parent instanceof Timelined) { - 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)); - } + 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)); } ret.addAll(frames); diff --git a/src/com/jpexs/decompiler/flash/timeline/Frame.java b/src/com/jpexs/decompiler/flash/timeline/Frame.java index 5344aa9b8..702680792 100644 --- a/src/com/jpexs/decompiler/flash/timeline/Frame.java +++ b/src/com/jpexs/decompiler/flash/timeline/Frame.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.tags.DoActionTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; @@ -37,6 +38,7 @@ public class Frame { public List sounds = new ArrayList<>(); public List soundClasses = new ArrayList<>(); public List innerTags = new ArrayList<>(); + public ShowFrameTag showFrameTag = null; // can be null for the last frame public Frame(Timeline timeline) { this.timeline = timeline; diff --git a/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 33f2aa284..609ec911f 100644 --- a/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -178,6 +178,7 @@ public class Timeline { tagAdded = true; } if (t instanceof ShowFrameTag) { + frame.showFrameTag = (ShowFrameTag) t; frames.add(frame); frame = new Frame(frame); tagAdded = false; diff --git a/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java b/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java index d65cd9cd8..3a0817e0f 100644 --- a/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java +++ b/src/com/jpexs/decompiler/flash/treeitems/FrameNodeItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.treeitems; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.timeline.Timelined; /** * @@ -27,10 +27,10 @@ public class FrameNodeItem implements TreeItem { private final SWF swf; private final int frame; - private final Tag parent; + private final Timelined parent; private final boolean display; - public FrameNodeItem(SWF swf, int frame, Tag parent, boolean display) { + public FrameNodeItem(SWF swf, int frame, Timelined parent, boolean display) { this.swf = swf; this.frame = frame; @@ -56,7 +56,7 @@ public class FrameNodeItem implements TreeItem { return frame; } - public Tag getParent() { + public Timelined getParent() { return parent; } }