diff --git a/trunk/src/com/jpexs/decompiler/flash/PackageNode.java b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java
new file mode 100644
index 000000000..758568da1
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 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;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class PackageNode {
+ public String packageName;
+
+ public PackageNode(String packageName) {
+ this.packageName = packageName;
+ }
+
+ @Override
+ public String toString() {
+ return packageName;
+ }
+
+
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java
index 96728ca05..39b8f8fd2 100644
--- a/trunk/src/com/jpexs/decompiler/flash/SWF.java
+++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java
@@ -535,6 +535,7 @@ public class SWF {
if (t instanceof ExportAssetsTag) {
exportAssetsTags.add((ExportAssetsTag) t);
}
+ TagNode addNode = null;
if (t instanceof ShowFrameTag) {
TagNode tti = new TagNode(new FrameNode(frame, parent, false));
@@ -543,8 +544,10 @@ public class SWF {
if (!(ret.get(r).tag instanceof DefineButtonTag)) {
if (!(ret.get(r).tag instanceof DefineButton2Tag)) {
if (!(ret.get(r).tag instanceof DoInitActionTag)) {
- tti.subItems.add(ret.get(r));
- ret.remove(r);
+ if (!(ret.get(r).tag instanceof PackageNode)) {
+ tti.subItems.add(ret.get(r));
+ ret.remove(r);
+ }
}
}
}
@@ -554,7 +557,8 @@ public class SWF {
frames.add(tti);
} else if (t instanceof ASMSource) {
TagNode tti = new TagNode(t);
- ret.add(tti);
+ //ret.add(tti);
+ addNode = tti;
} else if (t instanceof Container) {
if (((Container) t).getItemCount() > 0) {
@@ -562,7 +566,52 @@ public class SWF {
List subItems = ((Container) t).getSubItems();
tti.subItems = createASTagList(subItems, t);
- ret.add(tti);
+ addNode = tti;
+ //ret.add(tti);
+ }
+ }
+ if (addNode != null) {
+ if (addNode.tag instanceof CharacterIdTag) {
+ CharacterIdTag cit = (CharacterIdTag) addNode.tag;
+ String path = cit.getExportName();
+ if(path==null){
+ path="";
+ }
+ String pathParts[];
+ if (path.contains(".")) {
+ pathParts = path.split("\\.");
+ } else {
+ pathParts = new String[]{path};
+ }
+ List items = ret;
+ int pos = 0;
+ TagNode selNode = null;
+ do {
+ if(pos==pathParts.length-1){
+ break;
+ }
+ selNode = null;
+ for (TagNode node : items) {
+ if (node.tag instanceof PackageNode) {
+ PackageNode pkg = (PackageNode) node.tag;
+ if (pkg.packageName.equals(pathParts[pos])) {
+ selNode = node;
+ break;
+ }
+ }
+ }
+ if (selNode == null) {
+ items.add(selNode=new TagNode(new PackageNode(pathParts[pos])));
+ }
+ pos++;
+ if(selNode!=null){
+ items=selNode.subItems;
+ }
+
+ } while (selNode != null);
+ items.add(addNode);
+ }else{
+ ret.add(addNode);
}
}
@@ -1430,6 +1479,21 @@ public class SWF {
}
HashMap typeCounts = new HashMap<>();
+ public int deobfuscateIdentifiers(RenameType renameType){
+ if(fileAttributes==null){
+ int cnt=0;
+ cnt+=deobfuscateAS2Identifiers(renameType);
+ cnt+=deobfuscateAS3Identifiers(renameType);
+ return cnt;
+ }else{
+ if(fileAttributes.actionScript3){
+ return deobfuscateAS3Identifiers(renameType);
+ }else{
+ return deobfuscateAS2Identifiers(renameType);
+ }
+ }
+ }
+
public int deobfuscateAS2Identifiers(RenameType renameType) {
actionsMap = new HashMap<>();
allFunctions = new ArrayList<>();
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java
index f8595b971..6bd07444a 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java
@@ -628,6 +628,10 @@ public class Action implements GraphSourceItem {
return -1;
}
+ public static List actionsToTree(List actions, int version) {
+ return actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version);
+ }
+
/**
* Converts list of actions to ActionScript source code
*
diff --git a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java
index 71e45788b..fe7fcae14 100644
--- a/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java
+++ b/trunk/src/com/jpexs/decompiler/flash/action/treemodel/clauses/ClassTreeItem.java
@@ -29,7 +29,7 @@ import java.util.List;
public class ClassTreeItem extends TreeItem implements Block {
- private List functions;
+ public List functions;
public List staticFunctions;
public GraphTargetItem extendsOp;
public List implementsOp;
diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java
index 989cacfb2..a02630300 100644
--- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java
+++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.FrameNode;
+import com.jpexs.decompiler.flash.PackageNode;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.TagNode;
@@ -948,6 +949,9 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
return "package";
}
}
+ if(t instanceof PackageNode){
+ return "package";
+ }
if (t instanceof FrameNode) {
return "frame";
}
@@ -1705,12 +1709,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
protected Object doInBackground() throws Exception {
try {
int cnt = 0;
-
- if (abcPanel != null) {
- cnt = swf.deobfuscateAS3Identifiers(renameType);
- } else {
- cnt = swf.deobfuscateAS2Identifiers(renameType);
- }
+ cnt = swf.deobfuscateIdentifiers(renameType);
Main.stopWork();
JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt);
if (abcPanel != null) {
diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java
index 6c1cac4bb..12b23bc51 100644
--- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java
+++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java
@@ -21,6 +21,7 @@ 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;
+import com.jpexs.decompiler.flash.helpers.Helper;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
@@ -251,4 +252,15 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
public int getNumFrames() {
return frameCount;
}
+
+ @Override
+ public String getExportFileName() {
+ String expName=getExportName();
+ if((expName==null) || expName.equals("")){
+ return super.getExportFileName();
+ }
+ return Helper.makeFileName(super.getExportFileName()+"_"+expName);
+ }
+
+
}
diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java
index 304c5ae96..ed2e44447 100644
--- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java
+++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java
@@ -22,7 +22,9 @@ import com.jpexs.decompiler.flash.ReReadableInputStream;
import com.jpexs.decompiler.flash.SWFInputStream;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.action.Action;
+import com.jpexs.decompiler.flash.helpers.Helper;
import com.jpexs.decompiler.flash.tags.base.ASMSource;
+import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -31,7 +33,7 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-public class DoInitActionTag extends Tag implements ASMSource {
+public class DoInitActionTag extends CharacterIdTag implements ASMSource {
/**
* Identifier of Sprite
@@ -145,6 +147,7 @@ public class DoInitActionTag extends Tag implements ASMSource {
this.actionBytes = actionBytes;
}
+ @Override
public int getCharacterID() {
return spriteId;
}
@@ -159,4 +162,38 @@ public class DoInitActionTag extends Tag implements ASMSource {
public void removeDisassemblyListener(DisassemblyListener listener) {
listeners.remove(listener);
}
+
+ @Override
+ public String getExportFileName() {
+ String expName=getExportName();
+ if((expName==null) || expName.equals("")){
+ return super.toString();
+ }
+ String pathParts[];
+ if(expName.contains(".")){
+ pathParts = expName.split("\\.");
+ }else{
+ pathParts = new String[]{expName};
+ }
+ return Helper.makeFileName(pathParts[pathParts.length-1]);
+ }
+
+
+
+ @Override
+ public String toString() {
+ String expName=getExportName();
+ if((expName==null) || expName.equals("")){
+ return super.toString();
+ }
+ String pathParts[];
+ if(expName.contains(".")){
+ pathParts = expName.split("\\.");
+ }else{
+ pathParts = new String[]{expName};
+ }
+ return pathParts[pathParts.length-1];
+ }
+
+
}
diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java
index 4bff19a71..e9ec2282a 100644
--- a/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java
+++ b/trunk/src/com/jpexs/decompiler/flash/tags/Tag.java
@@ -49,7 +49,7 @@ public class Tag implements NeedsCharacters {
return name;
}
- public String getExportName() {
+ public String getExportFileName() {
return getName();
}
diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java
new file mode 100644
index 000000000..7137fa52a
--- /dev/null
+++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 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.tags.base;
+
+import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
+import com.jpexs.decompiler.flash.tags.Tag;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author JPEXS
+ */
+public abstract class CharacterIdTag extends Tag {
+ public CharacterIdTag(int id, String name, byte[] data, long pos) {
+ super(id, name, data, pos);
+ }
+
+ public abstract int getCharacterID();
+ /**
+ * List of ExportAssetsTag used for converting to String
+ */
+ public List exportAssetsTags = new ArrayList<>();
+ private String className;
+ private String exportName;
+
+ public void setExportName(String exportName){
+ this.exportName = exportName;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ @Override
+ public String getName() {
+ String nameAppend = "";
+ if (exportName != null) {
+ nameAppend = ": " + exportName;
+ }
+ if (className != null) {
+ nameAppend = ": " + className;
+ }
+ return super.getName() + " (" + getCharacterID() + nameAppend + ")";
+ }
+
+ @Override
+ public String getExportFileName() {
+ return super.getName() + "_" + getCharacterID();
+ }
+
+ public String getExportName() {
+ return exportName;
+ }
+
+
+}
diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java
index 0844df76e..9a5df7055 100644
--- a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java
+++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java
@@ -25,44 +25,11 @@ import java.util.List;
*
* @author JPEXS
*/
-public abstract class CharacterTag extends Tag {
+public abstract class CharacterTag extends CharacterIdTag {
public CharacterTag(int id, String name, byte[] data, long pos) {
super(id, name, data, pos);
}
- public abstract int getCharacterID();
- /**
- * List of ExportAssetsTag used for converting to String
- */
- public List exportAssetsTags = new ArrayList<>();
- private String className;
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public String getClassName() {
- return className;
- }
-
- @Override
- public String getName() {
- String nameAppend = "";
- for (ExportAssetsTag eat : exportAssetsTags) {
- int pos = eat.tags.indexOf(getCharacterID());
- if (pos > -1) {
- nameAppend = ": " + eat.names.get(pos);
- }
- }
- if (className != null) {
- nameAppend = ": " + className;
- }
- return super.getName() + " (" + getCharacterID() + nameAppend + ")";
- }
-
- @Override
- public String getExportName() {
- return super.getName() + "_" + getCharacterID();
- }
+
}