diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index b4c26c121..d85ea7c54 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -201,7 +201,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound; import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound; import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap; import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage; -import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag; +import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo; import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA; @@ -1365,7 +1365,7 @@ public class SWFInputStream implements AutoCloseable { if (swf.gfx) { //GFX tags only in GFX files. There may be incorrect GFX tags in non GFX files switch (tag.getId()) { case 1000: - ret = new ExporterInfoTag(sis, data); + ret = new ExporterInfo(sis, data); break; case 1001: ret = new DefineExternalImage(sis, data); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java index 04b6043d3..0986fba3d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java @@ -28,6 +28,7 @@ import java.util.logging.Logger; public class AVM2ConstantPool { + private static final Logger logger = Logger.getLogger(AVM2ConstantPool.class.getName()); public List constant_int = new ArrayList<>(); public List constant_uint = new ArrayList<>(); public List constant_double = new ArrayList<>(); @@ -122,7 +123,7 @@ public class AVM2ConstantPool { try { return constant_int.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return 0; } @@ -131,7 +132,7 @@ public class AVM2ConstantPool { try { return constant_namespace.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return null; } @@ -140,7 +141,7 @@ public class AVM2ConstantPool { try { return constant_namespace_set.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return null; } @@ -149,7 +150,7 @@ public class AVM2ConstantPool { try { return constant_multiname.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return null; } @@ -158,7 +159,7 @@ public class AVM2ConstantPool { try { return constant_uint.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return 0; } @@ -167,7 +168,7 @@ public class AVM2ConstantPool { try { return constant_double.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return 0; } @@ -176,7 +177,7 @@ public class AVM2ConstantPool { try { return constant_decimal.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return null; } @@ -185,7 +186,7 @@ public class AVM2ConstantPool { try { return constant_string.get(index); } catch (IndexOutOfBoundsException ex) { - Logger.getLogger(AVM2ConstantPool.class.getName()).log(Level.SEVERE, "Multiname not found. Index: " + index, ex); + logger.log(Level.SEVERE, "Multiname not found. Index: " + index, ex); } return null; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index cf9a1d99f..e928c5567 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -713,7 +713,7 @@ public class Action implements GraphSourceItem { } catch (InterruptedException ex) { throw ex; } catch (Exception | OutOfMemoryError | StackOverflowError ex) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex); + logger.log(Level.SEVERE, "Decompilation error in: " + path, ex); convertException = ex; Throwable cause = ex.getCause(); if (ex instanceof ExecutionException && cause instanceof Exception) { @@ -728,10 +728,10 @@ public class Action implements GraphSourceItem { if (convertException == null) { Graph.graphToString(tree, writer, new LocalData()); } else if (convertException instanceof TimeoutException) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, convertException); + logger.log(Level.SEVERE, "Decompilation error in: " + path, convertException); Helper.appendTimeoutComment(writer, timeout); } else { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, convertException); + logger.log(Level.SEVERE, "Decompilation error in: " + path, convertException); Helper.appendErrorComment(writer, convertException); } if (asm != null) { @@ -871,7 +871,7 @@ public class Action implements GraphSourceItem { try { out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables2, functions, actions.subList(adr2ip(actions, endAddr), adr2ip(actions, endAddr + size)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); } catch (OutOfMemoryError | TranslateException | StackOverflowError ex2) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex2); + logger.log(Level.SEVERE, "Decompilation error in: " + path, ex2); if (ex2 instanceof OutOfMemoryError) { Helper.freeMem(); } @@ -1004,7 +1004,7 @@ public class Action implements GraphSourceItem { try { action.translate(localData, stack, output, staticOperation, path); } catch (EmptyStackException ese) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ese); + logger.log(Level.SEVERE, "Decompilation error in: " + path, ese); output.add(new UnsupportedActionItem(action, "Empty stack")); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java index db85ae1bd..3ab804f6f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FrameLabelTag.java @@ -12,9 +12,11 @@ * 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; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.helpers.ByteArrayRange; @@ -36,6 +38,15 @@ public class FrameLabelTag extends Tag { return namedAnchor; } + /** + * Constructor + * @param swf + */ + public FrameLabelTag(SWF swf) { + super(swf, ID, "FrameLabel", null); + name = "New frame label"; + } + public FrameLabelTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "FrameLabel", data); name = sis.readString("name"); 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 31ff99153..e5abc7a98 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 @@ -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.tags; import com.jpexs.decompiler.flash.SWF; @@ -191,6 +192,14 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public PlaceObject2Tag(SWF swf) { + super(swf, ID, "PlaceObject2", null); + } + public PlaceObject2Tag(SWF swf, boolean placeFlagHasClipActions, boolean placeFlagHasClipDepth, boolean placeFlagHasName, boolean placeFlagHasRatio, boolean placeFlagHasColorTransform, boolean placeFlagHasMatrix, boolean placeFlagHasCharacter, boolean placeFlagMove, int depth, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, CLIPACTIONS clipActions) { super(swf, ID, "PlaceObject2", null); this.placeFlagHasClipActions = placeFlagHasClipActions; 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 52949d2d4..5f2cb8338 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 @@ -12,10 +12,12 @@ * 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; import com.jpexs.decompiler.flash.EndOfStreamException; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; @@ -295,6 +297,14 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public PlaceObject3Tag(SWF swf) { + super(swf, ID, "PlaceObject3", null); + } + /** * Constructor * 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 787cc010f..cfc284f48 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 @@ -12,10 +12,12 @@ * 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; import com.jpexs.decompiler.flash.EndOfStreamException; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; @@ -297,6 +299,14 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public PlaceObject4Tag(SWF swf) { + super(swf, ID, "PlaceObject4", null); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java index 5a75e7be3..dc1fce7cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObjectTag.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.tags; import com.jpexs.decompiler.flash.SWF; @@ -97,6 +98,15 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public PlaceObjectTag(SWF swf) { + super(swf, ID, "PlaceObject", null); + matrix = new MATRIX(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java index 51e3201b7..aa6a380ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObject2Tag.java @@ -12,9 +12,11 @@ * 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; +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.RemoveTag; @@ -31,6 +33,14 @@ public class RemoveObject2Tag extends Tag implements RemoveTag { public int depth; public static final int ID = 28; + /** + * Constructor + * @param swf + */ + public RemoveObject2Tag(SWF swf) { + super(swf, ID, "RemoveObject2", null); + } + public RemoveObject2Tag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "RemoveObject2", data); depth = sis.readUI16("depth"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java index 1df3548a9..eb6587e12 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/RemoveObjectTag.java @@ -12,9 +12,11 @@ * 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; +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; @@ -64,6 +66,15 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public RemoveObjectTag(SWF swf) { + super(swf, ID, "RemoveObject", null); + characterId = swf.getNextCharacterId(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java index 1fc1ca0ed..348a775f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ShowFrameTag.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.tags; import com.jpexs.decompiler.flash.SWF; @@ -57,6 +58,10 @@ public class ShowFrameTag extends Tag { super(swf, ID, "ShowFrame", data); } + /** + * Constructor + * @param swf + */ public ShowFrameTag(SWF swf) { super(swf, ID, "ShowFrame", null); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java index 09fcff7dd..ea93070d9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamBlockTag.java @@ -12,9 +12,11 @@ * 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; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.types.annotations.Internal; @@ -35,6 +37,15 @@ public class SoundStreamBlockTag extends Tag { @Internal public byte[] streamSoundData; + /** + * Constructor + * @param swf + */ + public SoundStreamBlockTag(SWF swf) { + super(swf, ID, "SoundStreamBlock", null); + streamSoundData = new byte[0]; + } + /** * Constructor * 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 b895605e6..78d5dc31c 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 @@ -181,12 +181,12 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea return streamSoundType; } - public static void populateSoundStreamBlocks(int containerId, List tags, Tag head, List output) { + public static void populateSoundStreamBlocks(int containerId, List tags, SoundStreamHeadTypeTag head, List output) { boolean found = false; for (ContainerItem t : tags) { if (t == head) { found = true; - ((SoundStreamHeadTypeTag) head).setVirtualCharacterId(containerId); + head.setVirtualCharacterId(containerId); continue; } if (t instanceof Container) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java index 46b00e2de..34ac2dab9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java @@ -12,9 +12,11 @@ * 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; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.types.SOUNDINFO; @@ -44,13 +46,25 @@ public class StartSound2Tag extends Tag { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = baos; SWFOutputStream sos = new SWFOutputStream(os, getVersion()); - /*try { - //sos.write - } catch (IOException e) { - }*/ + try { + sos.writeString(soundClassName); + sos.writeSOUNDINFO(soundInfo); + } catch (IOException e) { + throw new Error("This should never happen.", e); + } return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public StartSound2Tag(SWF swf) { + super(swf, ID, "StartSound2", null); + soundClassName = "NewSoundClass"; + soundInfo = new SOUNDINFO(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java index 0ca33daa8..bfc3fdab8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java @@ -12,9 +12,11 @@ * 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; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.types.BasicType; @@ -56,6 +58,15 @@ public class StartSoundTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public StartSoundTag(SWF swf) { + super(swf, ID, "StartSound", null); + soundInfo = new SOUNDINFO(); + } + /** * Constructor * 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 2732553b3..cc4f27de6 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 @@ -29,7 +29,7 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound; import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound; import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap; import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage; -import com.jpexs.decompiler.flash.tags.gfx.ExporterInfoTag; +import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo; import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.annotations.Internal; @@ -216,7 +216,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, ContainerItem, DefineExternalStreamSound.ID, DefineGradientMap.ID, DefineSubImage.ID, - ExporterInfoTag.ID, + ExporterInfo.ID, FontTextureInfo.ID); knownTagIds = tagIds; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java index 880b0a083..0dbcc9e08 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/VideoFrameTag.java @@ -12,9 +12,11 @@ * 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; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.types.BasicType; @@ -58,6 +60,15 @@ public class VideoFrameTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public VideoFrameTag(SWF swf) { + super(swf, ID, "VideoFrame", null); + videoData = new byte[0]; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfo.java similarity index 95% rename from libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfo.java index f8b6aa169..7d9d7f1f0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfoTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/ExporterInfo.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.tags.gfx; import com.jpexs.decompiler.flash.SWFInputStream; @@ -30,7 +31,7 @@ import java.util.List; * * @author JPEXS */ -public class ExporterInfoTag extends Tag { +public class ExporterInfo extends Tag { public static final int ID = 1000; //Version (1.10 will be encoded as 0x10A) @@ -87,7 +88,7 @@ public class ExporterInfoTag extends Tag { * @param data * @throws IOException */ - public ExporterInfoTag(SWFInputStream sis, ByteArrayRange data) throws IOException { + public ExporterInfo(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "ExporterInfo", data); this.version = sis.readUI16("version"); if (this.version >= 0x10a) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/MemoryInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/MemoryInputStream.java index 4f78b6eb8..fcfa19c73 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/MemoryInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/MemoryInputStream.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.helpers; import com.jpexs.helpers.streams.SeekableInputStream; @@ -40,7 +41,7 @@ public class MemoryInputStream extends SeekableInputStream { public MemoryInputStream(byte[] buffer, int startPos, int maxLength) throws IOException { this.buffer = buffer; this.startPos = startPos; - if (startPos >= buffer.length) { + if (startPos > buffer.length) { throw new IOException("Invalid startPos"); } this.maxLength = maxLength; diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagIdClassMap.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagIdClassMap.java new file mode 100644 index 000000000..ca528de3e --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagIdClassMap.java @@ -0,0 +1,205 @@ +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.tagtree; + +import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; +import com.jpexs.decompiler.flash.tags.DebugIDTag; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsLossless2Tag; +import com.jpexs.decompiler.flash.tags.DefineBitsLosslessTag; +import com.jpexs.decompiler.flash.tags.DefineBitsTag; +import com.jpexs.decompiler.flash.tags.DefineButton2Tag; +import com.jpexs.decompiler.flash.tags.DefineButtonCxformTag; +import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag; +import com.jpexs.decompiler.flash.tags.DefineButtonTag; +import com.jpexs.decompiler.flash.tags.DefineEditTextTag; +import com.jpexs.decompiler.flash.tags.DefineFont2Tag; +import com.jpexs.decompiler.flash.tags.DefineFont3Tag; +import com.jpexs.decompiler.flash.tags.DefineFont4Tag; +import com.jpexs.decompiler.flash.tags.DefineFontAlignZonesTag; +import com.jpexs.decompiler.flash.tags.DefineFontInfo2Tag; +import com.jpexs.decompiler.flash.tags.DefineFontInfoTag; +import com.jpexs.decompiler.flash.tags.DefineFontNameTag; +import com.jpexs.decompiler.flash.tags.DefineFontTag; +import com.jpexs.decompiler.flash.tags.DefineMorphShape2Tag; +import com.jpexs.decompiler.flash.tags.DefineMorphShapeTag; +import com.jpexs.decompiler.flash.tags.DefineScalingGridTag; +import com.jpexs.decompiler.flash.tags.DefineSceneAndFrameLabelDataTag; +import com.jpexs.decompiler.flash.tags.DefineShape2Tag; +import com.jpexs.decompiler.flash.tags.DefineShape3Tag; +import com.jpexs.decompiler.flash.tags.DefineShape4Tag; +import com.jpexs.decompiler.flash.tags.DefineShapeTag; +import com.jpexs.decompiler.flash.tags.DefineSoundTag; +import com.jpexs.decompiler.flash.tags.DefineSpriteTag; +import com.jpexs.decompiler.flash.tags.DefineText2Tag; +import com.jpexs.decompiler.flash.tags.DefineTextTag; +import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; +import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.DoActionTag; +import com.jpexs.decompiler.flash.tags.DoInitActionTag; +import com.jpexs.decompiler.flash.tags.EnableDebugger2Tag; +import com.jpexs.decompiler.flash.tags.EnableDebuggerTag; +import com.jpexs.decompiler.flash.tags.EnableTelemetryTag; +import com.jpexs.decompiler.flash.tags.EndTag; +import com.jpexs.decompiler.flash.tags.ExportAssetsTag; +import com.jpexs.decompiler.flash.tags.FileAttributesTag; +import com.jpexs.decompiler.flash.tags.FrameLabelTag; +import com.jpexs.decompiler.flash.tags.ImportAssets2Tag; +import com.jpexs.decompiler.flash.tags.ImportAssetsTag; +import com.jpexs.decompiler.flash.tags.JPEGTablesTag; +import com.jpexs.decompiler.flash.tags.MetadataTag; +import com.jpexs.decompiler.flash.tags.PlaceObject2Tag; +import com.jpexs.decompiler.flash.tags.PlaceObject3Tag; +import com.jpexs.decompiler.flash.tags.PlaceObject4Tag; +import com.jpexs.decompiler.flash.tags.PlaceObjectTag; +import com.jpexs.decompiler.flash.tags.ProductInfoTag; +import com.jpexs.decompiler.flash.tags.ProtectTag; +import com.jpexs.decompiler.flash.tags.RemoveObject2Tag; +import com.jpexs.decompiler.flash.tags.RemoveObjectTag; +import com.jpexs.decompiler.flash.tags.ScriptLimitsTag; +import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; +import com.jpexs.decompiler.flash.tags.SetTabIndexTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; +import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag; +import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag; +import com.jpexs.decompiler.flash.tags.StartSound2Tag; +import com.jpexs.decompiler.flash.tags.StartSoundTag; +import com.jpexs.decompiler.flash.tags.SymbolClassTag; +import com.jpexs.decompiler.flash.tags.VideoFrameTag; +import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont; +import com.jpexs.decompiler.flash.tags.gfx.DefineExternalGradient; +import com.jpexs.decompiler.flash.tags.gfx.DefineExternalImage; +import com.jpexs.decompiler.flash.tags.gfx.DefineExternalImage2; +import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound; +import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound; +import com.jpexs.decompiler.flash.tags.gfx.DefineGradientMap; +import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage; +import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo; +import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author JPEXS + */ +public class TagIdClassMap { + + private static final Map tagIdClassMap = new HashMap<>(); + + private static final Map classTagIdMap = new HashMap<>(); + + static { + addTag(CSMTextSettingsTag.ID, CSMTextSettingsTag.class); + addTag(DebugIDTag.ID, DebugIDTag.class); + addTag(DefineBinaryDataTag.ID, DefineBinaryDataTag.class); + addTag(DefineBitsJPEG2Tag.ID, DefineBitsJPEG2Tag.class); + addTag(DefineBitsJPEG3Tag.ID, DefineBitsJPEG3Tag.class); + addTag(DefineBitsJPEG4Tag.ID, DefineBitsJPEG4Tag.class); + addTag(DefineBitsLossless2Tag.ID, DefineBitsLossless2Tag.class); + addTag(DefineBitsLosslessTag.ID, DefineBitsLosslessTag.class); + addTag(DefineBitsTag.ID, DefineBitsTag.class); + addTag(DefineButton2Tag.ID, DefineButton2Tag.class); + addTag(DefineButtonCxformTag.ID, DefineButtonCxformTag.class); + addTag(DefineButtonSoundTag.ID, DefineButtonSoundTag.class); + addTag(DefineButtonTag.ID, DefineButtonTag.class); + addTag(DefineEditTextTag.ID, DefineEditTextTag.class); + addTag(DefineFont2Tag.ID, DefineFont2Tag.class); + addTag(DefineFont3Tag.ID, DefineFont3Tag.class); + addTag(DefineFont4Tag.ID, DefineFont4Tag.class); + addTag(DefineFontAlignZonesTag.ID, DefineFontAlignZonesTag.class); + addTag(DefineFontInfo2Tag.ID, DefineFontInfo2Tag.class); + addTag(DefineFontInfoTag.ID, DefineFontInfoTag.class); + addTag(DefineFontNameTag.ID, DefineFontNameTag.class); + addTag(DefineFontTag.ID, DefineFontTag.class); + addTag(DefineMorphShape2Tag.ID, DefineMorphShape2Tag.class); + addTag(DefineMorphShapeTag.ID, DefineMorphShapeTag.class); + addTag(DefineScalingGridTag.ID, DefineScalingGridTag.class); + addTag(DefineSceneAndFrameLabelDataTag.ID, DefineSceneAndFrameLabelDataTag.class); + addTag(DefineShape2Tag.ID, DefineShape2Tag.class); + addTag(DefineShape3Tag.ID, DefineShape3Tag.class); + addTag(DefineShape4Tag.ID, DefineShape4Tag.class); + addTag(DefineShapeTag.ID, DefineShapeTag.class); + addTag(DefineSoundTag.ID, DefineSoundTag.class); + addTag(DefineSpriteTag.ID, DefineSpriteTag.class); + addTag(DefineText2Tag.ID, DefineText2Tag.class); + addTag(DefineTextTag.ID, DefineTextTag.class); + addTag(DefineVideoStreamTag.ID, DefineVideoStreamTag.class); + addTag(DoABCDefineTag.ID, DoABCDefineTag.class); + addTag(DoABCTag.ID, DoABCTag.class); + addTag(DoActionTag.ID, DoActionTag.class); + addTag(DoInitActionTag.ID, DoInitActionTag.class); + addTag(EnableDebugger2Tag.ID, EnableDebugger2Tag.class); + addTag(EnableDebuggerTag.ID, EnableDebuggerTag.class); + addTag(EnableTelemetryTag.ID, EnableTelemetryTag.class); + addTag(EndTag.ID, EndTag.class); + addTag(ExportAssetsTag.ID, ExportAssetsTag.class); + addTag(FileAttributesTag.ID, FileAttributesTag.class); + addTag(FrameLabelTag.ID, FrameLabelTag.class); + addTag(ImportAssets2Tag.ID, ImportAssets2Tag.class); + addTag(ImportAssetsTag.ID, ImportAssetsTag.class); + addTag(JPEGTablesTag.ID, JPEGTablesTag.class); + addTag(MetadataTag.ID, MetadataTag.class); + addTag(PlaceObject2Tag.ID, PlaceObject2Tag.class); + addTag(PlaceObject3Tag.ID, PlaceObject3Tag.class); + addTag(PlaceObject4Tag.ID, PlaceObject4Tag.class); + addTag(PlaceObjectTag.ID, PlaceObjectTag.class); + addTag(ProductInfoTag.ID, ProductInfoTag.class); + addTag(ProtectTag.ID, ProtectTag.class); + addTag(RemoveObject2Tag.ID, RemoveObject2Tag.class); + addTag(RemoveObjectTag.ID, RemoveObjectTag.class); + addTag(ScriptLimitsTag.ID, ScriptLimitsTag.class); + addTag(SetBackgroundColorTag.ID, SetBackgroundColorTag.class); + addTag(SetTabIndexTag.ID, SetTabIndexTag.class); + addTag(ShowFrameTag.ID, ShowFrameTag.class); + addTag(SoundStreamBlockTag.ID, SoundStreamBlockTag.class); + addTag(SoundStreamHead2Tag.ID, SoundStreamHead2Tag.class); + addTag(SoundStreamHeadTag.ID, SoundStreamHeadTag.class); + addTag(StartSound2Tag.ID, StartSound2Tag.class); + addTag(StartSoundTag.ID, StartSoundTag.class); + addTag(SymbolClassTag.ID, SymbolClassTag.class); + addTag(VideoFrameTag.ID, VideoFrameTag.class); + addTag(DefineCompactedFont.ID, DefineCompactedFont.class); + addTag(DefineExternalGradient.ID, DefineExternalGradient.class); + addTag(DefineExternalImage.ID, DefineExternalImage.class); + addTag(DefineExternalImage2.ID, DefineExternalImage2.class); + addTag(DefineExternalSound.ID, DefineExternalSound.class); + addTag(DefineExternalStreamSound.ID, DefineExternalStreamSound.class); + addTag(DefineGradientMap.ID, DefineGradientMap.class); + addTag(DefineSubImage.ID, DefineSubImage.class); + addTag(ExporterInfo.ID, ExporterInfo.class); + addTag(FontTextureInfo.ID, FontTextureInfo.class); + } + + private static void addTag(int tagId, Class cl) { + tagIdClassMap.put(tagId, cl); + classTagIdMap.put(cl, tagId); + } + + public static Class getClassByTagId(int tagId) { + return tagIdClassMap.get(tagId); + } + + public static Integer getTagIdByClass(Class cl) { + return classTagIdMap.get(cl); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index 2f701bced..9cd1871c2 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -50,10 +50,21 @@ import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; +import com.jpexs.decompiler.flash.tags.FrameLabelTag; +import com.jpexs.decompiler.flash.tags.PlaceObject2Tag; +import com.jpexs.decompiler.flash.tags.PlaceObject3Tag; +import com.jpexs.decompiler.flash.tags.PlaceObject4Tag; +import com.jpexs.decompiler.flash.tags.PlaceObjectTag; +import com.jpexs.decompiler.flash.tags.RemoveObject2Tag; +import com.jpexs.decompiler.flash.tags.RemoveObjectTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.SoundStreamHead2Tag; import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag; +import com.jpexs.decompiler.flash.tags.StartSound2Tag; +import com.jpexs.decompiler.flash.tags.StartSoundTag; 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.CharacterIdTag; @@ -69,6 +80,7 @@ import com.jpexs.decompiler.flash.timeline.AS3Package; import com.jpexs.decompiler.flash.timeline.Frame; import com.jpexs.decompiler.flash.timeline.FrameScript; import com.jpexs.decompiler.flash.timeline.TagScript; +import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem; import com.jpexs.decompiler.flash.treeitems.FolderItem; import com.jpexs.decompiler.flash.treeitems.HeaderItem; @@ -308,41 +320,41 @@ public class TagTree extends JTree implements ActionListener { return TreeNodeType.FOLDER; } - public List getTreeItemClasses(String folderName, boolean gfx) { - List ret = null; + public List getSwfFolderItemNestedTagIds(String folderName, boolean gfx) { + List ret = null; switch (folderName) { case TagTreeModel.FOLDER_SHAPES: - ret = Arrays.asList((Class) DefineShapeTag.class, DefineShape2Tag.class, DefineShape3Tag.class, DefineShape4Tag.class); + ret = Arrays.asList(DefineShapeTag.ID, DefineShape2Tag.ID, DefineShape3Tag.ID, DefineShape4Tag.ID); break; case TagTreeModel.FOLDER_MORPHSHAPES: - ret = Arrays.asList((Class) DefineMorphShapeTag.class, DefineMorphShape2Tag.class); + ret = Arrays.asList(DefineMorphShapeTag.ID, DefineMorphShape2Tag.ID); break; case TagTreeModel.FOLDER_SPRITES: - ret = Arrays.asList((Class) DefineSpriteTag.class); + ret = Arrays.asList(DefineSpriteTag.ID); break; case TagTreeModel.FOLDER_TEXTS: - ret = Arrays.asList((Class) DefineTextTag.class, DefineText2Tag.class, DefineEditTextTag.class); + ret = Arrays.asList(DefineTextTag.ID, DefineText2Tag.ID, DefineEditTextTag.ID); break; case TagTreeModel.FOLDER_IMAGES: - ret = Arrays.asList((Class) DefineBitsTag.class, DefineBitsJPEG2Tag.class, DefineBitsJPEG3Tag.class, DefineBitsJPEG4Tag.class, DefineBitsLosslessTag.class, DefineBitsLossless2Tag.class); + ret = Arrays.asList(DefineBitsTag.ID, DefineBitsJPEG2Tag.ID, DefineBitsJPEG3Tag.ID, DefineBitsJPEG4Tag.ID, DefineBitsLosslessTag.ID, DefineBitsLossless2Tag.ID); break; case TagTreeModel.FOLDER_MOVIES: - ret = Arrays.asList((Class) DefineVideoStreamTag.class); + ret = Arrays.asList(DefineVideoStreamTag.ID); break; case TagTreeModel.FOLDER_SOUNDS: - ret = Arrays.asList((Class) DefineSoundTag.class, SoundStreamHeadTag.class, SoundStreamHead2Tag.class); + ret = Arrays.asList(DefineSoundTag.ID); break; case TagTreeModel.FOLDER_BUTTONS: - ret = Arrays.asList((Class) DefineButtonTag.class, DefineButton2Tag.class); + ret = Arrays.asList(DefineButtonTag.ID, DefineButton2Tag.ID); break; case TagTreeModel.FOLDER_FONTS: - ret = Arrays.asList((Class) DefineFontTag.class, DefineFont2Tag.class, DefineFont3Tag.class, DefineFont4Tag.class); + ret = Arrays.asList(DefineFontTag.ID, DefineFont2Tag.ID, DefineFont3Tag.ID, DefineFont4Tag.ID); if (gfx) { - ret.add(DefineCompactedFont.class); + ret.add(DefineCompactedFont.ID); } break; case TagTreeModel.FOLDER_BINARY_DATA: - ret = Arrays.asList((Class) DefineBinaryDataTag.class); + ret = Arrays.asList(DefineBinaryDataTag.ID); break; case TagTreeModel.FOLDER_FRAMES: ret = new ArrayList<>(); @@ -355,6 +367,13 @@ public class TagTree extends JTree implements ActionListener { return ret; } + public List getSpriteNestedTagIds() { + return Arrays.asList(PlaceObjectTag.ID, PlaceObject2Tag.ID, PlaceObject3Tag.ID, PlaceObject4Tag.ID, + RemoveObjectTag.ID, RemoveObject2Tag.ID, ShowFrameTag.ID, FrameLabelTag.ID, + StartSoundTag.ID, StartSound2Tag.ID, VideoFrameTag.ID, + SoundStreamBlockTag.ID, SoundStreamHeadTag.ID, SoundStreamHead2Tag.ID); + } + public void createContextMenu(final List swfs) { final JPopupMenu contextPopupMenu = new JPopupMenu(); @@ -443,7 +462,7 @@ public class TagTree extends JTree implements ActionListener { openSWFInsideTagMenuItem.setVisible(false); if (paths.length == 1) { - TreeItem item = (TreeItem) paths[0].getLastPathComponent(); + final TreeItem item = (TreeItem) paths[0].getLastPathComponent(); if (item instanceof ImageTag && ((ImageTag) item).importSupported()) { replaceSelectionMenuItem.setVisible(true); @@ -474,34 +493,45 @@ public class TagTree extends JTree implements ActionListener { closeSelectionMenuItem.setVisible(true); } + List allowedTagTypes = null; if (item instanceof FolderItem) { - final FolderItem folderItem = (FolderItem) item; - List allowedTagTypes = getTreeItemClasses(folderItem.getName(), item.getSwf().gfx); - addTagMenu.removeAll(); - if (allowedTagTypes != null) { - for (final Class cl : allowedTagTypes) { - JMenuItem tagItem = new JMenuItem(cl.getSimpleName()); - tagItem.addActionListener(new ActionListener() { + allowedTagTypes = getSwfFolderItemNestedTagIds(((FolderItem) item).getName(), item.getSwf().gfx); + } else if (item instanceof DefineSpriteTag) { + allowedTagTypes = getSpriteNestedTagIds(); + } + + addTagMenu.removeAll(); + if (allowedTagTypes != null) { + for (Integer tagId : allowedTagTypes) { + final Class cl = TagIdClassMap.getClassByTagId(tagId); + JMenuItem tagItem = new JMenuItem(cl.getSimpleName()); + tagItem.addActionListener(new ActionListener() { - @Override - @SuppressWarnings("unchecked") - public void actionPerformed(ActionEvent ae) { - try { - SWF swf = folderItem.getSwf(); - Tag t = (Tag) cl.getDeclaredConstructor(SWF.class).newInstance(new Object[]{swf}); - t.setTimelined(swf); + @Override + @SuppressWarnings("unchecked") + public void actionPerformed(ActionEvent ae) { + try { + SWF swf = item.getSwf(); + Tag t = (Tag) cl.getDeclaredConstructor(SWF.class).newInstance(new Object[]{swf}); + boolean isDefineSprite = item instanceof DefineSpriteTag; + Timelined timelined = isDefineSprite ? (DefineSpriteTag) item : swf; + t.setTimelined(timelined); + if (isDefineSprite) { + ((DefineSpriteTag) item).subTags.add(t); + } else { swf.tags.add(t); - swf.updateCharacters(); - mainPanel.refreshTree(); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { - Logger.getLogger(TagTree.class.getName()).log(Level.SEVERE, null, ex); } + timelined.getTimeline().reset(); + swf.updateCharacters(); + mainPanel.refreshTree(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) { + Logger.getLogger(TagTree.class.getName()).log(Level.SEVERE, null, ex); } - }); - addTagMenu.add(tagItem); - } - addTagMenu.setVisible(true); + } + }); + addTagMenu.add(tagItem); } + addTagMenu.setVisible(true); } if (item instanceof Tag && swfs.size() > 1) {