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 5ff5d6bdd..34d4d53ba 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -855,8 +855,8 @@ public final class SWF implements TreeItem, Timelined { List> ret = new ArrayList<>(); for (MyEntry item : packs) { for (MyEntry itemOld : ret) { - if (item.key.equals(itemOld.key)) { - logger.log(Level.SEVERE, "Duplicate pack path found (" + itemOld.key + ")!"); + if (item.getKey().equals(itemOld.getKey())) { + logger.log(Level.SEVERE, "Duplicate pack path found (" + itemOld.getKey() + ")!"); break; } } @@ -968,7 +968,7 @@ public final class SWF implements TreeItem, Timelined { @Override public Void call() throws Exception { for (MyEntry item : packs) { - ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel); + ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.getKey(), item.getValue(), outdir, abcTags, exportMode, parallel); ret.add(task.call()); } return null; @@ -983,7 +983,7 @@ public final class SWF implements TreeItem, Timelined { ExecutorService executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get()); List> futureResults = new ArrayList<>(); for (MyEntry item : packs) { - Future future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel)); + Future future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.getKey(), item.getValue(), outdir, abcTags, exportMode, parallel)); futureResults.add(future); } @@ -1970,7 +1970,7 @@ public final class SWF implements TreeItem, Timelined { informListeners("rename", ""); int fc = 0; for (MyEntry it : allVariableNames) { - String name = it.key.toStringNoH(it.value); + String name = it.getKey().toStringNoH(it.getValue()); deobfuscation.allVariableNamesStr.add(name); } @@ -2029,10 +2029,10 @@ public final class SWF implements TreeItem, Timelined { List vars = new ArrayList<>(); for (MyEntry item : cti.vars) { - vars.add(item.key); + vars.add(item.getKey()); } for (MyEntry item : cti.staticVars) { - vars.add(item.key); + vars.add(item.getKey()); } for (GraphTargetItem gti : vars) { if (gti instanceof DirectValueActionItem) { @@ -2139,7 +2139,7 @@ public final class SWF implements TreeItem, Timelined { HashSet stringsNoVarH = new HashSet<>(); List allVariableNamesDv = new ArrayList<>(); for (MyEntry it : allVariableNames) { - allVariableNamesDv.add(it.key); + allVariableNamesDv.add(it.getKey()); } for (DirectValueActionItem ti : allStrings.keySet()) { if (!allVariableNamesDv.contains(ti)) { @@ -2150,22 +2150,22 @@ public final class SWF implements TreeItem, Timelined { int vc = 0; for (MyEntry it : allVariableNames) { vc++; - String name = it.key.toStringNoH(it.value); - String changed = deobfuscation.deobfuscateName(name, false, usageTypes.get(it.key), deobfuscated, renameType, selected); + String name = it.getKey().toStringNoH(it.getValue()); + String changed = deobfuscation.deobfuscateName(name, false, usageTypes.get(it.getKey()), deobfuscated, renameType, selected); if (changed != null) { boolean addNew = false; - String h = System.identityHashCode(it.key) + "_" + name; + String h = System.identityHashCode(it.getKey()) + "_" + name; if (stringsNoVarH.contains(h)) { addNew = true; } - ActionPush pu = (ActionPush) it.key.src; + ActionPush pu = (ActionPush) it.getKey().src; if (pu.replacement == null) { pu.replacement = new ArrayList<>(); pu.replacement.addAll(pu.values); } - if (pu.replacement.get(it.key.pos) instanceof ConstantIndex) { - ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.key.pos); - ConstantPool pool = it.value; + if (pu.replacement.get(it.getKey().pos) instanceof ConstantIndex) { + ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.getKey().pos); + ConstantPool pool = it.getValue(); if (pool == null) { continue; } @@ -2179,7 +2179,7 @@ public final class SWF implements TreeItem, Timelined { pool.constants.set(ci.index, changed); } } else { - pu.replacement.set(it.key.pos, changed); + pu.replacement.set(it.getKey().pos, changed); } ret++; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 42bb2bcf4..e77b59641 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.executing.CallPropertyIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushStringIns; +import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.ActionScriptParser; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.ClassInfo; import com.jpexs.decompiler.flash.abc.types.InstanceInfo; @@ -56,6 +58,9 @@ import com.jpexs.decompiler.flash.abc.usages.TypeNameMultinameUsage; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.SymbolClassTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.helpers.MemoryInputStream; import com.jpexs.helpers.utf8.Utf8PrintWriter; import java.io.IOException; @@ -1004,17 +1009,17 @@ public class ABC { name = name.substring(0, name.length() - 2); for (MyEntry en : allPacks) { - if (en.key.toString().startsWith(name)) { - ret.add(en.value); + if (en.getKey().toString().startsWith(name)) { + ret.add(en.getValue()); } } } else if (name.endsWith(".*") || name.equals("*") || name.endsWith(".+") || name.equals("+")) { name = name.substring(0, name.length() - 1); for (MyEntry en : allPacks) { - if (en.key.toString().startsWith(name)) { - String rem = name.isEmpty() ? en.key.toString() : en.key.toString().substring(name.length()); + if (en.getKey().toString().startsWith(name)) { + String rem = name.isEmpty() ? en.getKey().toString() : en.getKey().toString().substring(name.length()); if (!rem.contains(".")) { - ret.add(en.value); + ret.add(en.getValue()); } } } @@ -1031,8 +1036,8 @@ public class ABC { public ScriptPack findScriptPackByPath(String name) { List> packs = getScriptPacks(); for (MyEntry en : packs) { - if (en.key.toString().equals(name)) { - return en.value; + if (en.getKey().toString().equals(name)) { + return en.getValue(); } } return null; @@ -1148,6 +1153,34 @@ public class ABC { method_info.remove(index); } + public void replaceSciptPack(ScriptPack pack, String as) throws ParseException, CompilationException, IOException, InterruptedException { + String scriptName = pack.getPathScriptName() + ".as"; + int oldIndex = pack.scriptIndex; + int newIndex = script_info.size(); + String documentClass = ""; + loopt: + for (Tag t : swf.tags) { + if (t instanceof SymbolClassTag) { + SymbolClassTag sc = (SymbolClassTag) t; + for (int i = 0; i < sc.tags.length; i++) { + if (sc.tags[i] == 0) { + documentClass = sc.names[i]; + break loopt; + } + } + } + } + boolean isDocumentClass = documentClass.equals(pack.getPath().toString()); + + script_info.get(oldIndex).delete(this, true); + ActionScriptParser.compile(as, this, new ArrayList(), isDocumentClass, scriptName); + //Move newly added script to its position + script_info.set(oldIndex, script_info.get(newIndex)); + script_info.remove(newIndex); + pack(); //removes old classes/methods + ((Tag) parentTag).setModified(true); + } + public void pack() { for (int c = 0; c < instance_info.size(); c++) { if (instance_info.get(c).deleted) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java index 9bb32a22d..aab3e32a8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.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.action.model.clauses; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -91,7 +92,7 @@ public class ClassActionItem extends ActionItem implements Block { } uninitializedVars.addAll(allMembers); for (MyEntry v : vars) { - String s = v.key.toStringNoQuotes(LocalData.empty); + String s = v.getKey().toStringNoQuotes(LocalData.empty); if (uninitializedVars.contains(s)) { uninitializedVars.remove(s); } @@ -169,9 +170,9 @@ public class ClassActionItem extends ActionItem implements Block { for (MyEntry item : vars) { writer.append("var "); - item.key.toStringNoQuotes(writer, localData); + item.getKey().toStringNoQuotes(writer, localData); writer.append(" = "); - item.value.toString(writer, localData); + item.getValue().toString(writer, localData); writer.append(";").newLine(); } for (String v : uninitializedVars) { @@ -181,9 +182,9 @@ public class ClassActionItem extends ActionItem implements Block { } for (MyEntry item : staticVars) { writer.append("static var "); - item.key.toStringNoQuotes(writer, localData); + item.getKey().toStringNoQuotes(writer, localData); writer.append(" = "); - item.value.toString(writer, localData); + item.getValue().toString(writer, localData); writer.append(";").newLine(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index 3b3ffe933..512c2256f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.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.action.parser.script; import com.jpexs.decompiler.flash.SWF; @@ -690,14 +691,14 @@ public class ActionSourceGenerator implements SourceGenerator { } for (MyEntry en : staticVars) { ifbody.add(new ActionPush(new RegisterNumber(1/*static*/))); - ifbody.add(new ActionPush(getName(en.key))); - ifbody.addAll(toActionList(en.value.toSource(localData, this))); + ifbody.add(new ActionPush(getName(en.getKey()))); + ifbody.addAll(toActionList(en.getValue().toSource(localData, this))); ifbody.add(new ActionSetMember()); } for (MyEntry en : vars) { ifbody.add(new ActionPush(new RegisterNumber(2/*instance*/))); - ifbody.add(new ActionPush(getName(en.key))); - ifbody.addAll(toActionList(en.value.toSource(localData, this))); + ifbody.add(new ActionPush(getName(en.getKey()))); + ifbody.addAll(toActionList(en.getValue().toSource(localData, this))); ifbody.add(new ActionSetMember()); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java index 5d344fde1..3991e5db1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.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.helpers.collections; import java.util.Map.Entry; @@ -26,8 +27,8 @@ import java.util.Objects; */ public class MyEntry implements Entry { - public K key; - public V value; + private final K key; + private V value; public MyEntry(K key, V value) { this.key = key; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyMap.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyMap.java index e046c84ec..2e6ddcdb6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyMap.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyMap.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.helpers.collections; import java.util.ArrayList; @@ -44,7 +45,7 @@ public class MyMap implements Map { @Override public boolean containsKey(Object key) { for (MyEntry kv : values) { - if (kv.key.equals(key)) { + if (kv.getKey().equals(key)) { return true; } } @@ -54,7 +55,7 @@ public class MyMap implements Map { @Override public boolean containsValue(Object value) { for (MyEntry kv : values) { - if (kv.value.equals(value)) { + if (kv.getValue().equals(value)) { return true; } } @@ -64,8 +65,8 @@ public class MyMap implements Map { @Override public V get(Object key) { for (MyEntry kv : values) { - if (kv.key.equals(key)) { - return kv.value; + if (kv.getKey().equals(key)) { + return kv.getValue(); } } return null; @@ -74,8 +75,8 @@ public class MyMap implements Map { @Override public V put(K key, V value) { for (MyEntry kv : values) { - if (kv.key.equals(key)) { - kv.value = value; + if (kv.getKey().equals(key)) { + kv.setValue(value); return value; } } @@ -87,9 +88,9 @@ public class MyMap implements Map { public V remove(Object key) { for (int i = 0; i < values.size(); i++) { MyEntry kv = values.get(i); - if (kv.key.equals(key)) { + if (kv.getKey().equals(key)) { values.remove(i); - return kv.value; + return kv.getValue(); } } return null; @@ -111,7 +112,7 @@ public class MyMap implements Map { public Set keySet() { Set ret = new MySet<>(); for (MyEntry kv : values) { - ret.add(kv.key); + ret.add(kv.getKey()); } return ret; } @@ -120,7 +121,7 @@ public class MyMap implements Map { public Collection values() { Collection ret = new ArrayList<>(); for (MyEntry kv : values) { - ret.add(kv.value); + ret.add(kv.getValue()); } return ret; } diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 1afc9355d..7c9758340 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.avm2.parser.script.ActionScriptParser; +import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; @@ -73,6 +74,7 @@ import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.decompiler.flash.xfl.FLAVersion; +import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; import com.jpexs.helpers.streams.SeekableInputStream; @@ -251,8 +253,8 @@ public class CommandLineArgumentParser { out.println(" ...converts FlashPaper SWF file to PDF . Use -zoom parameter to specify image quality."); out.println(" " + (cnt++) + ") -zoom "); out.println(" ...apply zoom during export (currently for FlashPaper conversion only)"); - out.println(" " + (cnt++) + ") -replace "); - out.println(" ...replaces the data of the specified BinaryData, Image or DefineSound tag"); + out.println(" " + (cnt++) + ") -replace (|) [(|) ]..."); + out.println(" ...replaces the data of the specified BinaryData, Image, DefineSound tag or Script"); out.println(); out.println("Examples:"); out.println("java -jar ffdec.jar myfile.swf"); @@ -1350,14 +1352,38 @@ public class CommandLineArgumentParser { if (asms.containsKey(objectToReplace)) { found = true; // replace AS1/2 - // todo: implement + String repFile = args.remove(); + String as = Helper.readTextFile(repFile); + ASMSource src = asms.get(objectToReplace); + com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser par = new com.jpexs.decompiler.flash.action.parser.script.ActionScriptParser(swf.version); + try { + src.setActions(par.actionsFromString(as)); + } catch (ParseException ex) { + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.exit(1); + } catch (CompilationException ex) { + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.exit(1); + } + src.setModified(); } else { List> packs = swf.getAS3Packs(); for (MyEntry entry : packs) { if (entry.toString().equals(objectToReplace)) { found = true; // replace AS3 - // todo: implement + String repFile = args.remove(); + String as = Helper.readTextFile(repFile); + ScriptPack pack = entry.getValue(); + try { + pack.abc.replaceSciptPack(pack, as); + } catch (com.jpexs.decompiler.flash.abc.avm2.parser.ParseException ex) { + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.exit(1); + } catch (CompilationException ex) { + System.err.println("%error% on line %line%".replace("%error%", ex.text).replace("%line%", "" + ex.line)); + System.exit(1); + } } } } @@ -1433,7 +1459,7 @@ public class CommandLineArgumentParser { SWF swf = new SWF(is, Configuration.parallelSpeedUp.get()); List> packs = swf.getAS3Packs(); for (MyEntry entry : packs) { - System.out.println(entry.key.toString()); + System.out.println(entry.getKey().toString()); } } } catch (IOException | InterruptedException e) { diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index a701988d7..4046bb42d 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.ShapeExporter; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; import com.jpexs.decompiler.flash.tags.DefineButtonSoundTag; @@ -73,7 +72,6 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis static final String ACTION_SELECT_BKCOLOR = "SELECTCOLOR"; - //private JLabel label = new JLabel(); private Timelined timelined; private boolean stillFrame = false; private Timer timer; @@ -81,7 +79,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private SWF swf; private boolean loaded; private int mouseButton; - private JLabel debugLabel = new JLabel("-"); + private final JLabel debugLabel = new JLabel("-"); private DepthState stateUnderCursor = null; private MouseEvent lastMouseEvent = null; private final List soundPlayers = new ArrayList<>(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 3ab485b69..72eefe499 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -48,7 +48,6 @@ import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JToggleButton; import javax.swing.SwingUtilities; import org.pushingpixels.flamingo.api.common.AbstractCommandButton; import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState; diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index c9d54b1a2..27eb6f0a4 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -64,7 +64,6 @@ import com.jpexs.decompiler.flash.gui.dumpview.DumpTreeModel; import com.jpexs.decompiler.flash.gui.dumpview.DumpViewPanel; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.timeline.TimelineViewPanel; -import com.jpexs.decompiler.flash.gui.timeline.TimelinePanel; import com.jpexs.decompiler.flash.gui.treenodes.SWFBundleNode; import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; import com.jpexs.decompiler.flash.gui.treenodes.StringNode; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 7b8a5fb07..bdc241090 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.GetLocal0Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushScopeIns; import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.ActionScriptParser; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; @@ -59,8 +58,6 @@ import com.jpexs.decompiler.flash.gui.abc.tablemodels.UIntTableModel; import com.jpexs.decompiler.flash.helpers.Freed; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.flash.tags.SymbolClassTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.treenodes.TreeNode; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.helpers.CancellableWorker; @@ -171,7 +168,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se pos++; String workText = AppStrings.translate("work.searching"); String decAdd = ""; - if (!decompiledTextArea.isCached(item.value)) { + if (!decompiledTextArea.isCached(item.getValue())) { decAdd = ", " + AppStrings.translate("work.decompiling"); } @@ -180,18 +177,18 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se @Override public Void doInBackground() throws Exception { - decompiledTextArea.cacheScriptPack(item.value, swf.abcList); - if (pat.matcher(decompiledTextArea.getCachedText(item.value)).find()) { + decompiledTextArea.cacheScriptPack(item.getValue(), swf.abcList); + if (pat.matcher(decompiledTextArea.getCachedText(item.getValue())).find()) { ABCPanelSearchResult searchResult = new ABCPanelSearchResult(); - searchResult.scriptPack = item.value; - searchResult.classPath = item.key; + searchResult.scriptPack = item.getValue(); + searchResult.classPath = item.getKey(); found.add(searchResult); } return null; } }; worker.execute(); - Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + item.key.toString() + "... ", worker); + Main.startWork(workText + " \"" + txt + "\"" + decAdd + " - (" + pos + "/" + allpacks.size() + ") " + item.getKey().toString() + "... ", worker); worker.get(); } catch (InterruptedException ex) { break; @@ -668,8 +665,8 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode.getItem(); ScriptPack pack = null; for (MyEntry item : clModel.getList()) { - if (item.key.toString().equals(name)) { - pack = item.value; + if (item.getKey().toString().equals(name)) { + pack = item.getValue(); break; } } @@ -777,37 +774,16 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se break; case ACTION_SAVE_DECOMPILED: ScriptPack pack = decompiledTextArea.getScriptLeaf(); - String scriptName = pack.getPathScriptName() + ".as"; int oldIndex = pack.scriptIndex; - int newIndex = abc.script_info.size(); - String documentClass = ""; - loopt: - for (Tag t : swf.tags) { - if (t instanceof SymbolClassTag) { - SymbolClassTag sc = (SymbolClassTag) t; - for (int i = 0; i < sc.tags.length; i++) { - if (sc.tags[i] == 0) { - documentClass = sc.names[i]; - break loopt; - } - } - } - } - boolean isDocumentClass = documentClass.equals(pack.getPath().toString()); try { - abc.script_info.get(oldIndex).delete(abc, true); - ActionScriptParser.compile(decompiledTextArea.getText(), abc, new ArrayList(), isDocumentClass, scriptName); - //Move newly added script to its position - abc.script_info.set(oldIndex, abc.script_info.get(newIndex)); - abc.script_info.remove(newIndex); - abc.pack(); //removes old classes/methods - ((Tag) abc.parentTag).setModified(true); - lastDecompiled = decompiledTextArea.getText(); + String as = decompiledTextArea.getText(); + abc.replaceSciptPack(pack, as); + lastDecompiled = as; mainPanel.updateClassesList(); List> packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex); if (!packs.isEmpty()) { - hilightScript(swf, packs.get(0).key.toString()); + hilightScript(swf, packs.get(0).getKey().toString()); } //decompiledTextArea.setClassIndex(-1); //navigator.setClassIndex(-1, oldIndex); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index 89720fa6a..4e78a8a7f 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -120,13 +120,13 @@ public class ClassesListTreeModel implements TreeModel, TreeElementItem { filter = (filter == null || filter.isEmpty()) ? null : filter.toLowerCase(); for (MyEntry item : list) { if (filter != null) { - if (!item.key.toString().toLowerCase().contains(filter)) { + if (!item.getKey().toString().toLowerCase().contains(filter)) { continue; } } //String nsName = path.contains(".") ? path.substring(path.lastIndexOf(".") + 1) : path; //String packageName = path.contains(".") ? path.substring(0, path.lastIndexOf(".")) : ""; - classTree.add(item.key.className, item.key.packageStr, item.value); + classTree.add(item.getKey().className, item.getKey().packageStr, item.getValue()); } } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index ea92a2070..c806069be 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -43,7 +43,6 @@ import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.treenodes.TreeNode; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Cache; diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java index b88ebdbdf..da2ac900e 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java @@ -16,16 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.timeline; -import com.jpexs.decompiler.flash.gui.AppFrame; import com.jpexs.decompiler.flash.gui.ImagePanel; -import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.timeline.Timelined; import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Image; -import java.util.ArrayList; -import java.util.List; import javax.swing.JPanel; import javax.swing.JSplitPane;