From 4089770d13a4ad0615d9638196a968984754ea0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 3 Nov 2022 19:53:49 +0100 Subject: [PATCH] Add new SWF file. WIP --- src/com/jpexs/decompiler/flash/gui/Main.java | 27 ++++++++++++++++++ .../decompiler/flash/gui/MainFrameMenu.java | 9 ++++-- .../flash/gui/graphics/newswf16.png | Bin 0 -> 985 bytes .../flash/gui/graphics/newswf32.png | Bin 0 -> 1705 bytes .../flash/gui/locales/MainFrame.properties | 5 +++- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/newswf16.png create mode 100644 src/com/jpexs/decompiler/flash/gui/graphics/newswf32.png diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 273688d60..d0ca2469a 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -47,10 +47,13 @@ import com.jpexs.decompiler.flash.gui.pipes.FirstInstance; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.EndTag; +import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.tags.base.ImportTag; import com.jpexs.decompiler.flash.treeitems.SWFList; +import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -78,6 +81,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -1459,6 +1463,29 @@ public class Main { return openFile(newSourceInfos, executeAfterOpen, null); } + + public static void newFile() { + View.checkAccess(); + if (mainFrame != null && !Configuration.openMultipleFiles.get()) { + sourceInfos.clear(); + mainFrame.getPanel().closeAll(false); + mainFrame.setVisible(false); + Helper.freeMem(); + } + SWFSourceInfo sourceInfo = new SWFSourceInfo(new ByteArrayInputStream(new byte[0]), "", "newfile.swf"); + sourceInfos.add(sourceInfo); + SWFList list = new SWFList(); + list.sourceInfo = sourceInfo; + SWF swf = new SWF(); + swf.setFile(""); + swf.displayRect = new RECT(0, 20 * 400, 0, 20 * 300); + swf.version = 17; + swf.addTag(new FileAttributesTag(swf)); + swf.hasEndTag = true; + list.add(swf); + swf.swfList = list; + mainFrame.getPanel().load(list, true); + } public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen, int[] reloadIndices) { View.checkAccess(); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 180b72bb8..4879c3164 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -172,6 +172,10 @@ public abstract class MainFrameMenu implements MenuBuilder { return saved; } + protected void newActionPerformed(ActionEvent evt) { + Main.newFile(); + } + protected boolean saveActionPerformed(ActionEvent evt) { if (Main.isWorking()) { return false; @@ -865,7 +869,8 @@ public abstract class MainFrameMenu implements MenuBuilder { addMenuItem("/file/saveAsExe", translate("menu.file.saveasexe"), "saveasexe16", this::saveAsExeActionPerformed, PRIORITY_MEDIUM, null, true, null, false); addMenuItem("/file/reload", translate("menu.file.reload"), "reload16", this::reloadActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+SHIFT+R"), false); addMenuItem("/file/reloadAll", translate("menu.file.reloadAll"), "reload16", this::reloadAllActionPerformed, PRIORITY_MEDIUM, null, true, null, false); - + addMenuItem("/file/new", translate("menu.file.new"), "newswf32", this::newActionPerformed, PRIORITY_TOP, null, true, null, false); + addSeparator("/file"); addMenuItem("/file/export", translate("menu.export"), null, null, 0, null, false, null, false); @@ -884,8 +889,8 @@ public abstract class MainFrameMenu implements MenuBuilder { addMenuItem("/file/start", translate("menu.file.start"), null, null, 0, null, false, null, false); addMenuItem("/file/start/run", translate("menu.file.start.run"), "play32", this::runActionPerformed, PRIORITY_TOP, null, true, new HotKey("F6"), false); - addMenuItem("/file/start/debug", translate("menu.file.start.debug"), "debug32", this::debugActionPerformed, PRIORITY_TOP, null, true, new HotKey("CTRL+F5"), false); addMenuItem("/file/start/stop", translate("menu.file.start.stop"), "stop32", this::stopActionPerformed, PRIORITY_TOP, null, true, null, false); + addMenuItem("/file/start/debug", translate("menu.file.start.debug"), "debug32", this::debugActionPerformed, PRIORITY_MEDIUM, null, true, new HotKey("CTRL+F5"), false); addMenuItem("/file/start/debugpcode", translate("menu.file.start.debugpcode"), "debug32", this::debugPCodeActionPerformed, PRIORITY_MEDIUM, null, true, null, false); finishMenu("/file/start"); diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/newswf16.png b/src/com/jpexs/decompiler/flash/gui/graphics/newswf16.png new file mode 100644 index 0000000000000000000000000000000000000000..ad8d943dd3cc43806105597300c9ea44a6dd049c GIT binary patch literal 985 zcmV;~119{5P)EX>4Tx04R}tkv&MmKpe$iQ>CI62P=v=WT;LSL`58>ibb$c+6t{Ym|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1le0HI!Hs@X9CsG4OY zV^J}aT@?eb=z)L%3?d*gQ;(+>)9@T$_we!cF2b|C&;2=im7K`{pGZ8%bi*RvAfDN@ zbk6(4Ay$+W;&bA0gDyz?$aUG}H_ioz1)do)(#d(^5V2TjW4Vo4(NKw}iNlJjQNECI zS>e3JSuIyt^Pc>L!JM{|;yTR{#IS@o5)dJyiW17O5TR8g#YB?!qaOZY$DbgVOs*0b zITlcX3d!+<|H1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