diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 51f207cc2..bb636b288 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -212,8 +212,8 @@ public class Main { public static final int LIBRARY_AIR = 0; public static final int LIBRARY_FLASH = 1; - public static boolean isSwfAir(SWF swf) { - SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(swf.getShortPathTitle()); + public static boolean isSwfAir(Openable openable) { + SwfSpecificCustomConfiguration conf = Configuration.getSwfSpecificCustomConfiguration(openable.getShortPathTitle()); if (conf != null) { String libraryAsStr = conf.getCustomData(CustomConfigurationKeys.KEY_LIBRARY, "" + LIBRARY_FLASH); int libraryAsInt = Integer.parseInt(libraryAsStr); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index d2ae46edb..055939726 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -290,7 +290,7 @@ public abstract class MainFrameMenu implements MenuBuilder { return; } - mainFrame.getPanel().importScript((SWF) openable); + mainFrame.getPanel().importScript(openable); } protected void importImagesActionPerformed(ActionEvent evt) { @@ -803,16 +803,25 @@ public abstract class MainFrameMenu implements MenuBuilder { boolean swfIsNew = openableSelected && openable.getOpenableList() != null && openable.getOpenableList().sourceInfo.isEmpty(); boolean allSameSwf = true; + boolean allSameOpenable = true; if (mainPanel != null) { List items = mainPanel.getCurrentTree().getSelected(); SWF firstSwf = null; + Openable firstOpenable = null; for (TreeItem item : items) { if (item instanceof OpenableList) { allSameSwf = false; break; } - if (firstSwf == null) { - Openable fopenable = item.getOpenable(); + Openable fopenable = item.getOpenable(); + if (firstOpenable == null) { + firstOpenable = fopenable; + } else { + if (fopenable != firstOpenable) { + allSameOpenable = false; + } + } + if (firstSwf == null) { if (fopenable instanceof SWF) { firstSwf = (SWF) fopenable; } else { @@ -852,7 +861,7 @@ public abstract class MainFrameMenu implements MenuBuilder { setMenuEnabled("/file/import", openableSelected); setMenuEnabled("/file/import/importText", allSameSwf && swfSelected && !isWorking); - setMenuEnabled("/file/import/importScript", allSameSwf && swfSelected && !isWorking); + setMenuEnabled("/file/import/importScript", allSameOpenable && openableSelected && !isWorking); setMenuEnabled("/file/import/importOther", allSameSwf && swfSelected && !isWorking); setMenuEnabled("/file/import/importXml", allSameSwf && swfSelected && !isWorking); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 992ba8dfb..1be6ebdcd 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -3237,14 +3237,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return r; } - public void importScript(final SWF swf) { - As3ScriptReplacerInterface as3ScriptReplacer = getAs3ScriptReplacer(Main.isSwfAir(swf)); + public void importScript(final Openable openable) { + As3ScriptReplacerInterface as3ScriptReplacer = getAs3ScriptReplacer(Main.isSwfAir(openable)); if (as3ScriptReplacer == null) { return; } ViewMessages.showMessageDialog(MainPanel.this, translate("message.info.importScripts"), translate("message.info"), JOptionPane.INFORMATION_MESSAGE, Configuration.showImportScriptsInfo); - String flexLocation = Configuration.flexSdkLocation.get(); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(Configuration.lastExportDir.get())); chooser.setDialogTitle(translate("import.select.directory")); @@ -3260,13 +3259,27 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override public Void doInBackground() throws Exception { + + SWF swf = (openable instanceof SWF) ? (SWF) openable : ((ABC) openable).getSwf(); + new AS2ScriptImporter().importScripts(scriptsFolder, swf.getASMs(true), new ScriptImporterProgressListener() { @Override public void scriptImported() { countAs2++; } }); - new AS3ScriptImporter().importScripts(as3ScriptReplacer, scriptsFolder, swf.getAS3Packs(), new ScriptImporterProgressListener() { + + List packs; + if (openable instanceof SWF) { + packs = swf.getAS3Packs(); + } else { + List allAbcs = new ArrayList<>(); + ABC abc = (ABC) openable; + allAbcs.add(abc); + packs = abc.getScriptPacks(null, allAbcs); + } + + new AS3ScriptImporter().importScripts(as3ScriptReplacer, scriptsFolder, packs, new ScriptImporterProgressListener() { @Override public void scriptImported() { countAs3++; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 5052c345a..41013651f 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -238,7 +238,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener getAbcList() { SWF swf = getSwf(); @@ -1480,7 +1484,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener