diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index a66b76c67..2f2038a8d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -270,7 +270,7 @@ public class Configuration { @ConfigurationName("gui.skin") @ConfigurationCategory("ui") public static final ConfigurationItem guiSkin = null; - + @ConfigurationDefaultInt(3) @ConfigurationCategory("export") public static final ConfigurationItem saveAsExeScaleMode = null; @@ -430,10 +430,12 @@ public class Configuration { @ConfigurationCategory("ui") public static final ConfigurationItem autoSaveTagModifications = null; - @ConfigurationDefaultBoolean(false) + @ConfigurationDefaultBoolean(true) @ConfigurationCategory("ui") public static final ConfigurationItem saveSessionOnExit = null; + public static final ConfigurationItem lastSessionData = null; + @ConfigurationDefaultBoolean(true) @ConfigurationCategory("ui") public static final ConfigurationItem allowOnlyOneInstance = null; diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 01c4f954d..5646ed290 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -23,26 +23,15 @@ import com.jpexs.decompiler.flash.SWFBundle; import com.jpexs.decompiler.flash.SWFSourceInfo; import com.jpexs.decompiler.flash.SearchMode; import com.jpexs.decompiler.flash.Version; -import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.CommandLineArgumentParser; import com.jpexs.decompiler.flash.console.ContextMenuTools; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.gui.pipes.FirstInstance; import com.jpexs.decompiler.flash.gui.proxy.ProxyFrame; -import com.jpexs.decompiler.flash.helpers.CodeFormatting; -import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; -import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; -import com.jpexs.decompiler.flash.tags.DoABCDefineTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.decompiler.flash.treeitems.SWFList; -import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; @@ -74,7 +63,6 @@ import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.PrintWriter; import java.lang.reflect.Field; import java.net.InetSocketAddress; import java.net.Proxy; @@ -417,12 +405,24 @@ public class Main { private final SWFSourceInfo[] sourceInfos; + private final Runnable executeAfterOpen; + public OpenFileWorker(SWFSourceInfo sourceInfo) { + this(sourceInfo, null); + } + + public OpenFileWorker(SWFSourceInfo sourceInfo, Runnable executeAfterOpen) { this.sourceInfos = new SWFSourceInfo[]{sourceInfo}; + this.executeAfterOpen = executeAfterOpen; } public OpenFileWorker(SWFSourceInfo[] sourceInfos) { + this(sourceInfos, null); + } + + public OpenFileWorker(SWFSourceInfo[] sourceInfos, Runnable executeAfterOpen) { this.sourceInfos = sourceInfos; + this.executeAfterOpen = executeAfterOpen; } @Override @@ -467,16 +467,17 @@ public class Main { shouldCloseWhenClosingLoadingDialog = false; final SWF fswf = firstSWF; - View.execInEventDispatch(new Runnable() { - @Override - public void run() { - if (mainFrame != null) { - mainFrame.setVisible(true); - } - Main.stopWork(); - if (mainFrame != null && Configuration.gotoMainClassOnStartup.get()) { - mainFrame.getPanel().gotoDocumentClass(fswf); - } + View.execInEventDispatch(() -> { + if (executeAfterOpen != null) { + executeAfterOpen.run(); + } + + if (mainFrame != null) { + mainFrame.setVisible(true); + } + Main.stopWork(); + if (mainFrame != null && Configuration.gotoMainClassOnStartup.get()) { + mainFrame.getPanel().gotoDocumentClass(fswf); } }); @@ -536,6 +537,10 @@ public class Main { } public static OpenFileResult openFile(String swfFile, String fileTitle) { + return openFile(swfFile, fileTitle, null); + } + + public static OpenFileResult openFile(String swfFile, String fileTitle, Runnable executeAfterOpen) { try { File file = new File(swfFile); if (!file.exists()) { @@ -557,7 +562,15 @@ public class Main { return openFile(new SWFSourceInfo[]{sourceInfo}); } + public static OpenFileResult openFile(SWFSourceInfo sourceInfo, Runnable executeAfterOpen) { + return openFile(new SWFSourceInfo[]{sourceInfo}, executeAfterOpen); + } + public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos) { + return openFile(newSourceInfos, null); + } + + public static OpenFileResult openFile(SWFSourceInfo[] newSourceInfos, Runnable executeAfterOpen) { if (mainFrame != null && !Configuration.openMultipleFiles.get()) { sourceInfos.clear(); mainFrame.getPanel().closeAll(); @@ -566,7 +579,7 @@ public class Main { } loadingDialog.setVisible(true); - OpenFileWorker wrk = new OpenFileWorker(newSourceInfos); + OpenFileWorker wrk = new OpenFileWorker(newSourceInfos, executeAfterOpen); wrk.execute(); sourceInfos.addAll(Arrays.asList(newSourceInfos)); return OpenFileResult.OK; @@ -1052,6 +1065,7 @@ public class Main { Main.exit(); } else { showModeFrame(); + reloadLastSession(); } } else { @@ -1070,6 +1084,30 @@ public class Main { } } + private static void reloadLastSession() { + if (Configuration.saveSessionOnExit.get()) { + String lastSession = Configuration.lastSessionData.get(); + if (lastSession != null && lastSession.length() > 0) { + String[] filesToOpen = lastSession.split(File.pathSeparator, -1); + int cnt = filesToOpen.length - 1; + SWFSourceInfo[] sourceInfos = new SWFSourceInfo[cnt]; + for (int i = 0; i < cnt; i++) { + String fileToOpen = filesToOpen[i]; + sourceInfos[i] = new SWFSourceInfo(null, fileToOpen, null); + } + + openFile(sourceInfos, () -> { + // last part contains the selected node in the tagtree + String pathStr = filesToOpen[filesToOpen.length - 1]; + if (pathStr.length() > 0) { + String[] path = pathStr.split("\\|"); + View.selectTreeNode(mainFrame.getPanel().tagTree, Arrays.asList(path)); + } + }); + } + } + } + public static String tempFile(String url) throws IOException { File f = new File(Configuration.getFFDecHome() + "saved" + File.separator); Path.createDirectorySafe(f); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 66d816729..9c13dbf9e 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; +import com.jpexs.decompiler.flash.treeitems.SWFList; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -29,8 +30,10 @@ import java.awt.event.ComponentEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowStateListener; +import java.io.File; import java.util.List; import javax.swing.JFrame; +import javax.swing.tree.TreePath; import org.pushingpixels.flamingo.api.ribbon.JRibbon; import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton; @@ -114,6 +117,32 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { + if (Configuration.saveSessionOnExit.get()) { + StringBuilder sb = new StringBuilder(); + for (SWFList swf : panel.getSwfs()) { + String file = swf.sourceInfo.getFile(); + if (file != null) { + sb.append(file); + sb.append(File.pathSeparator); + } + } + + TreePath path = panel.tagTree.getLeadSelectionPath(); + if (path != null) { + boolean first = true; + for (Object p : path.getPath()) { + if (!first) { + sb.append("|"); + } + + first = false; + sb.append(p.toString()); + } + } + + Configuration.lastSessionData.set(sb.toString()); + } + boolean closeResult = panel.closeAll(); if (closeResult) { Main.exit(); diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index 08c255648..f893e2941 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -99,11 +99,11 @@ import org.pushingpixels.substance.internal.utils.SubstanceColorSchemeUtilities; * @author JPEXS */ public class View { - + public static Color getDefaultBackgroundColor() { return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor(); } - + private static Color swfBackgroundColor = null; public static void setSwfBackgroundColor(Color swfBackgroundColor) { @@ -111,13 +111,11 @@ public class View { } public static Color getSwfBackgroundColor() { - if(swfBackgroundColor == null){ + if (swfBackgroundColor == null) { return getDefaultBackgroundColor(); } return swfBackgroundColor; } - - private static final BufferedImage transparentTexture; @@ -286,15 +284,15 @@ public class View { */ public static void setWindowIcon(Window f) { List images = new ArrayList<>(); - MyResizableIcon[] icons=MyRibbonApplicationMenuButtonUI.getIcons(); - MyResizableIcon icon=icons[1]; - int sizes[] = new int[] {16,32,48,256}; - for(int size:sizes){ - icon.setIconSize(size,size); - BufferedImage bi=new BufferedImage(size, size, BufferedImage.TYPE_4BYTE_ABGR); + MyResizableIcon[] icons = MyRibbonApplicationMenuButtonUI.getIcons(); + MyResizableIcon icon = icons[1]; + int sizes[] = new int[]{16, 32, 48, 256}; + for (int size : sizes) { + icon.setIconSize(size, size); + BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_4BYTE_ABGR); icon.paintIcon(f, bi.getGraphics(), 0, 0); images.add(bi); - } + } f.setIconImages(images); } @@ -532,15 +530,15 @@ public class View { } } - private static void expandTreeNode(JTree tree, List pathAsStringList) { + private static TreePath expandTreeNode(JTree tree, List pathAsStringList) { TreeModel model = tree.getModel(); Object node = model.getRoot(); if (pathAsStringList.isEmpty()) { - return; + return null; } if (!pathAsStringList.get(0).equals(node.toString())) { - return; + return null; } List path = new ArrayList<>(); @@ -561,6 +559,14 @@ public class View { TreePath tp = new TreePath(path.toArray(new Object[path.size()])); tree.expandPath(tp); + return tp; + } + + public static void selectTreeNode(JTree tree, List pathAsStringList) { + TreePath tp = expandTreeNode(tree, pathAsStringList); + if (tp != null) { + tree.setSelectionPath(tp); + } } public static void expandTreeNodes(JTree tree, TreePath parent, boolean expand) { diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index c692f46af..21599eb23 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -339,6 +339,8 @@ config.description.scriptExportSingleFile = Exporting texts to one file instead config.name.setFFDecVersionInExportedFont = Set FFDec version number in exported font config.description.setFFDecVersionInExportedFont = When this setting is disabled, FFDec won't add the current FFDec version number to the exported font. - config.name.gui.skin = User Interface Skin -config.description.gui.skin = Look and feel skin \ No newline at end of file +config.description.gui.skin = Look and feel skin + +config.name.gui.lastSessionData = Last session data +config.description.gui.lastSessionData = Contains the opened files from the last session diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties index 4059d4da6..ce6b28663 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties @@ -338,3 +338,9 @@ config.description.scriptExportSingleFile = Szkriptek export\u00e1l\u00e1sa egye config.name.setFFDecVersionInExportedFont = FFDec verzi\u00f3sz\u00e1m be\u00e1ll\u00edt\u00e1sa az export\u00e1lt bet\u0171t\u00edpusban config.description.setFFDecVersionInExportedFont = Ha ez a be\u00e1ll\u00edt\u00e1s ki van kapcsolva, az FFDec nem fogja be\u00edrni az aktu\u00e1lis FFDec verzi\u00f3sz\u00e1m\u00e1t az export\u00e1lt bet\u0171t\u00edpus f\u00e1jlba. + +config.name.gui.skin = Felhaszn\u00e1l\u00f3i fel\u00fclet b\u0151r +config.description.gui.skin = Kin\u00e9zet + +config.name.gui.lastSessionData = Utols\u00f3 munkamenet adatai +config.description.gui.lastSessionData = Az legut\u00f3bbi munkamenetben megnyitott f\u00e1jlokat tartalmazza