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 000000000..ad8d943dd Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/newswf16.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/newswf32.png b/src/com/jpexs/decompiler/flash/gui/graphics/newswf32.png new file mode 100644 index 000000000..e949559a5 Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/newswf32.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 d8a4c50ac..2ba623593 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -906,4 +906,7 @@ and/or ActionDefineFunction/2.\r\nYou can try to shorten the script and/or the f contextmenu.attachTag = Attach tag -contextmenu.showInHexDump = Show Hex dump \ No newline at end of file +contextmenu.showInHexDump = Show Hex dump + +menu.file.new = New empty +