mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-22 10:15:42 +00:00
Opening SWFs in BinaryData tags
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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<TreeNode> list;
|
||||
public TreeNode scriptsNode;
|
||||
public DefineBinaryDataTag binaryData;
|
||||
|
||||
public SWFNode(SWF swf, String name) {
|
||||
super(swf);
|
||||
|
||||
@@ -47,8 +47,8 @@ public class ExportAssetsTag extends Tag {
|
||||
public List<String> 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<>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user