From 382cd6eebf43a5af18bcc3a183a6d845cf17ace9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 12 Nov 2022 16:16:33 +0100 Subject: [PATCH] Show in Hex dump for BUTTONCONDACTION, BUTTONRECORD, CLIPACTIONRECORD --- CHANGELOG.md | 1 + .../decompiler/flash/tags/base/ASMSource.java | 3 +- .../decompiler/flash/tags/base/ButtonTag.java | 2 +- .../flash/types/BUTTONCONDACTION.java | 7 +- .../decompiler/flash/types/BUTTONRECORD.java | 4 +- .../flash/types/CLIPACTIONRECORD.java | 10 +-- .../decompiler/flash/types/HasSwfAndTag.java | 2 +- .../flash/gui/GenericTagTreePanel.java | 4 +- .../flash/gui/dumpview/DumpTree.java | 81 ++++++++++++++++++- .../flash/gui/tagtree/TagTreeContextMenu.java | 9 ++- 10 files changed, 102 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd4988bf..b5919cf8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - [#1701] Setting charset for SWF files with version 5 or lower (GUI, commandline) - [#1864] Commandline: Allow to set special value "/dev/stdin" for input files to read from stdin (even on Windows) - Show button records in the tree, preview them +- Show in Hex dump for BUTTONCONDACTION, BUTTONRECORD, CLIPACTIONRECORD ### Fixed - Exception when bundle selected diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index 6c043ad44..c08abb613 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.ConstantPoolTooBigException; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.types.HasSwfAndTag; import com.jpexs.helpers.ByteArrayRange; import java.util.List; @@ -31,7 +32,7 @@ import java.util.List; * * @author JPEXS */ -public interface ASMSource extends Exportable { +public interface ASMSource extends Exportable, HasSwfAndTag { /** * Converts actions to ASM source diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java index 14cabbd00..d21ad34f0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java @@ -200,7 +200,7 @@ public abstract class ButtonTag extends DrawableTag implements Timelined { public void setSwf(SWF swf, boolean deep) { this.swf = swf; for(BUTTONRECORD record:getRecords()) { - record.setSwfAndTag(swf, this); + record.setSourceTag(this); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index 2b3b2fb04..b3a2c3c15 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -43,7 +43,7 @@ import java.util.List; * * @author JPEXS */ -public class BUTTONCONDACTION implements ASMSource, Serializable { +public class BUTTONCONDACTION implements ASMSource, Serializable, HasSwfAndTag { private SWF swf; @@ -357,4 +357,9 @@ public class BUTTONCONDACTION implements ASMSource, Serializable { this.tag = t; this.swf = t.getSwf(); } + + @Override + public Tag getTag() { + return tag; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONRECORD.java index 48e9532f0..5d69f91fa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/BUTTONRECORD.java @@ -153,8 +153,8 @@ public class BUTTONRECORD implements Serializable, TreeItem, HasSwfAndTag, HasCh } @Override - public void setSwfAndTag(SWF swf, Tag tag) { - this.swf = swf; + public void setSourceTag(Tag tag) { + this.swf = tag.getSwf(); this.tag = (ButtonTag) tag; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index d2b65a80c..42a63dcec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -145,8 +145,8 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag { } @Override - public void setSwfAndTag(SWF swf, Tag tag) { - this.swf = swf; + public void setSourceTag(Tag tag) { + this.swf = tag.getSwf(); this.tag = tag; } @@ -344,10 +344,4 @@ public class CLIPACTIONRECORD implements ASMSource, Serializable, HasSwfAndTag { public Tag getSourceTag() { return tag; } - - @Override - public void setSourceTag(Tag t) { - this.tag = t; - this.swf = t.getSwf(); - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/HasSwfAndTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/HasSwfAndTag.java index f837ddbfc..d226acf1a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/HasSwfAndTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/HasSwfAndTag.java @@ -8,7 +8,7 @@ import com.jpexs.decompiler.flash.tags.Tag; * @author JPEXS */ public interface HasSwfAndTag { - public void setSwfAndTag(SWF swf, Tag tag); + public void setSourceTag(Tag tag); public SWF getSwf(); diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index ae4a325ae..e40363a28 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -1230,7 +1230,7 @@ public class GenericTagTreePanel extends GenericTagPanel { asv.setSourceTag(editedTag); } if (v instanceof HasSwfAndTag) { - ((HasSwfAndTag) obj).setSwfAndTag(editedTag.getSwf(), editedTag); + ((HasSwfAndTag) obj).setSourceTag(editedTag); } } catch (IllegalArgumentException | IllegalAccessException ex) { //ignore @@ -1265,7 +1265,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } if (obj instanceof HasSwfAndTag) { - ((HasSwfAndTag) obj).setSwfAndTag(editedTag.getSwf(), editedTag); + ((HasSwfAndTag) obj).setSourceTag(editedTag); } } catch (IllegalArgumentException | IllegalAccessException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java index 5f539edcc..aacb0951f 100644 --- a/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java +++ b/src/com/jpexs/decompiler/flash/gui/dumpview/DumpTree.java @@ -77,9 +77,16 @@ 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.Tag; +import com.jpexs.decompiler.flash.tags.base.ButtonTag; +import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.treeitems.TreeItem; +import com.jpexs.decompiler.flash.types.BUTTONCONDACTION; +import com.jpexs.decompiler.flash.types.BUTTONRECORD; +import com.jpexs.decompiler.flash.types.CLIPACTIONRECORD; +import com.jpexs.decompiler.flash.types.CLIPACTIONS; +import com.jpexs.decompiler.flash.types.HasSwfAndTag; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; @@ -604,8 +611,16 @@ public class DumpTree extends JTree { } } } - - public void setSelectedTag(Tag tag) { + + public void setSelectedItem(TreeItem item) { + Tag tag; + if (item instanceof Tag) { + tag = (Tag) item; + } else if (item instanceof HasSwfAndTag) { + tag = ((HasSwfAndTag) item).getTag(); + } else { + return; + } ByteArrayRange range = tag.getOriginalRange(); if (range == null) { return; @@ -616,7 +631,7 @@ public class DumpTree extends JTree { for (DumpInfo sd : d.getChildInfos()) { if (sd instanceof DumpInfoSwfNode) { DumpInfoSwfNode si = (DumpInfoSwfNode) sd; - if (si.getSwf() == tag.getSwf()) { + if (si.getSwf() == item.getSwf()) { DumpInfo di = si; while (model.getChildCount(di) > 0) { boolean found = false; @@ -635,6 +650,66 @@ public class DumpTree extends JTree { } di = di.parent; // tagId is selected, lets select the tag instead TreePath selPath = model.getDumpInfoPath(di); + + if (item instanceof CLIPACTIONRECORD) { + CLIPACTIONS clipActions = ((PlaceObjectTypeTag) tag).getClipActions(); + int index = clipActions.clipActionRecords.indexOf(item); + for (DumpInfo sdi : di.getChildInfos()) { + if ("clipActions".equals(sdi.name)) { + int i = 0; + for (DumpInfo sdi2 : sdi.getChildInfos()) { + if (sdi2.name.equals("record")) { + if (i == index) { + selPath = model.getDumpInfoPath(sdi2); + break; + } + i++; + } + } + break; + } + } + } + if (item instanceof BUTTONCONDACTION) { + DefineButton2Tag button = (DefineButton2Tag) tag; + int index = button.actions.indexOf(item); + for (DumpInfo sdi : di.getChildInfos()) { + if ("actions".equals(sdi.name)) { + int i = 0; + for (DumpInfo sdi2 : sdi.getChildInfos()) { + if (sdi2.name.equals("action")) { + if (i == index) { + selPath = model.getDumpInfoPath(sdi2); + break; + } + i++; + } + } + break; + } + } + } + + if (item instanceof BUTTONRECORD) { + ButtonTag button = (ButtonTag) tag; + int index = button.getRecords().indexOf(item); + for (DumpInfo sdi : di.getChildInfos()) { + if ("characters".equals(sdi.name)) { + int i = 0; + for (DumpInfo sdi2 : sdi.getChildInfos()) { + if (sdi2.name.equals("record")) { + if (i == index) { + selPath = model.getDumpInfoPath(sdi2); + break; + } + i++; + } + } + break; + } + } + } + if (selPath != null) { setSelectionPath(selPath); scrollPathToVisible(selPath); diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index a7a607da8..50dbb5f3d 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -880,7 +880,12 @@ public class TagTreeContextMenu extends JPopupMenu { showInTagListViewTagMenuItem.setVisible(true); } - if (firstItem instanceof Tag) { + if ( + (firstItem instanceof Tag) || + (firstItem instanceof CLIPACTIONRECORD) || + (firstItem instanceof BUTTONRECORD) || + (firstItem instanceof BUTTONCONDACTION) + ) { showInHexDumpViewTagMenuItem.setVisible(true); } @@ -2469,7 +2474,7 @@ public class TagTreeContextMenu extends JPopupMenu { } TreeItem item = getTree().getCurrentTreeItem(); mainPanel.showView(MainPanel.VIEW_DUMP); - mainPanel.dumpTree.setSelectedTag((Tag) item); + mainPanel.dumpTree.setSelectedItem(item); mainPanel.updateMenu(); }