From 65ef206650ecf88eceedbc6c9c067ee95d3ee5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 23 Jun 2013 16:16:44 +0200 Subject: [PATCH] Issue #63 Globally rename identifier --- .../jpexs/decompiler/flash/PackageNode.java | 3 +- trunk/src/com/jpexs/decompiler/flash/SWF.java | 84 +- .../com/jpexs/decompiler/flash/abc/ABC.java | 14 + .../flash/abc/gui/DecompiledEditorPane.java | 35 + .../flash/action/gui/ActionPanel.java | 41 + .../flash/action/swf4/ActionPush.java | 2 +- .../flash/graph/GraphTargetItem.java | 2 +- .../com/jpexs/decompiler/flash/gui/Main.java | 3 + .../jpexs/decompiler/flash/gui/MainFrame.java | 1180 +++++++++-------- .../decompiler/flash/gui/RenameDialog.java | 8 +- .../flash/tags/DefineSpriteTag.java | 8 +- .../flash/tags/DoInitActionTag.java | 24 +- .../flash/tags/base/CharacterIdTag.java | 15 +- .../flash/tags/base/CharacterTag.java | 2 - 14 files changed, 810 insertions(+), 611 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/PackageNode.java b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java index 758568da1..3986005c7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/PackageNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/PackageNode.java @@ -21,6 +21,7 @@ package com.jpexs.decompiler.flash; * @author JPEXS */ public class PackageNode { + public String packageName; public PackageNode(String packageName) { @@ -31,6 +32,4 @@ public class PackageNode { 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 fa993bdfe..ccd2f5ad3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -109,6 +109,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.Stack; import java.util.logging.Level; @@ -574,8 +575,8 @@ public class SWF { if (addNode.tag instanceof CharacterIdTag) { CharacterIdTag cit = (CharacterIdTag) addNode.tag; String path = cit.getExportName(); - if(path==null){ - path=""; + if (path == null) { + path = ""; } String pathParts[]; if (path.contains(".")) { @@ -587,7 +588,7 @@ public class SWF { int pos = 0; TagNode selNode = null; do { - if(pos==pathParts.length-1){ + if (pos == pathParts.length - 1) { break; } selNode = null; @@ -598,19 +599,19 @@ public class SWF { selNode = node; break; } - } + } } if (selNode == null) { - items.add(selNode=new TagNode(new PackageNode(pathParts[pos]))); + items.add(selNode = new TagNode(new PackageNode(pathParts[pos]))); } pos++; - if(selNode!=null){ - items=selNode.subItems; + if (selNode != null) { + items = selNode.subItems; } - + } while (selNode != null); items.add(addNode); - }else{ + } else { ret.add(addNode); } } @@ -1196,8 +1197,15 @@ public class SWF { return ret; } - public String deobfuscateName(HashMap namesMap, String s, boolean firstUppercase, String usageType, RenameType renameType) { + public String deobfuscateName(HashMap namesMap, String s, boolean firstUppercase, String usageType, RenameType renameType, Map selected) { boolean isValid = true; + + if (selected != null) { + if (selected.containsKey(s)) { + return selected.get(s); + } + } + if (isReserved(s)) { isValid = false; } @@ -1226,7 +1234,7 @@ public class SWF { cnt = 0; } - String ret; + String ret = null; if (renameType == RenameType.TYPENUMBER) { boolean found; @@ -1237,7 +1245,7 @@ public class SWF { found = allVariableNamesStr.contains(ret); } while (found); typeCounts.put(usageType, cnt); - } else { + } else if (renameType == RenameType.RANDOMWORD) { ret = fooString(s, firstUppercase, DEFAULT_FOO_SIZE); } return ret; @@ -1479,22 +1487,32 @@ public class SWF { } HashMap typeCounts = new HashMap<>(); - public int deobfuscateIdentifiers(RenameType renameType){ - if(fileAttributes==null){ - int cnt=0; - cnt+=deobfuscateAS2Identifiers(renameType); - cnt+=deobfuscateAS3Identifiers(renameType); + public int deobfuscateIdentifiers(RenameType renameType) { + if (fileAttributes == null) { + int cnt = 0; + cnt += deobfuscateAS2Identifiers(renameType); + cnt += deobfuscateAS3Identifiers(renameType); return cnt; - }else{ - if(fileAttributes.actionScript3){ + } else { + if (fileAttributes.actionScript3) { return deobfuscateAS3Identifiers(renameType); - }else{ + } else { return deobfuscateAS2Identifiers(renameType); } } } - + + public void renameAS2Identifier(String identifier, String newname) { + Map selected = new HashMap<>(); + selected.put(identifier, newname); + renameAS2Identifiers(null, selected); + } + public int deobfuscateAS2Identifiers(RenameType renameType) { + return renameAS2Identifiers(renameType, null); + } + + private int renameAS2Identifiers(RenameType renameType, Map selected) { actionsMap = new HashMap<>(); allFunctions = new ArrayList<>(); allVariableNames = new HashMap<>(); @@ -1504,14 +1522,14 @@ public class SWF { int ret = 0; objs.addAll(tags); getVariables(objs, ""); - informListeners("deobfuscate", ""); + informListeners("rename", ""); int fc = 0; for (DirectValueTreeItem ti : allVariableNames.keySet()) { String name = ti.toStringNoH(allVariableNames.get(ti)); allVariableNamesStr.add(name); } - informListeners("deobfuscate", "classes"); + informListeners("rename", "classes"); int classCount = 0; for (Tag t : tags) { if (t instanceof DoInitActionTag) { @@ -1522,7 +1540,7 @@ public class SWF { for (Tag t : tags) { if (t instanceof DoInitActionTag) { cnt++; - informListeners("deobfuscate", "class " + cnt + "/" + classCount); + informListeners("rename", "class " + cnt + "/" + classCount); DoInitActionTag dia = (DoInitActionTag) t; String exportName = dia.getExportName(); final String pkgPrefix = "__Packages."; @@ -1550,7 +1568,7 @@ public class SWF { if (fun.calculatedFunctionName instanceof DirectValueTreeItem) { DirectValueTreeItem dvf = (DirectValueTreeItem) fun.calculatedFunctionName; String fname = dvf.toStringNoH(null); - String changed = deobfuscateName(deobfuscated, fname, false, "method", renameType); + String changed = deobfuscateName(deobfuscated, fname, false, "method", renameType, selected); if (changed != null) { deobfuscated.put(fname, changed); } @@ -1566,7 +1584,7 @@ public class SWF { if (gti instanceof DirectValueTreeItem) { DirectValueTreeItem dvf = (DirectValueTreeItem) gti; String vname = dvf.toStringNoH(null); - String changed = deobfuscateName(deobfuscated, vname, false, "attribute", renameType); + String changed = deobfuscateName(deobfuscated, vname, false, "attribute", renameType, selected); if (changed != null) { deobfuscated.put(vname, changed); } @@ -1600,7 +1618,7 @@ public class SWF { if (classNameParts != null) { changedNameStr = classNameParts[classNameParts.length - 1 - pos]; } - String changedNameStr2 = deobfuscateName(deobfuscated, changedNameStr, pos == 0, pos == 0 ? "class" : "package", renameType); + String changedNameStr2 = deobfuscateName(deobfuscated, changedNameStr, pos == 0, pos == 0 ? "class" : "package", renameType, selected); if (changedNameStr2 != null) { changedNameStr = changedNameStr2; } @@ -1623,7 +1641,7 @@ public class SWF { if (classNameParts != null) { changedNameStr = classNameParts[classNameParts.length - 1 - pos]; } - String changedNameStr2 = deobfuscateName(deobfuscated, changedNameStr, pos == 0, pos == 0 ? "class" : "package", renameType); + String changedNameStr2 = deobfuscateName(deobfuscated, changedNameStr, pos == 0, pos == 0 ? "class" : "package", renameType, selected); if (changedNameStr2 != null) { changedNameStr = changedNameStr2; } @@ -1637,17 +1655,17 @@ public class SWF { for (GraphSourceItem fun : allFunctions) { fc++; - informListeners("deobfuscate", "function " + fc + "/" + allFunctions.size()); + informListeners("rename", "function " + fc + "/" + allFunctions.size()); if (fun instanceof ActionDefineFunction) { ActionDefineFunction f = (ActionDefineFunction) fun; - String changed = deobfuscateName(deobfuscated, f.functionName, false, "function", renameType); + String changed = deobfuscateName(deobfuscated, f.functionName, false, "function", renameType, selected); if (changed != null) { f.replacedFunctionName = changed; } } if (fun instanceof ActionDefineFunction2) { ActionDefineFunction2 f = (ActionDefineFunction2) fun; - String changed = deobfuscateName(deobfuscated, f.functionName, false, "function", renameType); + String changed = deobfuscateName(deobfuscated, f.functionName, false, "function", renameType, selected); if (changed != null) { f.replacedFunctionName = changed; } @@ -1664,9 +1682,9 @@ public class SWF { int vc = 0; for (DirectValueTreeItem ti : allVariableNames.keySet()) { vc++; - informListeners("deobfuscate", "variable " + vc + "/" + allVariableNames.size()); + informListeners("rename", "variable " + vc + "/" + allVariableNames.size()); String name = ti.toStringNoH(allVariableNames.get(ti)); - String changed = deobfuscateName(deobfuscated, name, false, usageTypes.get(ti), renameType); + String changed = deobfuscateName(deobfuscated, name, false, usageTypes.get(ti), renameType, selected); if (changed != null) { boolean addNew = false; String h = System.identityHashCode(allVariableNames.get(ti)) + "_" + name; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index c426dd7b5..c95fe2f58 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -177,6 +177,20 @@ public class ABC { } } + public void renameMultiname(int multinameIndex, String newname) { + if (multinameIndex <= 0 || multinameIndex >= constants.constant_multiname.length) { + throw new IllegalArgumentException("Multiname with index " + multinameIndex + " does not exist"); + } + Set stringUsages = getStringUsages(); + int strIndex = constants.constant_multiname[multinameIndex].name_index; + if (stringUsages.contains(strIndex)) { //name is used elsewhere as string literal + strIndex = constants.forceGetStringId(newname); + constants.constant_multiname[multinameIndex].name_index = strIndex; + } else { + constants.constant_string[strIndex] = newname; + } + } + public void deobfuscateIdentifiers(HashMap namesMap, RenameType renameType) { Set stringUsages = getStringUsages(); Map stringUsageTypes = new HashMap<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index 299c3254a..1450809a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -19,9 +19,12 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.ScriptPack; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; +import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.helpers.Cache; import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; @@ -124,6 +127,38 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL reset = false; } + public int getMultinameUnderCursor() { + int pos = getCaretPosition(); + for (Highlighting h : highlights) { + if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { + List list = abc.bodies[abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex()].code.code; + AVM2Instruction lastIns = null; + long inspos = 0; + AVM2Instruction selIns = null; + for (AVM2Instruction ins : list) { + if (h.offset == ins.getOffset()) { + selIns = ins; + break; + } + if (ins.getOffset() > h.offset) { + inspos = h.offset - lastIns.offset; + selIns = lastIns; + break; + } + lastIns = ins; + } + if (selIns != null) { + for (int i = 0; i < selIns.definition.operands.length; i++) { + if (selIns.definition.operands[i] == AVM2Code.DAT_MULTINAME_INDEX) { + return selIns.operands[i]; + } + } + } + } + } + return -1; + } + @Override public void caretUpdate(CaretEvent e) { if (abc == null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index a5e1a16af..852fe0669 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -26,6 +26,8 @@ import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser; +import com.jpexs.decompiler.flash.action.swf4.ActionPush; +import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.Main; @@ -110,6 +112,45 @@ public class ActionPanel extends JPanel implements ActionListener { private boolean searchRegexp; private Cache cache = new Cache(true); + public String getStringUnderCursor() { + int pos = decompiledEditor.getCaretPosition(); + for (Highlighting h : decompiledHilights) { + if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { + List list = lastCode; + Action lastIns = null; + int inspos = 0; + Action selIns = null; + for (Action ins : list) { + if (h.offset == ins.getOffset()) { + selIns = ins; + break; + } + if (ins.getOffset() > h.offset) { + inspos = (int) (h.offset - lastIns.getAddress()); + selIns = lastIns; + break; + } + lastIns = ins; + } + if (selIns != null) { + if (selIns instanceof ActionPush) { + ActionPush ap = (ActionPush) selIns; + Object var = ap.values.get(inspos - 1); + String identifier = null; + if (var instanceof String) { + identifier = (String) var; + } + if (var instanceof ConstantIndex) { + identifier = ap.constantPool.get(((ConstantIndex) var).index); + } + return identifier; + } + } + } + } + return null; + } + private CachedScript getCached(ASMSource pack) { return (CachedScript) cache.get(pack); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 7a8fa3691..0d9b8db82 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -262,7 +262,7 @@ public class ActionPush extends Action { if (pos > 0) { ret += " "; } - ret += Highlighting.hilighOffset(toString(i), getAddress()+pos+1); + ret += Highlighting.hilighOffset(toString(i), getAddress() + pos + 1); pos++; } return ret; diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java index f54dfcac3..c47ac691e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/GraphTargetItem.java @@ -61,7 +61,7 @@ public abstract class GraphTargetItem { if (src == null) { return str; } - return Highlighting.hilighOffset(str, src.getOffset()+pos+1); + return Highlighting.hilighOffset(str, src.getOffset() + pos + 1); } public String toStringSemicoloned(List localData) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 493252e53..ae3d7148e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -187,6 +187,9 @@ public class Main { if (event.equals("deobfuscate")) { startWork("Deobfuscating..." + (String) data); } + if (event.equals("rename")) { + startWork("Renaming..." + (String) data); + } } }); return locswf; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index a02630300..8e2d42261 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.PackageNode; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.TagNode; +import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.gui.ABCPanel; @@ -324,7 +325,11 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi miSubLimiter.setActionCommand("SUBLIMITER"); miSubLimiter.addActionListener(this); - JMenuItem miRenameIdentifiers = new JMenuItem("Rename identifiers"); + JMenuItem miRenameOneIdentifier = new JMenuItem("Globally rename identifier"); + miRenameOneIdentifier.setActionCommand("RENAMEONEIDENTIFIER"); + miRenameOneIdentifier.addActionListener(this); + + JMenuItem miRenameIdentifiers = new JMenuItem("Rename invalid identifiers"); miRenameIdentifiers.setActionCommand("RENAMEIDENTIFIERS"); miRenameIdentifiers.addActionListener(this); @@ -352,7 +357,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi miControlFlowAll.setActionCommand("RESTORECONTROLFLOWALL"); miControlFlowAll.addActionListener(this); - + menuDeobfuscation.add(miRenameOneIdentifier); menuDeobfuscation.add(miRenameIdentifiers); //menuDeobfuscation.add(miSubLimiter); menuDeobfuscation.add(miDeobfuscation); @@ -949,7 +954,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi return "package"; } } - if(t instanceof PackageNode){ + if (t instanceof PackageNode) { return "package"; } if (t instanceof FrameNode) { @@ -1000,6 +1005,52 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi return ret; } + public void renameIdentifier(String identifier) { + String oldName = identifier; + String newName = JOptionPane.showInputDialog("Enter new name:", oldName); + if (newName != null) { + if (!oldName.equals(newName)) { + swf.renameAS2Identifier(oldName, newName); + JOptionPane.showMessageDialog(null, "Identifier renamed."); + doFilter(); + reload(true); + } + } + } + + public void renameMultiname(int multiNameIndex) { + String oldName = ""; + if (abcPanel.abc.constants.constant_multiname[multiNameIndex].name_index > 0) { + oldName = abcPanel.abc.constants.constant_string[abcPanel.abc.constants.constant_multiname[multiNameIndex].name_index]; + } + String newName = JOptionPane.showInputDialog("Enter new name:", oldName); + if (newName != null) { + if (!oldName.equals(newName)) { + int mulCount = 0; + for (ABCContainerTag cnt : abcList) { + ABC abc = cnt.getABC(); + for (int m = 1; m < abc.constants.constant_multiname.length; m++) { + int ni = abc.constants.constant_multiname[m].name_index; + String n = ""; + if (ni > 0) { + n = abc.constants.constant_string[ni]; + } + if (n.equals(oldName)) { + abc.renameMultiname(m, newName); + mulCount++; + } + } + } + JOptionPane.showMessageDialog(null, mulCount + " multiname(s) renamed."); + if (abcPanel != null) { + abcPanel.reload(); + } + doFilter(); + reload(true); + } + } + } + public List getAllSubs(JTree tree, Object o) { TreeModel tm = tree.getModel(); List ret = new ArrayList<>(); @@ -1187,594 +1238,635 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi @Override public void actionPerformed(ActionEvent e) { - - if (e.getActionCommand().equals("PARALLELSPEEDUP")) { - String confStr = "Parallelism can speed up loading and decompilation but uses more memory.\r\n"; - if (miParallelSpeedUp.isSelected()) { - confStr += " Do you want to turn this ON?"; - } else { - confStr += " Do you want to turn this OFF?"; - } - if (JOptionPane.showConfirmDialog(null, confStr, "Parallelism", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { - Configuration.setConfig("paralelSpeedUp", (Boolean) miParallelSpeedUp.isSelected()); - } else { - miParallelSpeedUp.setSelected(!miParallelSpeedUp.isSelected()); - } - } - if (e.getActionCommand().equals("INTERNALVIEWERSWITCH")) { - Configuration.setConfig("internalFlashViewer", (Boolean) miInternalViewer.isSelected()); - } - if (e.getActionCommand().equals("SEARCHAS")) { - if (searchDialog == null) { - searchDialog = new SearchDialog(); - } - searchDialog.setVisible(true); - if (searchDialog.result) { - final String txt = searchDialog.searchField.getText(); - if (!txt.equals("")) { - Main.startWork("Searching \"" + txt + "\"..."); - if (abcPanel != null) { - (new Thread() { - @Override - public void run() { - if (abcPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) { - showDetail(DETAILCARDAS3NAVIGATOR); - showCard(CARDACTIONSCRIPTPANEL); - } else { - JOptionPane.showMessageDialog(null, "String \"" + txt + "\" not found.", "Not found", JOptionPane.INFORMATION_MESSAGE); + switch (e.getActionCommand()) { + case "PARALLELSPEEDUP": + String confStr = "Parallelism can speed up loading and decompilation but uses more memory.\r\n"; + if (miParallelSpeedUp.isSelected()) { + confStr += " Do you want to turn this ON?"; + } else { + confStr += " Do you want to turn this OFF?"; + } + if (JOptionPane.showConfirmDialog(null, confStr, "Parallelism", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + Configuration.setConfig("paralelSpeedUp", (Boolean) miParallelSpeedUp.isSelected()); + } else { + miParallelSpeedUp.setSelected(!miParallelSpeedUp.isSelected()); + } + break; + case "INTERNALVIEWERSWITCH": + Configuration.setConfig("internalFlashViewer", (Boolean) miInternalViewer.isSelected()); + break; + case "SEARCHAS": + if (searchDialog == null) { + searchDialog = new SearchDialog(); + } + searchDialog.setVisible(true); + if (searchDialog.result) { + final String txt = searchDialog.searchField.getText(); + if (!txt.equals("")) { + Main.startWork("Searching \"" + txt + "\"..."); + if (abcPanel != null) { + (new Thread() { + @Override + public void run() { + if (abcPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) { + showDetail(DETAILCARDAS3NAVIGATOR); + showCard(CARDACTIONSCRIPTPANEL); + } else { + JOptionPane.showMessageDialog(null, "String \"" + txt + "\" not found.", "Not found", JOptionPane.INFORMATION_MESSAGE); + } + Main.stopWork(); } - Main.stopWork(); - } - }).start(); - } else { - (new Thread() { - @Override - public void run() { - if (actionPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) { - showCard(CARDACTIONSCRIPTPANEL); - } else { - JOptionPane.showMessageDialog(null, "String \"" + txt + "\" not found.", "Not found", JOptionPane.INFORMATION_MESSAGE); + }).start(); + } else { + (new Thread() { + @Override + public void run() { + if (actionPanel.search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) { + showCard(CARDACTIONSCRIPTPANEL); + } else { + JOptionPane.showMessageDialog(null, "String \"" + txt + "\" not found.", "Not found", JOptionPane.INFORMATION_MESSAGE); + } + Main.stopWork(); } - Main.stopWork(); - } - }).start(); - } - } - } - } - if (e.getActionCommand().equals("REPLACEIMAGE")) { - Object tagObj = tagTree.getLastSelectedPathComponent(); - if (tagObj == null) { - return; - } - - if (tagObj instanceof TagNode) { - tagObj = ((TagNode) tagObj).tag; - } - if (tagObj instanceof ImageTag) { - ImageTag it = (ImageTag) tagObj; - if (it.importSupported()) { - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); - fc.setFileFilter(new FileFilter() { - @Override - public boolean accept(File f) { - return (f.getName().toLowerCase().endsWith(".jpg")) - || (f.getName().toLowerCase().endsWith(".jpeg")) - || (f.getName().toLowerCase().endsWith(".gif")) - || (f.getName().toLowerCase().endsWith(".png")) - || (f.isDirectory()); - } - - @Override - public String getDescription() { - return "Images (*.jpg,*.gif,*.png)"; - } - }); - JFrame f = new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showOpenDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - Configuration.setConfig("lastOpenDir", Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); - File selfile = Helper.fixDialogFile(fc.getSelectedFile()); - byte data[] = Helper.readFile(selfile.getAbsolutePath()); - try { - it.setImage(data); - } catch (IOException ex) { - Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); - JOptionPane.showMessageDialog(null, "Invalid image.", "Error", JOptionPane.ERROR_MESSAGE); - } - reload(true); - } - } - } - } - if (e.getActionCommand().equals("REMOVEITEM")) { - Object tagObj = tagTree.getLastSelectedPathComponent(); - if (tagObj == null) { - return; - } - - if (tagObj instanceof TagNode) { - tagObj = ((TagNode) tagObj).tag; - } - if (tagObj instanceof DefineSpriteTag) { - DefineSpriteTag sprite = (DefineSpriteTag) tagObj; - for (int i = 0; i < swf.tags.size(); i++) { - Tag t = swf.tags.get(i); - if (t == sprite) { - swf.tags.remove(i); - i--; - } else if (t instanceof DefineSpriteTag) { - DefineSpriteTag st = (DefineSpriteTag) t; - for (int j = 0; j < st.subTags.size(); j++) { - Tag t2 = st.subTags.get(j); - Set needed = t2.getNeededCharacters(); - if (needed.contains(sprite.spriteId)) { - st.subTags.remove(j); - j--; - } - } - } else { - Set needed = t.getNeededCharacters(); - if (needed.contains(sprite.spriteId)) { - swf.tags.remove(i); - i--; + }).start(); } } } - showCard(CARDEMPTYPANEL); - refreshTree(); - } - } - if (e.getActionCommand().equals("EDITTEXT")) { - setEditText(true); - } - if (e.getActionCommand().equals("CANCELTEXT")) { - setEditText(false); - } - if (e.getActionCommand().equals("SAVETEXT")) { - if (oldValue instanceof TextTag) { - try { - ((TextTag) oldValue).setFormattedText(swf.tags, textValue.getText()); - setEditText(false); - } catch (ParseException ex) { - JOptionPane.showMessageDialog(null, "Invalid text: " + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); - } - } - } - - if (e.getActionCommand().equals("AUTODEOBFUSCATE")) { - if (JOptionPane.showConfirmDialog(this, "Automatic deobfuscation is a way to decompile obfuscated code.\r\nDeobfuscation leads to slower decompilation and some of the dead code may be eliminated.\r\nIf the code is not obfuscated, it's better to turn autodeobfuscation off.\r\nDo you really want to " + (autoDeobfuscateMenuItem.getState() ? "turn ON" : "turn OFF") + " automatic debfuscation?", "Confirm", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { - Configuration.setConfig("autoDeobfuscate", autoDeobfuscateMenuItem.getState()); - } else { - autoDeobfuscateMenuItem.setState(!autoDeobfuscateMenuItem.getState()); - } - } - if (e.getActionCommand().equals("EXIT")) { - setVisible(false); - if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) { + break; + case "REPLACEIMAGE": + Object tagObj = tagTree.getLastSelectedPathComponent(); + if (tagObj == null) { return; } - } - Main.exit(); + + if (tagObj instanceof TagNode) { + tagObj = ((TagNode) tagObj).tag; + } + if (tagObj instanceof ImageTag) { + ImageTag it = (ImageTag) tagObj; + if (it.importSupported()) { + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); + fc.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + return (f.getName().toLowerCase().endsWith(".jpg")) + || (f.getName().toLowerCase().endsWith(".jpeg")) + || (f.getName().toLowerCase().endsWith(".gif")) + || (f.getName().toLowerCase().endsWith(".png")) + || (f.isDirectory()); + } + + @Override + public String getDescription() { + return "Images (*.jpg,*.gif,*.png)"; + } + }); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showOpenDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + Configuration.setConfig("lastOpenDir", Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); + File selfile = Helper.fixDialogFile(fc.getSelectedFile()); + byte data[] = Helper.readFile(selfile.getAbsolutePath()); + try { + it.setImage(data); + } catch (IOException ex) { + Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); + JOptionPane.showMessageDialog(null, "Invalid image.", "Error", JOptionPane.ERROR_MESSAGE); + } + reload(true); + } + } + } + break; + case "REMOVEITEM": + tagObj = tagTree.getLastSelectedPathComponent(); + if (tagObj == null) { + return; + } + + if (tagObj instanceof TagNode) { + tagObj = ((TagNode) tagObj).tag; + } + if (tagObj instanceof DefineSpriteTag) { + DefineSpriteTag sprite = (DefineSpriteTag) tagObj; + for (int i = 0; i < swf.tags.size(); i++) { + Tag t = swf.tags.get(i); + if (t == sprite) { + swf.tags.remove(i); + i--; + } else if (t instanceof DefineSpriteTag) { + DefineSpriteTag st = (DefineSpriteTag) t; + for (int j = 0; j < st.subTags.size(); j++) { + Tag t2 = st.subTags.get(j); + Set needed = t2.getNeededCharacters(); + if (needed.contains(sprite.spriteId)) { + st.subTags.remove(j); + j--; + } + } + } else { + Set needed = t.getNeededCharacters(); + if (needed.contains(sprite.spriteId)) { + swf.tags.remove(i); + i--; + } + } + } + showCard(CARDEMPTYPANEL); + refreshTree(); + } + break; + case "EDITTEXT": + setEditText(true); + break; + case "CANCELTEXT": + setEditText(false); + break; + case "SAVETEXT": + if (oldValue instanceof TextTag) { + try { + ((TextTag) oldValue).setFormattedText(swf.tags, textValue.getText()); + setEditText(false); + } catch (ParseException ex) { + JOptionPane.showMessageDialog(null, "Invalid text: " + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); + } + } + break; + + case "AUTODEOBFUSCATE": + if (JOptionPane.showConfirmDialog(this, "Automatic deobfuscation is a way to decompile obfuscated code.\r\nDeobfuscation leads to slower decompilation and some of the dead code may be eliminated.\r\nIf the code is not obfuscated, it's better to turn autodeobfuscation off.\r\nDo you really want to " + (autoDeobfuscateMenuItem.getState() ? "turn ON" : "turn OFF") + " automatic debfuscation?", "Confirm", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + Configuration.setConfig("autoDeobfuscate", autoDeobfuscateMenuItem.getState()); + } else { + autoDeobfuscateMenuItem.setState(!autoDeobfuscateMenuItem.getState()); + } + break; + case "EXIT": + setVisible(false); + if (Main.proxyFrame != null) { + if (Main.proxyFrame.isVisible()) { + return; + } + } + Main.exit(); + break; } if (Main.isWorking()) { return; } - if (e.getActionCommand().equals("ABOUT")) { - Main.about(); - } + switch (e.getActionCommand()) { + case "RENAMEONEIDENTIFIER": + if (swf.fileAttributes.actionScript3) { + final int multiName = abcPanel.decompiledTextArea.getMultinameUnderCursor(); + if (multiName > 0) { + (new Thread() { + @Override + public void run() { + Main.startWork("Renaming..."); + renameMultiname(multiName); + Main.stopWork(); + } + }).start(); - if (e.getActionCommand().equals("SHOWPROXY")) { - Main.showProxy(); - } - - if (e.getActionCommand().equals("SUBLIMITER")) { - if (e.getSource() instanceof JCheckBoxMenuItem) { - Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState()); - } - - } - - if (e.getActionCommand().equals("SAVE")) { - try { - Main.saveFile(Main.file); - } catch (IOException ex) { - Logger.getLogger(com.jpexs.decompiler.flash.abc.gui.ABCPanel.class.getName()).log(Level.SEVERE, null, ex); - JOptionPane.showMessageDialog(null, "Cannot save file", "Error", JOptionPane.ERROR_MESSAGE); - } - } - if (e.getActionCommand().equals("SAVEAS")) { - if (Main.saveFileDialog()) { - setTitle(Main.applicationVerName + (Configuration.DISPLAY_FILENAME ? " - " + Main.getFileTitle() : "")); - } - } - if (e.getActionCommand().equals("OPEN")) { - Main.openFileDialog(); - - } - if (e.getActionCommand().equals("EXPORTFLA")) { - JFileChooser fc = new JFileChooser(); - String selDir = (String) Configuration.getConfig("lastOpenDir", "."); - fc.setCurrentDirectory(new File(selDir)); - if (!selDir.endsWith(File.separator)) { - selDir += File.separator; - } - String fileName = (new File(Main.file).getName()); - fileName = fileName.substring(0, fileName.length() - 4) + ".fla"; - fc.setSelectedFile(new File(selDir + fileName)); - FileFilter fla = new FileFilter() { - @Override - public boolean accept(File f) { - return f.isDirectory() || (f.getName().toLowerCase().endsWith(".fla")); - } - - @Override - public String getDescription() { - return "Flash CS 6 Document (*.fla)"; - } - }; - FileFilter xfl = new FileFilter() { - @Override - public boolean accept(File f) { - return f.isDirectory() || (f.getName().toLowerCase().endsWith(".xfl")); - } - - @Override - public String getDescription() { - return "Flash CS 6 Uncompressed Document (*.xfl)"; - } - }; - fc.setFileFilter(fla); - fc.addChoosableFileFilter(xfl); - fc.setAcceptAllFileFilterUsed(false); - JFrame f = new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showSaveDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - Configuration.setConfig("lastOpenDir", Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); - final File selfile = Helper.fixDialogFile(fc.getSelectedFile()); - Main.startWork("Exporting FLA..."); - final boolean compressed = fc.getFileFilter() == fla; - (new Thread() { - @Override - public void run() { - if (compressed) { - swf.exportFla(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); - } else { - swf.exportXfl(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); - } - Main.stopWork(); + } else { + JOptionPane.showMessageDialog(null, "No Multiname found under cursor", "Not found", JOptionPane.INFORMATION_MESSAGE); } - }).start(); - } - } else if (e.getActionCommand().startsWith("EXPORT")) { - final ExportDialog export = new ExportDialog(); - export.setVisible(true); - if (!export.cancelled) { - JFileChooser chooser = new JFileChooser(); - chooser.setCurrentDirectory(new java.io.File((String) Configuration.getConfig("lastExportDir", "."))); - chooser.setDialogTitle("Select directory to export"); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setAcceptAllFileFilterUsed(false); - if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - final long timeBefore = System.currentTimeMillis(); - Main.startWork("Exporting..."); - final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath(); - Configuration.setConfig("lastExportDir", Helper.fixDialogFile(chooser.getSelectedFile()).getParentFile().getAbsolutePath()); - final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1; - final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; - final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; - final boolean onlySel = e.getActionCommand().endsWith("SEL"); + } else { + final String identifier = actionPanel.getStringUnderCursor(); + if (identifier != null) { + (new Thread() { + public void run() { + Main.startWork("Renaming..."); + renameIdentifier(identifier); + Main.stopWork(); + } + }).start(); + } else { + JOptionPane.showMessageDialog(null, "No identifier found under cursor", "Not found", JOptionPane.INFORMATION_MESSAGE); + } + } + break; + case "ABOUT": + Main.about(); + break; + + case "SHOWPROXY": + Main.showProxy(); + break; + + case "SUBLIMITER": + if (e.getSource() instanceof JCheckBoxMenuItem) { + Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState()); + } + + break; + + case "SAVE": + try { + Main.saveFile(Main.file); + } catch (IOException ex) { + Logger.getLogger(com.jpexs.decompiler.flash.abc.gui.ABCPanel.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, "Cannot save file", "Error", JOptionPane.ERROR_MESSAGE); + } + break; + case "SAVEAS": + if (Main.saveFileDialog()) { + setTitle(Main.applicationVerName + (Configuration.DISPLAY_FILENAME ? " - " + Main.getFileTitle() : "")); + } + break; + case "OPEN": + Main.openFileDialog(); + break; + case "EXPORTFLA": + JFileChooser fc = new JFileChooser(); + String selDir = (String) Configuration.getConfig("lastOpenDir", "."); + fc.setCurrentDirectory(new File(selDir)); + if (!selDir.endsWith(File.separator)) { + selDir += File.separator; + } + String fileName = (new File(Main.file).getName()); + fileName = fileName.substring(0, fileName.length() - 4) + ".fla"; + fc.setSelectedFile(new File(selDir + fileName)); + FileFilter fla = new FileFilter() { + @Override + public boolean accept(File f) { + return f.isDirectory() || (f.getName().toLowerCase().endsWith(".fla")); + } + + @Override + public String getDescription() { + return "Flash CS 6 Document (*.fla)"; + } + }; + FileFilter xfl = new FileFilter() { + @Override + public boolean accept(File f) { + return f.isDirectory() || (f.getName().toLowerCase().endsWith(".xfl")); + } + + @Override + public String getDescription() { + return "Flash CS 6 Uncompressed Document (*.xfl)"; + } + }; + fc.setFileFilter(fla); + fc.addChoosableFileFilter(xfl); + fc.setAcceptAllFileFilterUsed(false); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showSaveDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + Configuration.setConfig("lastOpenDir", Helper.fixDialogFile(fc.getSelectedFile()).getParentFile().getAbsolutePath()); + final File selfile = Helper.fixDialogFile(fc.getSelectedFile()); + Main.startWork("Exporting FLA..."); + final boolean compressed = fc.getFileFilter() == fla; (new Thread() { @Override public void run() { - try { - if (onlySel) { - List sel = getAllSelected(tagTree); - - List tlsList = new ArrayList<>(); - JPEGTablesTag jtt = null; - for (Tag t : swf.tags) { - if (t instanceof JPEGTablesTag) { - jtt = (JPEGTablesTag) t; - break; - } - } - List images = new ArrayList<>(); - List shapes = new ArrayList<>(); - List movies = new ArrayList<>(); - List sounds = new ArrayList<>(); - List texts = new ArrayList<>(); - List actionNodes = new ArrayList<>(); - List binaryData = new ArrayList<>(); - for (Object d : sel) { - if (d instanceof TagNode) { - TagNode n = (TagNode) d; - if ("image".equals(getTagType(n.tag))) { - images.add((Tag) n.tag); - } - if ("shape".equals(getTagType(n.tag))) { - shapes.add((Tag) n.tag); - } - if ("as".equals(getTagType(n.tag))) { - actionNodes.add(n); - } - if ("movie".equals(getTagType(n.tag))) { - movies.add((Tag) n.tag); - } - if ("sound".equals(getTagType(n.tag))) { - sounds.add((Tag) n.tag); - } - if ("binaryData".equals(getTagType(n.tag))) { - binaryData.add((Tag) n.tag); - } - if ("text".equals(getTagType(n.tag))) { - texts.add((Tag) n.tag); - } - } - if (d instanceof TreeElement) { - if (((TreeElement) d).isLeaf()) { - tlsList.add((ScriptPack) ((TreeElement) d).getItem()); - } - } - } - swf.exportImages(selFile + File.separator + "images", images); - SWF.exportShapes(selFile + File.separator + "shapes", shapes); - swf.exportTexts(selFile + File.separator + "texts", texts, isFormatted); - swf.exportMovies(selFile + File.separator + "movies", movies); - swf.exportSounds(selFile + File.separator + "sounds", sounds, isMp3OrWav, isMp3OrWav); - swf.exportBinaryData(selFile + File.separator + "binaryData", binaryData); - if (abcPanel != null) { - for (int i = 0; i < tlsList.size(); i++) { - ScriptPack tls = tlsList.get(i); - Main.startWork("Exporting " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ..."); - tls.export(selFile, abcList, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); - } - } else { - List allNodes = new ArrayList<>(); - TagNode asn = getASTagNode(tagTree); - if (asn != null) { - allNodes.add(asn); - TagNode.setExport(allNodes, false); - TagNode.setExport(actionNodes, true); - TagNode.exportNodeAS(allNodes, selFile, isPcode); - } - } - } else { - swf.exportImages(selFile + File.separator + "images"); - swf.exportShapes(selFile + File.separator + "shapes"); - swf.exportTexts(selFile + File.separator + "texts", isFormatted); - swf.exportMovies(selFile + File.separator + "movies"); - swf.exportSounds(selFile + File.separator + "sounds", isMp3OrWav, isMp3OrWav); - swf.exportBinaryData(selFile + File.separator + "binaryData"); - swf.exportActionScript(selFile, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); - } - } catch (Exception ex) { - Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error during export", ex); - JOptionPane.showMessageDialog(null, "Error during export"); + if (compressed) { + swf.exportFla(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); + } else { + swf.exportXfl(selfile.getAbsolutePath(), new File(Main.file).getName(), Main.applicationName, Main.applicationVerName, Main.version, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); } Main.stopWork(); - long timeAfter = System.currentTimeMillis(); - long timeMs = timeAfter - timeBefore; - long timeS = timeMs / 1000; - timeMs = timeMs % 1000; - long timeM = timeS / 60; - timeS = timeS % 60; - long timeH = timeM / 60; - timeM = timeM % 60; - String timeStr = ""; - if (timeH > 0) { - timeStr += Helper.padZeros(timeH, 2) + ":"; - } - timeStr += Helper.padZeros(timeM, 2) + ":"; - timeStr += Helper.padZeros(timeS, 2) + "." + Helper.padZeros(timeMs, 3); - setStatus("Exported in " + timeStr); } }).start(); - } - } - } + break; + case "EXPORT": + final ExportDialog export = new ExportDialog(); + export.setVisible(true); + if (!export.cancelled) { + JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new java.io.File((String) Configuration.getConfig("lastExportDir", "."))); + chooser.setDialogTitle("Select directory to export"); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setAcceptAllFileFilterUsed(false); + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + final long timeBefore = System.currentTimeMillis(); + Main.startWork("Exporting..."); + final String selFile = Helper.fixDialogFile(chooser.getSelectedFile()).getAbsolutePath(); + Configuration.setConfig("lastExportDir", Helper.fixDialogFile(chooser.getSelectedFile()).getParentFile().getAbsolutePath()); + final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1; + final boolean isMp3OrWav = export.getOption(ExportDialog.OPTION_SOUNDS) == 0; + final boolean isFormatted = export.getOption(ExportDialog.OPTION_TEXTS) == 1; + final boolean onlySel = e.getActionCommand().endsWith("SEL"); + (new Thread() { + @Override + public void run() { + try { + if (onlySel) { + List sel = getAllSelected(tagTree); - if (e.getActionCommand().equals("CHECKUPDATES")) { - if (!Main.checkForUpdates()) { - JOptionPane.showMessageDialog(null, "No new version available."); - } - } + List tlsList = new ArrayList<>(); + JPEGTablesTag jtt = null; + for (Tag t : swf.tags) { + if (t instanceof JPEGTablesTag) { + jtt = (JPEGTablesTag) t; + break; + } + } + List images = new ArrayList<>(); + List shapes = new ArrayList<>(); + List movies = new ArrayList<>(); + List sounds = new ArrayList<>(); + List texts = new ArrayList<>(); + List actionNodes = new ArrayList<>(); + List binaryData = new ArrayList<>(); + for (Object d : sel) { + if (d instanceof TagNode) { + TagNode n = (TagNode) d; + if ("image".equals(getTagType(n.tag))) { + images.add((Tag) n.tag); + } + if ("shape".equals(getTagType(n.tag))) { + shapes.add((Tag) n.tag); + } + if ("as".equals(getTagType(n.tag))) { + actionNodes.add(n); + } + if ("movie".equals(getTagType(n.tag))) { + movies.add((Tag) n.tag); + } + if ("sound".equals(getTagType(n.tag))) { + sounds.add((Tag) n.tag); + } + if ("binaryData".equals(getTagType(n.tag))) { + binaryData.add((Tag) n.tag); + } + if ("text".equals(getTagType(n.tag))) { + texts.add((Tag) n.tag); + } + } + if (d instanceof TreeElement) { + if (((TreeElement) d).isLeaf()) { + tlsList.add((ScriptPack) ((TreeElement) d).getItem()); + } + } + } + swf.exportImages(selFile + File.separator + "images", images); + SWF.exportShapes(selFile + File.separator + "shapes", shapes); + swf.exportTexts(selFile + File.separator + "texts", texts, isFormatted); + swf.exportMovies(selFile + File.separator + "movies", movies); + swf.exportSounds(selFile + File.separator + "sounds", sounds, isMp3OrWav, isMp3OrWav); + swf.exportBinaryData(selFile + File.separator + "binaryData", binaryData); + if (abcPanel != null) { + for (int i = 0; i < tlsList.size(); i++) { + ScriptPack tls = tlsList.get(i); + Main.startWork("Exporting " + (i + 1) + "/" + tlsList.size() + " " + tls.getPath() + " ..."); + tls.export(selFile, abcList, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); + } + } else { + List allNodes = new ArrayList<>(); + TagNode asn = getASTagNode(tagTree); + if (asn != null) { + allNodes.add(asn); + TagNode.setExport(allNodes, false); + TagNode.setExport(actionNodes, true); + TagNode.exportNodeAS(allNodes, selFile, isPcode); + } + } + } else { + swf.exportImages(selFile + File.separator + "images"); + swf.exportShapes(selFile + File.separator + "shapes"); + swf.exportTexts(selFile + File.separator + "texts", isFormatted); + swf.exportMovies(selFile + File.separator + "movies"); + swf.exportSounds(selFile + File.separator + "sounds", isMp3OrWav, isMp3OrWav); + swf.exportBinaryData(selFile + File.separator + "binaryData"); + swf.exportActionScript(selFile, isPcode, (Boolean) Configuration.getConfig("paralelSpeedUp", Boolean.TRUE)); + } + } catch (Exception ex) { + Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Error during export", ex); + JOptionPane.showMessageDialog(null, "Error during export"); + } + Main.stopWork(); + long timeAfter = System.currentTimeMillis(); + long timeMs = timeAfter - timeBefore; + long timeS = timeMs / 1000; + timeMs = timeMs % 1000; + long timeM = timeS / 60; + timeS = timeS % 60; + long timeH = timeM / 60; + timeM = timeM % 60; + String timeStr = ""; + if (timeH > 0) { + timeStr += Helper.padZeros(timeH, 2) + ":"; + } + timeStr += Helper.padZeros(timeM, 2) + ":"; + timeStr += Helper.padZeros(timeS, 2) + "." + Helper.padZeros(timeMs, 3); + setStatus("Exported in " + timeStr); + } + }).start(); - if (e.getActionCommand().equals("HELPUS")) { - String helpUsURL = Main.projectPage + "/help_us.html"; - if (java.awt.Desktop.isDesktopSupported()) { - java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); - try { - java.net.URI uri = new java.net.URI(helpUsURL); - desktop.browse(uri); - } catch (Exception ex) { + } } - } else { - JOptionPane.showMessageDialog(null, "Please visit\r\n" + helpUsURL + "\r\nfor details."); - } - } + break; - if (e.getActionCommand().equals("HOMEPAGE")) { - String homePageURL = Main.projectPage; - if (java.awt.Desktop.isDesktopSupported()) { - java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); - try { - java.net.URI uri = new java.net.URI(homePageURL); - desktop.browse(uri); - } catch (Exception ex) { + case "CHECKUPDATES": + if (!Main.checkForUpdates()) { + JOptionPane.showMessageDialog(null, "No new version available."); } - } else { - JOptionPane.showMessageDialog(null, "Visit homepage at: \r\n" + homePageURL); - } - } + break; - if (e.getActionCommand().startsWith("RESTORECONTROLFLOW")) { - Main.startWork("Restoring control flow..."); - final boolean all = e.getActionCommand().endsWith("ALL"); - if ((!all) || confirmExperimental()) { - new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - int cnt = 0; - if (all) { - for (ABCContainerTag tag : abcPanel.list) { - tag.getABC().restoreControlFlow(); - } - } else { - int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); - if (bi != -1) { - abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); - } - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); - } - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Control flow restored"); - abcPanel.reload(); - return true; + case "HELPUS": + String helpUsURL = Main.projectPage + "/help_us.html"; + if (java.awt.Desktop.isDesktopSupported()) { + java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); + try { + java.net.URI uri = new java.net.URI(helpUsURL); + desktop.browse(uri); + } catch (Exception ex) { } - }.execute(); - } - } + } else { + JOptionPane.showMessageDialog(null, "Please visit\r\n" + helpUsURL + "\r\nfor details."); + } + break; - if (e.getActionCommand().startsWith("REMOVETRAPS")) { - Main.startWork("Removing traps..."); - final boolean all = e.getActionCommand().endsWith("ALL"); - if ((!all) || confirmExperimental()) { - new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - int cnt = 0; - if (all) { - for (ABCContainerTag tag : abcPanel.list) { - cnt += tag.getABC().removeTraps(); - } - } else { - int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); - if (bi != -1) { - cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); - } - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); - } - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Traps removed: " + cnt); - abcPanel.reload(); - return true; + case "HOMEPAGE": + String homePageURL = Main.projectPage; + if (java.awt.Desktop.isDesktopSupported()) { + java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); + try { + java.net.URI uri = new java.net.URI(homePageURL); + desktop.browse(uri); + } catch (Exception ex) { } - }.execute(); - } - } + } else { + JOptionPane.showMessageDialog(null, "Visit homepage at: \r\n" + homePageURL); + } + break; - if (e.getActionCommand().startsWith("REMOVEDEADCODE")) { - Main.startWork("Removing dead code..."); - final boolean all = e.getActionCommand().endsWith("ALL"); - if ((!all) || confirmExperimental()) { - new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - int cnt = 0; - if (all) { - for (ABCContainerTag tag : abcPanel.list) { - cnt += tag.getABC().removeDeadCode(); - } - } else { - int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); - if (bi != -1) { - cnt += abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); - } - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); - } - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Instructions removed: " + cnt); - abcPanel.reload(); - return true; - } - }.execute(); - } - } - - if (e.getActionCommand().equals("RENAMEIDENTIFIERS")) { - if (confirmExperimental()) { - final RenameType renameType = new RenameDialog().display(); - if (renameType != null) { - Main.startWork("Renaming identifiers..."); + case "RESTORECONTROLFLOW": + case "RESTORECONTROLFLOWALL": + Main.startWork("Restoring control flow..."); + final boolean all = e.getActionCommand().endsWith("ALL"); + if ((!all) || confirmExperimental()) { new SwingWorker() { @Override protected Object doInBackground() throws Exception { - try { - int cnt = 0; - cnt = swf.deobfuscateIdentifiers(renameType); - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); - if (abcPanel != null) { - abcPanel.reload(); - } - doFilter(); - reload(true); - } catch (Exception ex) { - Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); - } - return true; - } - }.execute(); - - } - } - } - - if (e.getActionCommand().startsWith("DEOBFUSCATE")) { - if (deobfuscationDialog == null) { - deobfuscationDialog = new DeobfuscationDialog(); - } - deobfuscationDialog.setVisible(true); - if (deobfuscationDialog.ok) { - Main.startWork("Deobfuscating..."); - new SwingWorker() { - @Override - protected Object doInBackground() throws Exception { - try { - if (deobfuscationDialog.processAllCheckbox.isSelected()) { + int cnt = 0; + if (all) { for (ABCContainerTag tag : abcPanel.list) { - if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { - tag.getABC().removeDeadCode(); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { - tag.getABC().removeTraps(); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { - tag.getABC().removeTraps(); - tag.getABC().restoreControlFlow(); - } + tag.getABC().restoreControlFlow(); } } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); if (bi != -1) { - if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { - abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); - } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { - abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); - abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); - } + abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); } abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); } - } catch (Exception ex) { - Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Deobfuscation error", ex); + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Control flow restored"); + abcPanel.reload(); + return true; } - Main.stopWork(); - JOptionPane.showMessageDialog(null, "Deobfuscation complete"); - abcPanel.reload(); - return true; + }.execute(); + } + break; + case "RENAMEIDENTIFIERS": + if (confirmExperimental()) { + final RenameType renameType = new RenameDialog().display(); + if (renameType != null) { + Main.startWork("Renaming identifiers..."); + new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + try { + int cnt = 0; + cnt = swf.deobfuscateIdentifiers(renameType); + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Identifiers renamed: " + cnt); + if (abcPanel != null) { + abcPanel.reload(); + } + doFilter(); + reload(true); + } catch (Exception ex) { + Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "message", ex); + } + return true; + } + }.execute(); + } - }.execute(); - } + } + break; + case "DEOBFUSCATE": + case "DEOBFUSCATEALL": + if (deobfuscationDialog == null) { + deobfuscationDialog = new DeobfuscationDialog(); + } + deobfuscationDialog.setVisible(true); + if (deobfuscationDialog.ok) { + Main.startWork("Deobfuscating..."); + new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + try { + if (deobfuscationDialog.processAllCheckbox.isSelected()) { + for (ABCContainerTag tag : abcPanel.list) { + if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { + tag.getABC().removeDeadCode(); + } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { + tag.getABC().removeTraps(); + } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { + tag.getABC().removeTraps(); + tag.getABC().restoreControlFlow(); + } + } + } else { + int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); + if (bi != -1) { + if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { + abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); + } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); + } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { + abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); + abcPanel.abc.bodies[bi].restoreControlFlow(abcPanel.abc.constants); + } + } + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); + } + } catch (Exception ex) { + Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Deobfuscation error", ex); + } + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Deobfuscation complete"); + abcPanel.reload(); + return true; + } + }.execute(); + } + break; + + case "REMOVETRAPS": + case "REMOVETRAPSALL": + Main.startWork("Removing traps..."); + final boolean rall = e.getActionCommand().endsWith("ALL"); + if ((!rall) || confirmExperimental()) { + new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + int cnt = 0; + if (rall) { + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().removeTraps(); + } + } else { + int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); + if (bi != -1) { + cnt += abcPanel.abc.bodies[bi].removeTraps(abcPanel.abc.constants, abcPanel.abc, abcPanel.decompiledTextArea.getScriptLeaf().scriptIndex, abcPanel.decompiledTextArea.getClassIndex(), abcPanel.decompiledTextArea.getIsStatic()); + } + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); + } + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Traps removed: " + cnt); + abcPanel.reload(); + return true; + } + }.execute(); + } + break; + + case "REMOVEDEADCODE": + case "REMOVEDEADCODEALL": + Main.startWork("Removing dead code..."); + final boolean dall = e.getActionCommand().endsWith("ALL"); + if ((!dall) || confirmExperimental()) { + new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + int cnt = 0; + if (dall) { + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().removeDeadCode(); + } + } else { + int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); + if (bi != -1) { + cnt += abcPanel.abc.bodies[bi].removeDeadCode(abcPanel.abc.constants); + } + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc); + } + Main.stopWork(); + JOptionPane.showMessageDialog(null, "Instructions removed: " + cnt); + abcPanel.reload(); + return true; + } + }.execute(); + } + break; + } + + + + } private int splitPos = 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/RenameDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/RenameDialog.java index 1b73dbd5b..99a1a8186 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/RenameDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/RenameDialog.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui; +import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.abc.RenameType; import java.awt.BorderLayout; import java.awt.FlowLayout; @@ -25,6 +26,7 @@ import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JDialog; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -53,6 +55,7 @@ public class RenameDialog extends JDialog implements ActionListener { public RenameDialog() { setSize(300, 150); setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + int renameType = (Integer) Configuration.getConfig("lastRenameType", (Integer) 1); ButtonGroup group = new ButtonGroup(); group.add(typeNumberRadioButton); group.add(randomWordRadioButton); @@ -60,8 +63,10 @@ public class RenameDialog extends JDialog implements ActionListener { pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS)); pan.add(typeNumberRadioButton); pan.add(randomWordRadioButton); - typeNumberRadioButton.setSelected(true); + typeNumberRadioButton.setSelected(renameType == 1); + randomWordRadioButton.setSelected(renameType == 2); setLayout(new BorderLayout()); + add(new JLabel("Rename type:"), BorderLayout.NORTH); add(pan, BorderLayout.CENTER); JPanel panButtons = new JPanel(new FlowLayout()); panButtons.add(okButton); @@ -91,6 +96,7 @@ public class RenameDialog extends JDialog implements ActionListener { switch (e.getActionCommand()) { case "OK": confirmed = true; + Configuration.setConfig("lastRenameType", (Integer) (getRenameType() == RenameType.TYPENUMBER ? 1 : 2)); setVisible(false); break; case "CANCEL": diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 12b23bc51..f8f55104b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -255,12 +255,10 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT @Override public String getExportFileName() { - String expName=getExportName(); - if((expName==null) || expName.equals("")){ + String expName = getExportName(); + if ((expName == null) || expName.equals("")) { return super.getExportFileName(); } - return Helper.makeFileName(super.getExportFileName()+"_"+expName); + 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 ed2e44447..244659de6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -165,35 +165,31 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { @Override public String getExportFileName() { - String expName=getExportName(); - if((expName==null) || expName.equals("")){ + String expName = getExportName(); + if ((expName == null) || expName.equals("")) { return super.toString(); } String pathParts[]; - if(expName.contains(".")){ + if (expName.contains(".")) { pathParts = expName.split("\\."); - }else{ + } else { pathParts = new String[]{expName}; } - return Helper.makeFileName(pathParts[pathParts.length-1]); + return Helper.makeFileName(pathParts[pathParts.length - 1]); } - - @Override public String toString() { - String expName=getExportName(); - if((expName==null) || expName.equals("")){ + String expName = getExportName(); + if ((expName == null) || expName.equals("")) { return super.toString(); } String pathParts[]; - if(expName.contains(".")){ + if (expName.contains(".")) { pathParts = expName.split("\\."); - }else{ + } else { pathParts = new String[]{expName}; } - return pathParts[pathParts.length-1]; + return pathParts[pathParts.length - 1]; } - - } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java index 91afe742c..f552a7951 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterIdTag.java @@ -26,10 +26,11 @@ 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 @@ -38,10 +39,10 @@ public abstract class CharacterIdTag extends Tag { private String className; private String exportName; - public void setExportName(String exportName){ + public void setExportName(String exportName) { this.exportName = exportName; } - + public void setClassName(String className) { this.className = className; } @@ -64,16 +65,14 @@ public abstract class CharacterIdTag extends Tag { @Override public String getExportFileName() { - return super.getName() + "_" + getCharacterID()+(((exportName!=null) && (!exportName.equals("")))?"_"+exportName:""); + return super.getName() + "_" + getCharacterID() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : ""); } - + public String getCharacterExportFileName() { - return getCharacterID()+(((exportName!=null) && (!exportName.equals("")))?"_"+exportName:""); + return getCharacterID() + (((exportName != null) && (!exportName.equals(""))) ? "_" + exportName : ""); } 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 9a5df7055..ede4bbe1c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/CharacterTag.java @@ -30,6 +30,4 @@ public abstract class CharacterTag extends CharacterIdTag { public CharacterTag(int id, String name, byte[] data, long pos) { super(id, name, data, pos); } - - }