From a4cd36fd71af8bcdfff7679d3bf30056221f0510 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 7 Dec 2014 20:53:14 +0100 Subject: [PATCH] #742 Can't edit frames fixed, Container/ContainerItems refactored, build fixed on linux (Pull request #12) --- .../src/com/jpexs/decompiler/flash/SWF.java | 104 ++++++++++-------- .../flash/tags/DefineButton2Tag.java | 14 +-- .../flash/tags/DefineSpriteTag.java | 23 +--- .../flash/tags/PlaceObject2Tag.java | 17 +-- .../flash/tags/PlaceObject3Tag.java | 17 +-- .../flash/tags/PlaceObject4Tag.java | 17 +-- .../flash/tags/SoundStreamHeadTag.java | 7 +- .../com/jpexs/decompiler/flash/tags/Tag.java | 3 +- ...Container.java => ASMSourceContainer.java} | 11 +- .../flash/tags/base/ContainerItem.java | 27 ----- .../decompiler/flash/timeline/AS3Package.java | 2 +- .../flash/types/BUTTONCONDACTION.java | 3 +- .../flash/types/CLIPACTIONRECORD.java | 3 +- .../flash/gui/GenericTagTreePanel.java | 5 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 26 ++--- .../decompiler/flash/gui/PreviewPanel.java | 8 +- .../decompiler/flash/gui/tagtree/TagTree.java | 26 ++--- .../flash/gui/tagtree/TagTreeModel.java | 11 +- 18 files changed, 115 insertions(+), 209 deletions(-) rename libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/{Container.java => ASMSourceContainer.java} (81%) delete mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java 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 80ce9cd03..af33def5b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -104,12 +104,11 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.TagStub; import com.jpexs.decompiler.flash.tags.VideoFrameTag; import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.Container; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; @@ -283,7 +282,7 @@ public final class SWF implements SWFContainerItem, Timelined { public void updateCharacters() { characters.clear(); - parseCharacters(new ArrayList(tags)); + parseCharacters(tags); } public int getNextCharacterId() { @@ -363,13 +362,13 @@ public final class SWF implements SWFContainerItem, Timelined { } } - private void parseCharacters(List list) { - for (ContainerItem t : list) { + private void parseCharacters(List list) { + for (Tag t : list) { if (t instanceof CharacterTag) { characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t); } - if (t instanceof Container) { - parseCharacters(((Container) t).getSubItems()); + if (t instanceof DefineSpriteTag) { + parseCharacters(((DefineSpriteTag) t).getSubTags()); } } } @@ -693,10 +692,10 @@ public final class SWF implements SWFContainerItem, Timelined { abcList = newAbcList; } - private static void getABCTags(List list, List actionScripts) { - for (ContainerItem t : list) { - if (t instanceof Container) { - getABCTags(((Container) t).getSubItems(), actionScripts); + private static void getABCTags(List list, List actionScripts) { + for (Tag t : list) { + if (t instanceof DefineSpriteTag) { + getABCTags(((DefineSpriteTag) t).getSubTags(), actionScripts); } if (t instanceof ABCContainerTag) { actionScripts.add((ABCContainerTag) t); @@ -1084,23 +1083,32 @@ public final class SWF implements SWFContainerItem, Timelined { return asms; } - private static void getASMs(String path, List items, Map asms) { - for (ContainerItem item : items) { - String subPath = path + "/" + item.toString(); - if (item instanceof ASMSource) { - String npath = subPath; - int ppos = 1; - while (asms.containsKey(npath)) { - ppos++; - npath = subPath + "[" + ppos + "]"; - } - asms.put(npath, (ASMSource) item); + private static void getASMs(String path, List items, Map asms) { + for (Tag t : items) { + String subPath = path + "/" + t.toString(); + if (t instanceof ASMSource) { + addASM(asms, (ASMSource) t, subPath); } - if (item instanceof Container) { - getASMs(subPath, ((Container) item).getSubItems(), asms); + if (t instanceof ASMSourceContainer) { + for (ASMSource asm : ((ASMSourceContainer) t).getSubItems()) { + addASM(asms, asm, subPath + "/" + asm.toString()); + } + } + if (t instanceof DefineSpriteTag) { + getASMs(subPath, ((DefineSpriteTag) t).getSubTags(), asms); } } } + + private static void addASM(Map asms, ASMSource asm, String path) { + String npath = path; + int ppos = 1; + while (asms.containsKey(npath)) { + ppos++; + npath = path + "[" + ppos + "]"; + } + asms.put(npath, asm); + } private final HashSet listeners = new HashSet<>(); @@ -1142,13 +1150,13 @@ public final class SWF implements SWFContainerItem, Timelined { return false; } - public static void populateVideoFrames(int streamId, List tags, HashMap output) { - for (ContainerItem t : tags) { + public static void populateVideoFrames(int streamId, List tags, HashMap output) { + for (Tag t : tags) { if (t instanceof VideoFrameTag) { output.put(((VideoFrameTag) t).frameNum, (VideoFrameTag) t); } - if (t instanceof Container) { - populateVideoFrames(streamId, ((Container) t).getSubItems(), output); + if (t instanceof DefineSpriteTag) { + populateVideoFrames(streamId, ((DefineSpriteTag) t).getSubTags(), output); } } } @@ -1784,27 +1792,37 @@ public final class SWF implements SWFContainerItem, Timelined { } private HashMap actionsMap = new HashMap<>(); - private void getVariables(List objs, String path) throws InterruptedException { + private void getVariables(List tags, String path) throws InterruptedException { List processed = new ArrayList<>(); - for (ContainerItem o : objs) { - if (o instanceof ASMSource) { - String infPath = path + "/" + o.toString(); - int pos = 1; - String infPath2 = infPath; - while (processed.contains(infPath2)) { - pos++; - infPath2 = infPath + "[" + pos + "]"; - } - processed.add(infPath2); - informListeners("getVariables", infPath2); - getVariables(allVariableNames, allFunctions, allStrings, usageTypes, (ASMSource) o, path); + for (Tag t : tags) { + String subPath = path + "/" + t.toString(); + if (t instanceof ASMSource) { + addVariable((ASMSource) t, subPath, processed); } - if (o instanceof Container) { - getVariables(((Container) o).getSubItems(), path + "/" + o.toString()); + if (t instanceof ASMSourceContainer) { + List processed2 = new ArrayList<>(); + for (ASMSource asm : ((ASMSourceContainer) t).getSubItems()) { + addVariable(asm, subPath + "/" + asm.toString(), processed2); + } + } + if (t instanceof DefineSpriteTag) { + getVariables(((DefineSpriteTag) t).getSubTags(), path + "/" + t.toString()); } } } + private void addVariable(ASMSource asm, String path, List processed) throws InterruptedException { + int pos = 1; + String infPath2 = path; + while (processed.contains(infPath2)) { + pos++; + infPath2 = path + "[" + pos + "]"; + } + processed.add(infPath2); + informListeners("getVariables", infPath2); + getVariables(allVariableNames, allFunctions, allStrings, usageTypes, asm, path); + } + public int deobfuscateAS3Identifiers(RenameType renameType) { for (Tag tag : tags) { if (tag instanceof ABCContainerTag) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index 606ef1666..45524dd38 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -21,10 +21,10 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.timeline.Frame; import com.jpexs.decompiler.flash.timeline.Timeline; @@ -52,7 +52,7 @@ import java.util.Set; * * @author JPEXS */ -public class DefineButton2Tag extends ButtonTag implements Container { +public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { /** * ID for this character @@ -171,16 +171,6 @@ public class DefineButton2Tag extends ButtonTag implements Container { return actions; } - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - @Override - public int getItemCount() { - return actions.size(); - } - @Override public void getNeededCharacters(Set needed) { for (BUTTONRECORD r : characters) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 2e02ca214..747f39a99 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.timeline.DepthState; @@ -56,7 +55,7 @@ import java.util.Set; /** * Defines a sprite character */ -public class DefineSpriteTag extends CharacterTag implements Container, DrawableTag, Timelined { +public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timelined { /** * Character ID of sprite @@ -249,26 +248,6 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable return baos.toByteArray(); } - /** - * Returns all sub-items - * - * @return List of sub-items - */ - @Override - public List getSubItems() { - return subTags; - } - - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - @Override - public int getItemCount() { - return subTags.size(); - } - @Override public boolean hasSubTags() { return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 5658a4849..6eb2ba0a0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -21,8 +21,8 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; -import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; @@ -49,7 +49,7 @@ import java.util.Set; * * @author JPEXS */ -public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag { +public class PlaceObject2Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag { /** * @since SWF 5 Has clip actions (sprite characters only) @@ -276,19 +276,6 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO return new ArrayList<>(); } - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - @Override - public int getItemCount() { - if (!placeFlagHasClipActions) { - return 0; - } - return clipActions.clipActionRecords.size(); - } - @Override public void getNeededCharacters(Set needed) { if (placeFlagHasCharacter) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index fe3f2d49c..2e35075e4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; -import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; @@ -51,7 +51,7 @@ import java.util.Set; * * @author JPEXS */ -public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag { +public class PlaceObject3Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag { /** * @since SWF 5 has clip actions (sprite characters only) @@ -395,19 +395,6 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO return new ArrayList<>(); } - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - @Override - public int getItemCount() { - if (!placeFlagHasClipActions) { - return 0; - } - return clipActions.clipActionRecords.size(); - } - @Override public void getNeededCharacters(Set needed) { if (placeFlagHasCharacter) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index 02e109734..dda07f7a7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -22,8 +22,8 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; -import com.jpexs.decompiler.flash.tags.base.Container; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; @@ -51,7 +51,7 @@ import java.util.Set; * * @author JPEXS */ -public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceObjectTypeTag { +public class PlaceObject4Tag extends CharacterIdTag implements ASMSourceContainer, PlaceObjectTypeTag { /** * @since SWF 5 has clip actions (sprite characters only) @@ -398,19 +398,6 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO return new ArrayList<>(); } - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - @Override - public int getItemCount() { - if (!placeFlagHasClipActions) { - return 0; - } - return clipActions.clipActionRecords.size(); - } - @Override public void getNeededCharacters(Set needed) { if (placeFlagHasCharacter) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index 8668721fd..f37e5bb32 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.annotations.Conditional; @@ -180,9 +179,9 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea return streamSoundType; } - public static void populateSoundStreamBlocks(int containerId, List tags, SoundStreamHeadTypeTag head, List output) { + public static void populateSoundStreamBlocks(int containerId, List tags, SoundStreamHeadTypeTag head, List output) { boolean found = false; - for (ContainerItem t : tags) { + for (Tag t : tags) { if (t == head) { found = true; head.setVirtualCharacterId(containerId); @@ -190,7 +189,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea } if (t instanceof DefineSpriteTag) { DefineSpriteTag sprite = (DefineSpriteTag) t; - populateSoundStreamBlocks(sprite.getCharacterId(), sprite.getSubItems(), head, output); + populateSoundStreamBlocks(sprite.getCharacterId(), sprite.getSubTags(), head, output); } if (!found) { continue; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index 0a4fc94b1..0aa10bea8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.tags.base.NeedsCharacters; import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont; @@ -45,7 +44,7 @@ import java.util.Set; /** * Represents Tag inside SWF file */ -public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializable { +public abstract class Tag implements NeedsCharacters, Exportable, Serializable { /** * Identifier of tag type diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/Container.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSourceContainer.java similarity index 81% rename from libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/Container.java rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSourceContainer.java index 40a592bc4..9417d6e4d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/Container.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSourceContainer.java @@ -24,19 +24,12 @@ import java.util.List; * * @author JPEXS */ -public interface Container extends TreeItem { +public interface ASMSourceContainer extends TreeItem { /** * Returns all sub-items * * @return List of sub-items */ - public List getSubItems(); - - /** - * Returns number of sub-items - * - * @return Number of sub-items - */ - public int getItemCount(); + public List getSubItems(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java deleted file mode 100644 index 00eb3f112..000000000 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ContainerItem.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2010-2014 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.tags.base; - -import com.jpexs.decompiler.flash.treeitems.TreeItem; - -/** - * Object which contains other objects - * - * @author JPEXS - */ -public interface ContainerItem extends TreeItem { - -} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java index ac8a0c29f..cdfff4efb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java @@ -76,7 +76,7 @@ public class AS3Package extends AS3ClassTreeItem { int res = 0; if (child instanceof AS3Package) { for (AS3Package pkg : subPackages.values()) { - if (pkg.equals(child)) { + if (pkg.packageName.equals(((AS3Package) child).packageName)) { break; } res++; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 6c78fef7a..faf09f495 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; @@ -45,7 +44,7 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, Serializable { +public class BUTTONCONDACTION implements ASMSource, Exportable, Serializable { private final SWF swf; private final Tag tag; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index a2f9b90bc..97ba8201f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.types.annotations.Conditional; import com.jpexs.decompiler.flash.types.annotations.Internal; @@ -44,7 +43,7 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, Serializable { +public class CLIPACTIONRECORD implements ASMSource, Exportable, Serializable { public static String keyToString(int key) { if ((key < CLIPACTIONRECORD.KEYNAMES.length) && (key > 0) && (CLIPACTIONRECORD.KEYNAMES[key] != null)) { diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 28db1a99b..6c4e58458 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFArray; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.annotations.parser.AnnotationParseException; import com.jpexs.decompiler.flash.types.annotations.parser.ConditionEvaluator; +import com.jpexs.helpers.ByteArrayRange; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -663,10 +664,10 @@ public class GenericTagTreePanel extends GenericTagPanel { SWF swf = tag.getSwf(); try { byte[] data = tag.getData(); - SWFInputStream tagDataStream = new SWFInputStream(swf, data, 0, data.length); + SWFInputStream tagDataStream = new SWFInputStream(swf, data, tag.getDataPos(), data.length); TagStub copy = new TagStub(swf, tag.getId(), "Unresolved", tag.getOriginalRange(), tagDataStream); copy.forceWriteAsLong = tag.forceWriteAsLong; - this.editedTag = SWFInputStream.resolveTag(copy, 0, false, true, false); + editedTag = SWFInputStream.resolveTag(copy, 0, false, true, false); } catch (InterruptedException ex) { } catch (IOException ex) { Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 62d83515c..0bd9f027e 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -83,7 +83,6 @@ import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.ImageTag; @@ -897,37 +896,38 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (selectedNodeSwf != swf) { continue; } - if (d instanceof ContainerItem) { - ContainerItem n = (ContainerItem) d; - TreeNodeType nodeType = TagTree.getTreeNodeType(n); + + if (d instanceof Tag || d instanceof ASMSource) { + TreeNodeType nodeType = TagTree.getTreeNodeType(d); if (nodeType == TreeNodeType.IMAGE) { - images.add((Tag) n); + images.add((Tag) d); } if (nodeType == TreeNodeType.SHAPE) { - shapes.add((Tag) n); + shapes.add((Tag) d); } if (nodeType == TreeNodeType.MORPH_SHAPE) { - morphshapes.add((Tag) n); + morphshapes.add((Tag) d); } if (nodeType == TreeNodeType.AS) { - as12scripts.add(n); + as12scripts.add(d); } if (nodeType == TreeNodeType.MOVIE) { - movies.add((Tag) n); + movies.add((Tag) d); } if (nodeType == TreeNodeType.SOUND) { - sounds.add((Tag) n); + sounds.add((Tag) d); } if (nodeType == TreeNodeType.BINARY_DATA) { - binaryData.add((Tag) n); + binaryData.add((Tag) d); } if (nodeType == TreeNodeType.TEXT) { - texts.add((Tag) n); + texts.add((Tag) d); } if (nodeType == TreeNodeType.FONT) { - fonts.add((Tag) n); + fonts.add((Tag) d); } } + if (d instanceof Frame) { Frame fn = (Frame) d; Timelined parent = fn.timeline.timelined; diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 02eb03550..c5afea211 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -48,7 +48,6 @@ import com.jpexs.decompiler.flash.tags.VideoFrameTag; import com.jpexs.decompiler.flash.tags.base.AloneTag; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; @@ -562,8 +561,8 @@ public class PreviewPanel extends JSplitPane implements ActionListener { List subs = fn.timeline.tags; List doneCharacters = new ArrayList<>(); int frameCnt = 0; - for (ContainerItem item : subs) { - if (item instanceof ShowFrameTag) { + for (Tag t : subs) { + if (t instanceof ShowFrameTag) { frameCnt++; continue; } @@ -571,12 +570,11 @@ public class PreviewPanel extends JSplitPane implements ActionListener { break; } - if (item instanceof DoActionTag || item instanceof DoInitActionTag) { + if (t instanceof DoActionTag || t instanceof DoInitActionTag) { // todo: Maybe DoABC tags should be removed, too continue; } - Tag t = (Tag) item; Set needed = new HashSet<>(); t.getNeededCharactersDeep(needed); for (int n : needed) { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index f6964b1db..1344095d9 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -94,7 +94,6 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.VideoFrameTag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.ButtonTag; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; import com.jpexs.decompiler.flash.tags.base.ImageTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; @@ -472,37 +471,38 @@ public class TagTree extends JTree { if (d.getSwf() != swf) { continue; } - if (d instanceof ContainerItem) { - ContainerItem n = (ContainerItem) d; - TreeNodeType nodeType = TagTree.getTreeNodeType(n); + + if (d instanceof Tag || d instanceof ASMSource) { + TreeNodeType nodeType = TagTree.getTreeNodeType(d); if (nodeType == TreeNodeType.IMAGE) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.SHAPE) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.MORPH_SHAPE) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.AS) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.MOVIE) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.SOUND) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.BINARY_DATA) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.TEXT) { - ret.add(n); + ret.add(d); } if (nodeType == TreeNodeType.FONT) { - ret.add(n); + ret.add(d); } } + if (d instanceof Frame) { ret.add(d); } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java index 2d8358e2e..40c52a6f4 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java @@ -27,8 +27,7 @@ import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.tags.base.Container; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; +import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag; import com.jpexs.decompiler.flash.timeline.AS2Package; import com.jpexs.decompiler.flash.timeline.AS3Package; @@ -252,11 +251,9 @@ public class TagTreeModel implements TreeModel { } if (!hasInnerFrames) { - if (tag instanceof Container) { - for (ContainerItem item : ((Container) tag).getSubItems()) { - if (item instanceof ASMSource) { - tagSubNodes.add(item); - } + if (tag instanceof ASMSourceContainer) { + for (ASMSource asm : ((ASMSourceContainer) tag).getSubItems()) { + tagSubNodes.add(asm); } } }