From ea6568d71da13af6bdab4745239e11469b866f08 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 6 Nov 2014 11:49:12 +0100 Subject: [PATCH 1/5] add new tags to sprites --- .../decompiler/flash/SWFInputStream.java | 4 +- .../flash/abc/avm2/AVM2ConstantPool.java | 17 +- .../jpexs/decompiler/flash/action/Action.java | 10 +- .../decompiler/flash/tags/FrameLabelTag.java | 13 +- .../flash/tags/PlaceObject2Tag.java | 11 +- .../flash/tags/PlaceObject3Tag.java | 12 +- .../flash/tags/PlaceObject4Tag.java | 12 +- .../decompiler/flash/tags/PlaceObjectTag.java | 12 +- .../flash/tags/RemoveObject2Tag.java | 12 +- .../flash/tags/RemoveObjectTag.java | 13 +- .../decompiler/flash/tags/ShowFrameTag.java | 7 +- .../flash/tags/SoundStreamBlockTag.java | 13 +- .../flash/tags/SoundStreamHeadTag.java | 4 +- .../decompiler/flash/tags/StartSound2Tag.java | 24 +- .../decompiler/flash/tags/StartSoundTag.java | 13 +- .../com/jpexs/decompiler/flash/tags/Tag.java | 4 +- .../decompiler/flash/tags/VideoFrameTag.java | 13 +- ...ExporterInfoTag.java => ExporterInfo.java} | 7 +- .../com/jpexs/helpers/MemoryInputStream.java | 5 +- .../flash/gui/tagtree/TagIdClassMap.java | 205 ++++++++++++++++++ .../decompiler/flash/gui/tagtree/TagTree.java | 102 ++++++--- 21 files changed, 437 insertions(+), 76 deletions(-) rename libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/gfx/{ExporterInfoTag.java => ExporterInfo.java} (95%) create mode 100644 src/com/jpexs/decompiler/flash/gui/tagtree/TagIdClassMap.java 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) { From b51fdfb6a98050ffad5ed7f864e323a0ff578591 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 6 Nov 2014 17:16:56 +0100 Subject: [PATCH 2/5] script export fix --- src/com/jpexs/decompiler/flash/gui/ExportDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index d611a8ace..6c74b0a66 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -71,7 +71,7 @@ public class ExportDialog extends AppDialog { TagTreeModel.FOLDER_IMAGES, TagTreeModel.FOLDER_MOVIES, TagTreeModel.FOLDER_SOUNDS, - TagTreeModel.FOLDER_SPRITES, + TagTreeModel.FOLDER_SCRIPTS, TagTreeModel.FOLDER_BINARY_DATA, TagTreeModel.FOLDER_FRAMES, TagTreeModel.FOLDER_FONTS, From 660520f44bb81c0be4138b1bdad5062f2ba7ebd5 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Thu, 6 Nov 2014 23:33:42 +0100 Subject: [PATCH 3/5] DefineJPEG3 tag reading fix, Caching Shape outline, zoom to fit fixed, shape caching --- .../src/com/jpexs/decompiler/flash/SWFInputStream.java | 8 +++++--- .../src/com/jpexs/decompiler/flash/types/SHAPE.java | 7 +++++++ src/com/jpexs/decompiler/flash/gui/ImagePanel.java | 6 ++++-- src/com/jpexs/decompiler/flash/gui/MainPanel.java | 5 +++++ src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java | 3 ++- .../decompiler/flash/gui/player/FlashPlayerPanel.java | 3 ++- .../jpexs/decompiler/flash/gui/player/MediaDisplay.java | 2 +- .../jpexs/decompiler/flash/gui/player/PlayerControls.java | 4 ++-- 8 files changed, 28 insertions(+), 10 deletions(-) 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 d85ea7c54..6d16ca520 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -768,10 +768,12 @@ public class SWFInputStream implements AutoCloseable { endDumpLevel(); InflaterInputStream dis = new InflaterInputStream(new ByteArrayInputStream(data)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); + if (count > 0) { byte[] buf = new byte[4096]; - int c = 0; - while ((c = dis.read(buf)) > 0) { - baos.write(buf, 0, c); + int c = 0; + while ((c = dis.read(buf)) > 0) { + baos.write(buf, 0, c); + } } return baos.toByteArray(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java index c7a4e8d6d..ad9fc0015 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/SHAPE.java @@ -41,6 +41,8 @@ public class SHAPE implements NeedsCharacters, Serializable { public int numLineBits; public List shapeRecords; + private Shape cachedOutline; + @Override public void getNeededCharacters(Set needed) { for (SHAPERECORD r : shapeRecords) { @@ -62,12 +64,17 @@ public class SHAPE implements NeedsCharacters, Serializable { } public Shape getOutline() { + if (cachedOutline != null) { + return cachedOutline; + } + List paths = PathExporter.export(this); Area area = new Area(); for (GeneralPath path : paths) { area.add(new Area(path)); } + cachedOutline = area; return area; } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 46092a925..2bfe0751b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -406,7 +406,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } @Override - public void zoomToFit() { + public double getZoomToFit() { if (timelined instanceof BoundedTag) { RECT bounds = ((BoundedTag) timelined).getRect(new HashSet()); double w1 = bounds.getWidth() / SWF.unitDivisor; @@ -424,8 +424,10 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } else { w = w2; } - zoom = (double) w / (double) w1; + return (double) w / (double) w1; } + + return 1; } public void setImage(byte[] data) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 87228fcb5..736ec5eae 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2631,6 +2631,11 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } return new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); } + + @Override + public int hashCode() { + return tag.hashCode(); + } }; } } diff --git a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index a74e13159..9a2040815 100644 --- a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -207,7 +207,8 @@ public class SoundTagPlayer implements MediaDisplay { } @Override - public void zoomToFit() { + public double getZoomToFit() { + return 1; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index 3896b82de..87b8aa9c9 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -58,8 +58,9 @@ public class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay { } @Override - public void zoomToFit() { + public double getZoomToFit() { //TODO + return 1; } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java index c56c7e547..70688ca3b 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java +++ b/src/com/jpexs/decompiler/flash/gui/player/MediaDisplay.java @@ -53,7 +53,7 @@ public interface MediaDisplay { public boolean zoomAvailable(); - public void zoomToFit(); + public double getZoomToFit(); public double getZoom(); } diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index 7e8d4a149..d4be31059 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -316,8 +316,8 @@ public class PlayerControls extends JPanel implements ActionListener { updateZoom(); break; case ACTION_ZOOMFIT: - display.zoomToFit(); - //updateZoom(); + realZoom = display.getZoomToFit(); + updateZoom(); break; case ACTION_SNAPSHOT: putImageToClipBoard(display.printScreen()); From da5b8080ba100a8757d319994683d990a6792aa5 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Fri, 7 Nov 2014 15:22:00 +0100 Subject: [PATCH 4/5] allow adding "other type" tags --- .../flash/tags/CSMTextSettingsTag.java | 12 +++++- .../decompiler/flash/tags/DebugIDTag.java | 13 ++++++- .../flash/tags/DefineButtonCxformTag.java | 13 ++++++- .../flash/tags/DefineButtonSoundTag.java | 12 +++++- .../flash/tags/DefineFontAlignZonesTag.java | 13 ++++++- .../flash/tags/DefineFontInfo2Tag.java | 16 +++++++- .../flash/tags/DefineFontInfoTag.java | 18 +++++++-- .../flash/tags/DefineFontNameTag.java | 14 ++++++- .../flash/tags/DefineScalingGridTag.java | 13 ++++++- .../tags/DefineSceneAndFrameLabelDataTag.java | 16 +++++++- .../decompiler/flash/tags/DoABCDefineTag.java | 10 +++++ .../jpexs/decompiler/flash/tags/DoABCTag.java | 9 +++++ .../decompiler/flash/tags/DoActionTag.java | 8 ++++ .../flash/tags/DoInitActionTag.java | 9 +++++ .../flash/tags/EnableDebugger2Tag.java | 13 ++++++- .../flash/tags/EnableDebuggerTag.java | 13 ++++++- .../flash/tags/EnableTelemetryTag.java | 13 ++++++- .../jpexs/decompiler/flash/tags/EndTag.java | 15 +++++--- .../flash/tags/ExportAssetsTag.java | 7 +++- .../flash/tags/FileAttributesTag.java | 7 +++- .../flash/tags/ImportAssets2Tag.java | 14 ++++++- .../flash/tags/ImportAssetsTag.java | 14 ++++++- .../decompiler/flash/tags/JPEGTablesTag.java | 13 ++++++- .../decompiler/flash/tags/MetadataTag.java | 13 ++++++- .../decompiler/flash/tags/ProductInfoTag.java | 12 +++++- .../decompiler/flash/tags/ProtectTag.java | 13 ++++++- .../flash/tags/ScriptLimitsTag.java | 12 +++++- .../flash/tags/SetBackgroundColorTag.java | 12 +++++- .../decompiler/flash/tags/SetTabIndexTag.java | 12 +++++- .../decompiler/flash/tags/ShowFrameTag.java | 16 ++++---- .../decompiler/flash/tags/SymbolClassTag.java | 14 ++++++- .../decompiler/flash/timeline/Timeline.java | 2 +- .../decompiler/flash/gui/ExportDialog.java | 7 ++-- .../decompiler/flash/gui/ImagePanel.java | 2 +- .../decompiler/flash/gui/tagtree/TagTree.java | 38 ++++++++++++++++++- 35 files changed, 391 insertions(+), 47 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java index 2736eb883..5574c7f82 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/CSMTextSettingsTag.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; @@ -81,6 +83,14 @@ public class CSMTextSettingsTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public CSMTextSettingsTag(SWF swf) { + super(swf, ID, "CSMTextSettings", null); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java index 0c997c57a..42d55b448 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DebugIDTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DebugIDTag.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; @@ -54,6 +56,15 @@ public class DebugIDTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DebugIDTag(SWF swf) { + super(swf, ID, "DebugID", null); + debugId = new byte[16]; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java index fb518ad9a..c978eea46 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonCxformTag.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 DefineButtonCxformTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DefineButtonCxformTag(SWF swf) { + super(swf, ID, "DefineButtonCxform", null); + buttonColorTransform = new CXFORM(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java index 67ff40a90..5f406be10 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonSoundTag.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; @@ -96,6 +98,14 @@ public class DefineButtonSoundTag extends CharacterIdTag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DefineButtonSoundTag(SWF swf) { + super(swf, ID, "DefineButtonSound", null); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java index c3612d4b9..1b8a57ab0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontAlignZonesTag.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; @@ -42,6 +44,15 @@ public class DefineFontAlignZonesTag extends Tag { public List zoneTable; public static final int ID = 73; + /** + * Constructor + * @param swf + */ + public DefineFontAlignZonesTag(SWF swf) { + super(swf, ID, "DefineFontAlignZones", null); + zoneTable = new ArrayList<>(); + } + public DefineFontAlignZonesTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "DefineFontAlignZones", data); fontID = sis.readUI16("fontID"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java index 29f339807..153e98784 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.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; @@ -26,6 +28,7 @@ import com.jpexs.helpers.utf8.Utf8Helper; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.AbstractList; import java.util.ArrayList; import java.util.List; @@ -85,6 +88,17 @@ public class DefineFontInfo2Tag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DefineFontInfo2Tag(SWF swf) { + super(swf, ID, "DefineFontInfo2", null); + fontName = "New Font Info Name"; + languageCode = new LANGCODE(); + codeTable = new ArrayList<>(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java index ad6a79456..f668076f2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.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; @@ -86,6 +88,16 @@ public class DefineFontInfoTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DefineFontInfoTag(SWF swf) { + super(swf, ID, "DefineFontInfo", null); + fontName = "New Font Info Name"; + codeTable = new ArrayList<>(); + } + /** * Constructor * @@ -110,12 +122,12 @@ public class DefineFontInfoTag extends Tag { fontFlagsBold = sis.readUB(1, "fontFlagsBold") == 1; fontFlagsWideCodes = sis.readUB(1, "fontFlagsWideCodes") == 1; codeTable = new ArrayList<>(); - do { + while (sis.available() > 0) { if (fontFlagsWideCodes) { codeTable.add(sis.readUI16("code")); } else { codeTable.add(sis.readUI8("code")); } - } while (sis.available() > 0); + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java index bccafad1f..116e50ea9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontNameTag.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; @@ -32,6 +34,16 @@ public class DefineFontNameTag extends Tag { public String fontCopyright; public static final int ID = 88; + /** + * Constructor + * @param swf + */ + public DefineFontNameTag(SWF swf) { + super(swf, ID, "DefineFontName", null); + fontName = "New Font Name"; + fontCopyright = "Copyright text"; + } + public DefineFontNameTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "DefineFontName", data); fontId = sis.readUI16("fontId"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java index d6946c38e..b6e80da3d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.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; @@ -35,6 +37,15 @@ public class DefineScalingGridTag extends Tag { public RECT splitter; public static final int ID = 78; + /** + * Constructor + * @param swf + */ + public DefineScalingGridTag(SWF swf) { + super(swf, ID, "DefineScalingGrid", null); + splitter = new RECT(); + } + public DefineScalingGridTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "DefineScalingGrid", data); characterId = sis.readUI16("characterId"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java index c31faac55..65dd8848a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSceneAndFrameLabelDataTag.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; @@ -75,6 +77,18 @@ public class DefineSceneAndFrameLabelDataTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public DefineSceneAndFrameLabelDataTag(SWF swf) { + super(swf, ID, "DefineSceneAndFrameLabelData", null); + sceneOffsets = new long[0]; + sceneNames = new String[0]; + frameNums= new long[0]; + frameNames = new String[0]; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index 3126c2f96..fc99e7e92 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -65,6 +65,16 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag { return "DoABCDefine (" + name + ")"; } + /** + * Constructor + * @param swf + */ + public DoABCDefineTag(SWF swf) { + super(swf, ID, "DoABCDefine", null); + name = "New DoABC"; + abc = new ABC(swf); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index bc7a45fbb..cc8e632b4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -52,6 +52,15 @@ public class DoABCTag extends Tag implements ABCContainerTag { return "DoABC"; } + /** + * Constructor + * @param swf + */ + public DoABCTag(SWF swf) { + super(swf, ID, "DoABC", null); + abc = new ABC(swf); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 6e3812105..4a9d47f3d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -48,6 +48,14 @@ public class DoActionTag extends Tag implements ASMSource { public ByteArrayRange actionBytes; public static final int ID = 12; + /** + * Constructor + * @param swf + */ + public DoActionTag(SWF swf) { + super(swf, ID, "DoAction", null); + } + /** * Constructor * 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 99b8147a0..282bb859f 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.DisassemblyListener; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -53,6 +54,14 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { public ByteArrayRange actionBytes; public static final int ID = 59; + /** + * Constructor + * @param swf + */ + public DoInitActionTag(SWF swf) { + super(swf, ID, "DoInitAction", null); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java index 2af82adf0..97ddb1d6a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebugger2Tag.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; @@ -61,6 +63,15 @@ public class EnableDebugger2Tag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public EnableDebugger2Tag(SWF swf) { + super(swf, ID, "EnableDebugger2", null); + passwordHash = "PasswordHash"; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java index 3106589a9..d6589275e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableDebuggerTag.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; @@ -55,6 +57,15 @@ public class EnableDebuggerTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public EnableDebuggerTag(SWF swf) { + super(swf, ID, "EnableDebugger", null); + passwordHash = "PasswordHash"; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java index 5e2c40323..4548708d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EnableTelemetryTag.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; @@ -64,6 +66,15 @@ public class EnableTelemetryTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public EnableTelemetryTag(SWF swf) { + super(swf, ID, "EnableTelemetry", null); + passwordHash = new byte[32]; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EndTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EndTag.java index 182d4c745..fccc4fcf4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EndTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/EndTag.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; @@ -38,6 +39,14 @@ public class EndTag extends Tag { public static final int ID = 0; + /** + * Constructor + * @param swf + */ + public EndTag(SWF swf) { + super(swf, ID, "End", null); + } + /** * Constructor * @@ -49,8 +58,4 @@ public class EndTag extends Tag { super(swf, ID, "End", data); } - - public EndTag(SWF swf) { - super(swf, ID, "End", null); - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java index 81d671dd3..42308430b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.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; @@ -46,6 +47,10 @@ public class ExportAssetsTag extends Tag { public List names; public static final int ID = 56; + /** + * Constructor + * @param swf + */ public ExportAssetsTag(SWF swf) { super(swf, ID, "ExportAssets", null); tags = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java index 25f638120..d1d3c8b80 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/FileAttributesTag.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; @@ -44,6 +45,10 @@ public class FileAttributesTag extends Tag { public int reserved3; public static final int ID = 69; + /** + * Constructor + * @param swf + */ public FileAttributesTag(SWF swf) { super(swf, ID, "FileAttributes", null); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java index 68f4530a5..196e124b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssets2Tag.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.ImportTag; @@ -55,6 +57,16 @@ public class ImportAssets2Tag extends Tag implements ImportTag { public List names; public static final int ID = 71; + /** + * Constructor + * @param swf + */ + public ImportAssets2Tag(SWF swf) { + super(swf, ID, "ImportAssets2", null); + url = ""; + tags = new ArrayList<>(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java index 61f92d494..523becd6e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ImportAssetsTag.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.ImportTag; @@ -48,6 +50,16 @@ public class ImportAssetsTag extends Tag implements ImportTag { public List names; public static final int ID = 57; + /** + * Constructor + * @param swf + */ + public ImportAssetsTag(SWF swf) { + super(swf, ID, "ImportAssets", null); + url = ""; + tags = new ArrayList<>(); + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java index 0e88e1e8f..3f8199252 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/JPEGTablesTag.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; @@ -29,6 +31,15 @@ public class JPEGTablesTag extends Tag { @Internal public byte[] jpegData; + /** + * Constructor + * @param swf + */ + public JPEGTablesTag(SWF swf) { + super(swf, ID, "JPEGTables", null); + jpegData = new byte[0]; + } + public JPEGTablesTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "JPEGTables", data); jpegData = sis.readBytesEx(sis.available(), "jpegData"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/MetadataTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/MetadataTag.java index ac63c4be1..1af4c2fa7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/MetadataTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/MetadataTag.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.Multiline; @@ -29,6 +31,15 @@ public class MetadataTag extends Tag { public String xmlMetadata; public static final int ID = 77; + /** + * Constructor + * @param swf + */ + public MetadataTag(SWF swf) { + super(swf, ID, "Metadata", null); + xmlMetadata = ""; + } + public MetadataTag(SWFInputStream sis, ByteArrayRange data) { super(sis.getSwf(), ID, "Metadata", data); try { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java index 62661e2f2..3e9b185ba 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProductInfoTag.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; @@ -44,6 +46,14 @@ public class ProductInfoTag extends Tag { public long compilationDateHigh; public static final int ID = 41; + /** + * Constructor + * @param swf + */ + public ProductInfoTag(SWF swf) { + super(swf, ID, "ProductInfo", null); + } + public ProductInfoTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "ProductInfo", data); /* diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProtectTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProtectTag.java index 8f4a91f85..6bd70a8ef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProtectTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ProtectTag.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; @@ -55,6 +57,15 @@ public class ProtectTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public ProtectTag(SWF swf) { + super(swf, ID, "Protect", null); + passwordHash = ""; + } + /** * Constructor * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java index 82559d80e..0361e57f8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/ScriptLimitsTag.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; @@ -34,6 +36,14 @@ public class ScriptLimitsTag extends Tag { public static final int ID = 65; + /** + * Constructor + * @param swf + */ + public ScriptLimitsTag(SWF swf) { + super(swf, ID, "ScriptLimits", null); + } + public ScriptLimitsTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "ScriptLimits", data); maxRecursionDepth = sis.readUI16("maxRecursionDepth"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java index 889ba2b4e..66f391632 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetBackgroundColorTag.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; @@ -28,6 +29,15 @@ public class SetBackgroundColorTag extends Tag { public RGB backgroundColor; public static final int ID = 9; + /** + * Constructor + * @param swf + */ + public SetBackgroundColorTag(SWF swf) { + super(swf, ID, "SetBackgroundColor", null); + backgroundColor = new RGB(); + } + public SetBackgroundColorTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "SetBackgroundColor", data); backgroundColor = sis.readRGB("backgroundColor"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java index 8a5b2594c..2c987d996 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SetTabIndexTag.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; @@ -62,6 +64,14 @@ public class SetTabIndexTag extends Tag { return baos.toByteArray(); } + /** + * Constructor + * @param swf + */ + public SetTabIndexTag(SWF swf) { + super(swf, ID, "SetTabIndex", null); + } + /** * 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 348a775f2..774179c7c 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 @@ -48,6 +48,14 @@ public class ShowFrameTag extends Tag { } }; + /** + * Constructor + * @param swf + */ + public ShowFrameTag(SWF swf) { + super(swf, ID, "ShowFrame", null); + } + /** * Constructor * @@ -58,14 +66,6 @@ public class ShowFrameTag extends Tag { super(swf, ID, "ShowFrame", data); } - /** - * Constructor - * @param swf - */ - public ShowFrameTag(SWF swf) { - super(swf, ID, "ShowFrame", null); - } - /** * Gets data bytes * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java index d9ae99f7d..31273e4f7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SymbolClassTag.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; @@ -34,6 +36,16 @@ public class SymbolClassTag extends Tag { public String[] names; public static final int ID = 76; + /** + * Constructor + * @param swf + */ + public SymbolClassTag(SWF swf) { + super(swf, ID, "SymbolClass", null); + tags = new int[0]; + names = new String[0]; + } + public SymbolClassTag(SWFInputStream sis, ByteArrayRange data) throws IOException { super(sis.getSwf(), ID, "SymbolClass", data); int numSymbols = sis.readUI16("numSymbols"); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 10547f5df..d57c2e18b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -548,7 +548,7 @@ public class Timeline { return true; } - private boolean isSingleFrame(int frame) { + public boolean isSingleFrame(int frame) { Frame frameObj = frames.get(frame); int maxDepth = getMaxDepthInternal(); for (int i = 1; i <= maxDepth; i++) { diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index 6c74b0a66..8ded352ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -159,12 +159,11 @@ public class ExportDialog extends AppDialog { cnt.setLayout(new BorderLayout()); JPanel comboPanel = new JPanel(null); combos = new JComboBox[optionNames.length]; - JLabel[] labels = new JLabel[optionNames.length]; int labWidth = 0; for (int i = 0; i < optionNames.length; i++) { - labels[i] = new JLabel(optionNames[i]); - if (labels[i].getPreferredSize().width > labWidth) { - labWidth = labels[i].getPreferredSize().width; + JLabel label = new JLabel(optionNames[i]); + if (label.getPreferredSize().width > labWidth) { + labWidth = label.getPreferredSize().width; } } String exportFormatsStr = Configuration.lastSelectedExportFormats.get(); diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 2bfe0751b..d7ecf7e1b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -594,7 +594,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis img = image; } - if (drawable.getTimeline().isSingleFrame()) { + if (drawable.getTimeline().isSingleFrame(frame)) { SWF.putToCache(key, img); } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java index 9cd1871c2..07c1f75a4 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTree.java @@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.gui.MainFrameRibbonMenu; import com.jpexs.decompiler.flash.gui.MainPanel; import com.jpexs.decompiler.flash.gui.TreeNodeType; import com.jpexs.decompiler.flash.gui.View; +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; @@ -33,14 +35,22 @@ 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; @@ -50,19 +60,38 @@ 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.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.Tag; import com.jpexs.decompiler.flash.tags.VideoFrameTag; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -360,7 +389,14 @@ public class TagTree extends JTree implements ActionListener { ret = new ArrayList<>(); break; case TagTreeModel.FOLDER_OTHERS: - ret = new ArrayList<>(); + ret = Arrays.asList(CSMTextSettingsTag.ID, DebugIDTag.ID, DefineButtonCxformTag.ID, DefineButtonSoundTag.ID, + DefineFontAlignZonesTag.ID, DefineFontInfoTag.ID, DefineFontInfo2Tag.ID, DefineFontNameTag.ID, + DefineScalingGridTag.ID, DefineSceneAndFrameLabelDataTag.ID, + DoABCDefineTag.ID, DoABCTag.ID, DoActionTag.ID, DoInitActionTag.ID, + EnableDebuggerTag.ID, EnableDebugger2Tag.ID, EnableTelemetryTag.ID, + ExportAssetsTag.ID, FileAttributesTag.ID, ImportAssetsTag.ID, ImportAssets2Tag.ID, + JPEGTablesTag.ID, MetadataTag.ID, ProductInfoTag.ID, ProtectTag.ID, ScriptLimitsTag.ID, + SetBackgroundColorTag.ID, SetTabIndexTag.ID, SymbolClassTag.ID); break; } From 7323ce4545ce3ee7005deb9596a091fa1e06e84f Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Fri, 7 Nov 2014 20:24:25 +0100 Subject: [PATCH 5/5] move new character tags to appropriate location --- .../src/com/jpexs/decompiler/flash/SWF.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 58accef09..8e42b9c26 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -285,7 +285,36 @@ public final class SWF implements SWFContainerItem, Timelined { return max + 1; } - + + public void fixCharactersOrder(boolean checkAll) { + Set addedCharacterIds = new HashSet<>(); + Set movedTags = new HashSet<>(); + for (int i = 0; i < tags.size(); i++) { + Tag tag = tags.get(i); + if (checkAll || tag.isModified()) { + Set needed = new HashSet<>(); + tag.getNeededCharacters(needed); + for (Integer id : needed) { + if (!addedCharacterIds.contains(id)) { + CharacterTag neededCharacter = characters.get(id); + if (movedTags.contains(neededCharacter)) { + logger.log(Level.SEVERE, "Fixing characters order failed, recursion detected."); + return; + } + + // move the needed character to the current position + tags.remove(neededCharacter); + tags.add(i, neededCharacter); + movedTags.add(neededCharacter); + } + } + } + if (tag instanceof CharacterTag) { + addedCharacterIds.add(((CharacterTag) tag).getCharacterId()); + } + } + } + public void resetTimelines(Timelined timelined) { timelined.getTimeline().reset(); for (Tag t : timelined.getTimeline().tags) { @@ -402,6 +431,8 @@ public final class SWF implements SWFContainerItem, Timelined { */ public void saveTo(OutputStream os, SWFCompression compression) throws IOException { try { + fixCharactersOrder(false); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); SWFOutputStream sos = new SWFOutputStream(baos, version); sos.writeRECT(displayRect);