diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 5765de7ea..4ee80b9b3 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -641,7 +641,21 @@ public class Main { return AppStrings.translate("filter.swf"); } }; - if (!swf.gfx) { + + FileFilter exeFilter = new FileFilter() { + @Override + public boolean accept(File f) { + return (f.getName().toLowerCase().endsWith(".exe")) || (f.isDirectory()); + } + + @Override + public String getDescription() { + return AppStrings.translate("filter.exe"); + } + }; + if(mode == SaveFileMode.EXE){ + fc.setFileFilter(exeFilter); + } else if (!swf.gfx) { fc.setFileFilter(swfFilter); } else { fc.addChoosableFileFilter(swfFilter); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 07dd674eb..a1424b416 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -134,7 +134,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private static final String ACTION_EXPORT = "EXPORT"; - private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT"; + private static final String ACTION_IMPORT_TEXT = "IMPORTTEXT"; private static final String ACTION_CHECK_UPDATES = "CHECKUPDATES"; @@ -199,6 +199,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private JCommandButton exportSelectionCommandButton; private JCommandButton importTextCommandButton; + private JCommandButton importXmlCommandButton; + private JCommandButton exportXmlCommandButton; private JCommandToggleButton viewModeResourcesToggleButton; @@ -409,11 +411,15 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener reloadCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.reload")), View.getResizableIcon("reload16")); assignListener(reloadCommandButton, ACTION_RELOAD); + + saveasexeCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveasexe")), View.getResizableIcon("saveasexe16")); + assignListener(saveasexeCommandButton, ACTION_SAVE_AS_EXE); editBand.addCommandButton(openCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveCommandButton, RibbonElementPriority.TOP); editBand.addCommandButton(saveasCommandButton, RibbonElementPriority.MEDIUM); - editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM); + editBand.addCommandButton(saveasexeCommandButton, RibbonElementPriority.MEDIUM); + editBand.addCommandButton(reloadCommandButton, RibbonElementPriority.MEDIUM); JRibbonBand exportBand = new JRibbonBand(translate("menu.export"), null); exportBand.setResizePolicies(getResizePolicies(exportBand)); @@ -423,20 +429,27 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener assignListener(exportAllCommandButton, ACTION_EXPORT); exportSelectionCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.selection")), View.getResizableIcon("exportsel16")); assignListener(exportSelectionCommandButton, ACTION_EXPORT_SEL); - saveasexeCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.saveasexe")), View.getResizableIcon("saveasexe16")); - assignListener(saveasexeCommandButton, ACTION_SAVE_AS_EXE); + + + exportXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.export.xml")), View.getResizableIcon("exportxml32")); + assignListener(exportXmlCommandButton, ACTION_EXPORT_SWF_XML); exportBand.addCommandButton(exportFlaCommandButton, RibbonElementPriority.TOP); exportBand.addCommandButton(exportAllCommandButton, RibbonElementPriority.MEDIUM); exportBand.addCommandButton(exportSelectionCommandButton, RibbonElementPriority.MEDIUM); - exportBand.addCommandButton(saveasexeCommandButton, RibbonElementPriority.MEDIUM); + exportBand.addCommandButton(exportXmlCommandButton, RibbonElementPriority.MEDIUM); + JRibbonBand importBand = new JRibbonBand(translate("menu.import"), null); importBand.setResizePolicies(getResizePolicies(importBand)); - importTextCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.text")), View.getResizableIcon("import32")); + importTextCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.text")), View.getResizableIcon("importtext32")); assignListener(importTextCommandButton, ACTION_IMPORT_TEXT); + + importXmlCommandButton = new JCommandButton(fixCommandTitle(translate("menu.file.import.xml")), View.getResizableIcon("importxml32")); + assignListener(importXmlCommandButton, ACTION_IMPORT_SWF_XML); - importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); + importBand.addCommandButton(importXmlCommandButton, RibbonElementPriority.TOP); + importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); JRibbonBand viewBand = new JRibbonBand(translate("menu.view"), null); viewBand.setResizePolicies(getResizePolicies(viewBand)); @@ -721,8 +734,10 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener saveasexeCommandButton.setEnabled(swfLoaded); exportAllCommandButton.setEnabled(swfLoaded); exportFlaCommandButton.setEnabled(swfLoaded); + exportXmlCommandButton.setEnabled(swfLoaded); exportSelectionCommandButton.setEnabled(swfLoaded); importTextCommandButton.setEnabled(swfLoaded); + importXmlCommandButton.setEnabled(swfLoaded); reloadCommandButton.setEnabled(swfLoaded); renameInvalidCommandButton.setEnabled(swfLoaded); @@ -933,6 +948,13 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener case ACTION_IMPORT_TEXT: importText(); break; + + case ACTION_EXPORT_SWF_XML: + mainFrame.getPanel().exportSwfXml(); + break; + case ACTION_IMPORT_SWF_XML: + mainFrame.getPanel().importSwfXml(); + break; case ACTION_EXPORT_SEL: case ACTION_EXPORT: boolean onlySel = e.getActionCommand().equals(ACTION_EXPORT_SEL); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index e21732b23..91395b52a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -1704,18 +1704,21 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void exportSwfXml() { List sel = tagTree.getSelected(tagTree); + Set swfs = new HashSet<>(); + for (TreeItem item : sel) { - if (item instanceof SWF) { - SWF swf = (SWF) item; - final String selFile = selectExportDir(); - if (selFile != null) { - try { - File outFile = new File(selFile + File.separator + Helper.makeFileName("swf.xml")); - new SwfXmlExporter().exportXml(swf, outFile); - Main.stopWork(); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } + swfs.add(item.getSwf()); + } + + for (SWF swf : swfs) { + final String selFile = selectExportDir(); + if (selFile != null) { + try { + File outFile = new File(selFile + File.separator + Helper.makeFileName("swf.xml")); + new SwfXmlExporter().exportXml(swf, outFile); + Main.stopWork(); + } catch (IOException ex) { + logger.log(Level.SEVERE, null, ex); } } } @@ -1723,22 +1726,27 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void importSwfXml() { List sel = tagTree.getSelected(tagTree); + Set swfs = new HashSet<>(); for (TreeItem item : sel) { - if (item instanceof SWF) { - SWF swf = (SWF) item; - File selectedFile = showImportFileChooser("filter.xml|*.xml"); - if (selectedFile != null) { - File selfile = Helper.fixDialogFile(selectedFile); - String xml = Helper.readTextFile(selfile.getPath()); - try { - new SwfXmlImporter().importSwf(swf, xml); - swf.clearAllCache(); - swf.assignExportNamesToSymbols(); - swf.assignClassesToSymbols(); - refreshTree(); - } catch (IOException ex) { - logger.log(Level.SEVERE, null, ex); - } + swfs.add(item.getSwf()); + } + if (swfs.size() > 1) { + return; + } + + for (SWF swf : swfs) { + File selectedFile = showImportFileChooser("filter.xml|*.xml"); + if (selectedFile != null) { + File selfile = Helper.fixDialogFile(selectedFile); + String xml = Helper.readTextFile(selfile.getPath()); + try { + new SwfXmlImporter().importSwf(swf, xml); + swf.clearAllCache(); + swf.assignExportNamesToSymbols(); + swf.assignClassesToSymbols(); + refreshTree(); + } catch (IOException ex) { + logger.log(Level.SEVERE, null, ex); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png b/src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png new file mode 100644 index 000000000..6f9da78cc Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/exportxml32.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png b/src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png new file mode 100644 index 000000000..0aa20e6de Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/importtext32.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png b/src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png new file mode 100644 index 000000000..d194895be Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/importxml32.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 79e983fa5..f40f3b8ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -564,3 +564,6 @@ text.align.center = Center align text.align.justify = Justify align text.undo = Undo changes + +menu.file.import.xml = Import SWF XML +menu.file.export.xml = Export SWF XML \ No newline at end of file