From 7d05b54d703c75d033be0c829f05a6fae498bead Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Wed, 18 Mar 2015 23:16:59 +0100 Subject: [PATCH] rendering fix, gc and cache clear buttons added to debug menu --- .../src/com/jpexs/decompiler/flash/SWF.java | 2 +- .../flash/configuration/Configuration.java | 4 ++ .../flash/gui/MainFrameClassicMenu.java | 1 - .../flash/gui/MainFrameRibbonMenu.java | 45 +++++++++---------- .../locales/AdvancedSettingsDialog.properties | 3 ++ .../AdvancedSettingsDialog_hu.properties | 3 ++ .../flash/gui/tagtree/TagTreeContextMenu.java | 1 + .../flash/gui/tagtree/TagTreeModel.java | 7 ++- 8 files changed, 40 insertions(+), 26 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 17669e766..f93dd03e2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -2561,7 +2561,7 @@ public final class SWF implements SWFContainerItem, Timelined { SerializableImage img = null; String cacheKey = null; if (drawable instanceof ShapeTag) { - cacheKey = m.toString() + clrTrans.toString(); + cacheKey = ((ShapeTag) drawable).getCharacterId() + m.toString() + clrTrans.toString(); img = renderContext.shapeCache.get(cacheKey); } 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 137001215..cc2408886 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 @@ -146,6 +146,10 @@ public class Configuration { @ConfigurationCategory("debug") public static final ConfigurationItem debugMode = null; + @ConfigurationDefaultBoolean(false) + @ConfigurationCategory("debug") + public static final ConfigurationItem showDebugMenu = null; + /** * Turn off resolving constants in ActionScript 2 */ diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java index 6d340b201..535ccd1cb 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameClassicMenu.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.SWFBundle; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.console.ContextMenuTools; import com.jpexs.decompiler.flash.tags.ABCContainerTag; diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 03c27c1d2..0bd6edfee 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -41,6 +41,7 @@ import org.pushingpixels.flamingo.api.common.CommandToggleButtonGroup; import org.pushingpixels.flamingo.api.common.JCommandButton; import org.pushingpixels.flamingo.api.common.JCommandButtonPanel; import org.pushingpixels.flamingo.api.common.JCommandToggleButton; +import org.pushingpixels.flamingo.api.common.icon.ResizableIcon; import org.pushingpixels.flamingo.api.ribbon.JRibbon; import org.pushingpixels.flamingo.api.ribbon.JRibbonBand; import org.pushingpixels.flamingo.api.ribbon.JRibbonComponent; @@ -155,14 +156,8 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private static final String ACTION_DEOBFUSCATE_ALL = "DEOBFUSCATEALL"; - private static final String ACTION_REMOVE_NON_SCRIPTS = "REMOVENONSCRIPTS"; - - private static final String ACTION_REFRESH_DECOMPILED = "REFRESHDECOMPILED"; - private static final String ACTION_CLEAR_RECENT_FILES = "CLEARRECENTFILES"; - private static final String ACTION_CHECK_RESOURCES = "CHECKRESOURCES"; - private static final String ACTION_VIEWMODE_RESOURCES = "VIEWMODERESOURCES"; private static final String ACTION_VIEWMODE_HEX_DUMP = "VIEWMODEHEXDUMP"; @@ -270,7 +265,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener ribbon.addTask(createSettingsRibbonTask(externalFlashPlayerUnavailable)); ribbon.addTask(createHelpRibbonTask()); - if (Configuration.debugMode.get()) { + if (Configuration.showDebugMenu.get()) { ribbon.addTask(createDebugRibbonTask()); } @@ -520,7 +515,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener searchCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.search")), View.getResizableIcon("search32")); assignListener(searchCommandButton, ACTION_SEARCH); - // todo: change icon replaceCommandButton = new JCommandButton(fixCommandTitle(translate("menu.tools.replace")), View.getResizableIcon("replace32")); assignListener(replaceCommandButton, ACTION_REPLACE); @@ -703,21 +697,35 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener private RibbonTask createDebugRibbonTask() { // ----------------------------------------- DEBUG ----------------------------------- + ResizableIcon icon = View.getResizableIcon("update16"); JRibbonBand debugBand = new JRibbonBand("Debug", null); debugBand.setResizePolicies(getResizePolicies(debugBand)); - JCommandButton removeNonScriptsCommandButton = new JCommandButton(fixCommandTitle("Remove non scripts"), View.getResizableIcon("update16")); - assignListener(removeNonScriptsCommandButton, ACTION_REMOVE_NON_SCRIPTS); + JCommandButton removeNonScriptsCommandButton = new JCommandButton(fixCommandTitle("Remove non scripts"), icon); + removeNonScriptsCommandButton.addActionListener(e -> removeNonScripts()); - JCommandButton refreshDecompiledCommandButton = new JCommandButton(fixCommandTitle("Refresh decompiled script"), View.getResizableIcon("update16")); - assignListener(refreshDecompiledCommandButton, ACTION_REFRESH_DECOMPILED); + JCommandButton refreshDecompiledCommandButton = new JCommandButton(fixCommandTitle("Refresh decompiled script"), icon); + refreshDecompiledCommandButton.addActionListener(e -> refreshDecompiled()); - JCommandButton checkResourcesCommandButton = new JCommandButton(fixCommandTitle("Check resources"), View.getResizableIcon("update16")); - assignListener(checkResourcesCommandButton, ACTION_CHECK_RESOURCES); + JCommandButton checkResourcesCommandButton = new JCommandButton(fixCommandTitle("Check resources"), icon); + checkResourcesCommandButton.addActionListener(e -> checkResources()); + + JCommandButton callGcCommandButton = new JCommandButton(fixCommandTitle("Call System.gc()"), icon); + callGcCommandButton.addActionListener(e -> System.gc()); + + JCommandButton emptyCacheCommandButton = new JCommandButton(fixCommandTitle("Empty cache"), icon); + emptyCacheCommandButton.addActionListener(e -> { + SWF swf = mainFrame.getPanel().getCurrentSwf(); + if (swf != null) { + swf.clearAllCache(); + } + }); debugBand.addCommandButton(removeNonScriptsCommandButton, RibbonElementPriority.MEDIUM); debugBand.addCommandButton(refreshDecompiledCommandButton, RibbonElementPriority.MEDIUM); debugBand.addCommandButton(checkResourcesCommandButton, RibbonElementPriority.MEDIUM); + debugBand.addCommandButton(callGcCommandButton, RibbonElementPriority.MEDIUM); + debugBand.addCommandButton(emptyCacheCommandButton, RibbonElementPriority.MEDIUM); return new RibbonTask("Debug", debugBand); } @@ -1000,15 +1008,6 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener case ACTION_DEOBFUSCATE_ALL: deobfuscate(); break; - case ACTION_REMOVE_NON_SCRIPTS: - removeNonScripts(); - break; - case ACTION_REFRESH_DECOMPILED: - refreshDecompiled(); - break; - case ACTION_CHECK_RESOURCES: - checkResources(); - break; } } } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index 8a2fb95d2..6d054b086 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -326,3 +326,6 @@ config.description.autoSaveTagModifications = Save the changes when you select a config.name.saveSessionOnExit = Save session on exit config.description.saveSessionOnExit = Save the current session and reopens it after FFDec restart (works only with real files) + +config.name.showDebugMenu = Show debug menu +config.description.showDebugMenu = Shows debug menu in the ribbon 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 ddd543f54..67cb45024 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties @@ -323,3 +323,6 @@ config.description.autoSaveTagModifications = V\u00e1ltoz\u00e1sok ment\u00e9se config.name.saveSessionOnExit = Munkamenet ment\u00e9se kil\u00e9p\u00e9skor config.description.saveSessionOnExit = Elmenti az aktu\u00e1lis munkamenetet \u00e9s vissza\u00e1ll\u00edtja azt az FFDec \u00fajraind\u00edt\u00e1sa ut\u00e1n (csak igazi f\u00e1jlokkal m\u0171k\u00f6dik) + +config.name.showDebugMenu = Hibakeres\u00e9si men\u00fc mutat\u00e1sa +config.description.showDebugMenu = Hibakeres\u00e9si men\u00fc mutat\u00e1sa a szalagon diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 6f2004380..bae04f0ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -549,6 +549,7 @@ public class TagTreeContextMenu extends JPopupMenu implements ActionListener { Tag tag = (Tag) item; tag.undo(); tag.getSwf().clearAllCache(); + tagTree.getModel().updateNode(item); } catch (InterruptedException | IOException ex) { Logger.getLogger(TagTreeContextMenu.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java index 1c3a21878..a12e3bcb5 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeModel.java @@ -139,6 +139,11 @@ public class TagTreeModel implements TreeModel { fireTreeStructureChanged(new TreeModelEvent(this, changedPath)); } + public void updateNode(TreeItem treeItem) { + TreePath changedPath = getTreePath(treeItem); + fireTreeStructureChanged(new TreeModelEvent(this, changedPath)); + } + private void fireTreeNodesRemoved(TreeModelEvent e) { for (TreeModelListener listener : listeners) { listener.treeNodesRemoved(e); @@ -520,7 +525,7 @@ public class TagTreeModel implements TreeModel { return new ArrayList<>(); } - + @Override public TreeItem getChild(Object parent, int index) { TreeItem parentNode = (TreeItem) parent;