diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java index bfbc5039c..592361b33 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java @@ -20,11 +20,13 @@ import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; +import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.helpers.Cache; import com.sun.jna.Platform; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URISyntaxException; import java.util.List; @@ -478,7 +480,18 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener { break; case ACTION_SAVE: { SWF swf = mainFrame.panel.getCurrentSwf(); - if (swf.file == null) { + SWFNode snode = ((TagTreeModel)mainFrame.panel.tagTree.getModel()).getSwfNode(swf); + if(snode.binaryData!=null){ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + swf.saveTo(baos); + snode.binaryData.binaryData = baos.toByteArray(); + snode.binaryData.setModified(true); + } catch (IOException ex) { + Logger.getLogger(MainFrameRibbonMenu.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex); + } + } + else if(swf.file == null) { saveAs(swf, SaveFileMode.SAVEAS); } else { try { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index f35b6e7ef..617c961ed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.gui.helpers.CheckResources; +import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.helpers.Cache; @@ -510,7 +511,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { closeFileMenu.setEnabled(swfLoaded); closeAllFilesMenu.setEnabled(swfLoaded); - boolean isBundle = swfLoaded && (swf.swfList != null) && swf.swfList.isBundle; + boolean isBundle = swfLoaded && (swf.swfList != null) && swf.swfList.isBundle; saveCommandButton.setEnabled(swfLoaded && !isBundle); saveasCommandButton.setEnabled(swfLoaded); saveasexeCommandButton.setEnabled(swfLoaded); @@ -668,7 +669,18 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { break; case ACTION_SAVE: { SWF swf = mainFrame.panel.getCurrentSwf(); - if (swf.file == null) { + SWFNode snode = ((TagTreeModel)mainFrame.panel.tagTree.getModel()).getSwfNode(swf); + if(snode.binaryData!=null){ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + swf.saveTo(baos); + snode.binaryData.binaryData = baos.toByteArray(); + snode.binaryData.setModified(true); + } catch (IOException ex) { + Logger.getLogger(MainFrameRibbonMenu.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex); + } + } + else if (swf.file == null) { saveAs(swf, SaveFileMode.SAVEAS); } else { try { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 1a512a03a..1892ecd7f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2324,11 +2324,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec TreeItem treeItem = treeNode.getItem(); if (!(treeItem instanceof SWFList)) { SWF swf = treeItem.getSwf(); - if (swfs.contains(swf.swfList)) { + /*if (swfs.contains(swf.swfList)) { //why? updateUi(swf); } else { updateUi(); - } + }*/ + updateUi(swf); } else { updateUi(); } @@ -2510,7 +2511,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec timelined = parentSprite; } previewPanel.showImagePanel(timelined, swf, fn.getFrame() - 1); - } else if (((tagObj instanceof SoundTag) && isInternalFlashViewerSelected() && (Arrays.asList("mp3", "wav").contains(((SoundTag) tagObj).getExportFormat())))) { + } else if ((tagObj instanceof SoundTag)){ //&& isInternalFlashViewerSelected() && (Arrays.asList("mp3", "wav").contains(((SoundTag) tagObj).getExportFormat())))) { showCard(CARDPREVIEWPANEL); previewPanel.showImagePanel(new SerializableImage(View.loadImage("sound32"))); previewPanel.setImageReplaceButtonVisible(tagObj instanceof DefineSoundTag); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index cfe58939c..795eea69c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -680,7 +680,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { new ShowFrameTag(swf).writeTag(sos2); } } else if (tagObj instanceof DefineSoundTag) { - ExportAssetsTag ea = new ExportAssetsTag(); + ExportAssetsTag ea = new ExportAssetsTag(swf); DefineSoundTag ds = (DefineSoundTag) tagObj; ea.tags.add(ds.soundId); ea.names.add("my_define_sound"); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 13f58e11a..df7d6d87d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.treenodes.ClassesListNode; import com.jpexs.decompiler.flash.gui.abc.treenodes.TreeElement; @@ -25,6 +26,7 @@ import com.jpexs.decompiler.flash.gui.treenodes.SWFContainerNode; import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; import com.jpexs.decompiler.flash.gui.treenodes.StringNode; import com.jpexs.decompiler.flash.gui.treenodes.TagTreeRoot; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; @@ -38,6 +40,11 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem; import com.jpexs.decompiler.flash.treenodes.FrameNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -153,7 +160,20 @@ public class TagTreeModel implements TreeModel { sounds.add(new TagNode(t)); break; case BINARY_DATA: - binaryData.add(new TagNode(t)); + TagNode bt; + binaryData.add(bt = new TagNode(t)); + + DefineBinaryDataTag b=(DefineBinaryDataTag)t; + + try { + SWF bswf=new SWF(new ByteArrayInputStream(b.binaryData),Configuration.parallelSpeedUp.get()); + bswf.fileTitle = "(SWF Data)"; + SWFNode snode=createSwfNode(bswf); + snode.binaryData = b; + bt.subNodes.add(snode); + } catch (IOException | InterruptedException ex) { + //ignore + } break; default: if (!actionScriptTags.contains(t) && !ShowFrameTag.isNestedTagType(t.getId())) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/SWFNode.java b/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/SWFNode.java index a8f17b473..a78a9b49e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/SWFNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/SWFNode.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui.treenodes; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.treenodes.TreeNode; import java.util.List; @@ -29,6 +30,7 @@ public class SWFNode extends SWFContainerNode { private final String name; public List list; public TreeNode scriptsNode; + public DefineBinaryDataTag binaryData; public SWFNode(SWF swf, String name) { super(swf); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java index beb56002e..46f5f7704 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/ExportAssetsTag.java @@ -47,8 +47,8 @@ public class ExportAssetsTag extends Tag { public List names; public static final int ID = 56; - public ExportAssetsTag() { - super(null, ID, "ExportAssets", new byte[0], new byte[0], 0); + public ExportAssetsTag(SWF swf) { + super(swf, ID, "ExportAssets", new byte[0], new byte[0], 0); tags = new ArrayList<>(); names = new ArrayList<>(); }