From ef138b284fb53aa0ee07ddbcd3957f8aba75fbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Mon, 8 Jul 2013 20:57:11 +0200 Subject: [PATCH] Issue #176 Option to show main document class on swf open --- .../jpexs/decompiler/flash/gui/MainFrame.java | 56 ++++++++++++------- .../flash/gui/resources/MainFrame.properties | 1 + .../gui/resources/MainFrame_cs.properties | 1 + 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index effd45db9..bc7e90c7d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -27,7 +27,6 @@ import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; -import static com.jpexs.decompiler.flash.gui.Main.isAddedToContextMenu; import com.jpexs.decompiler.flash.gui.abc.ABCPanel; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; @@ -226,6 +225,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection private JCheckBoxMenuItem miAssociate; private JCheckBoxMenuItem miDecompile; private JCheckBoxMenuItem miCacheDisk; + private JCheckBoxMenuItem miGotoMainClassOnStartup; public void setPercent(int percent) { progressBar.setValue(percent); @@ -490,18 +490,23 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection miCacheDisk.setActionCommand("CACHEONDISK"); miCacheDisk.addActionListener(this); + miGotoMainClassOnStartup = new JCheckBoxMenuItem(translate("menu.settings.gotoMainClassOnStartup")); + miGotoMainClassOnStartup.setSelected((Boolean) Configuration.getConfig("gotoMainClassOnStartup", Boolean.FALSE)); + miGotoMainClassOnStartup.setActionCommand("GOTODOCUMENTCLASSONSTARTUP"); + miGotoMainClassOnStartup.addActionListener(this); + JMenu menuSettings = new JMenu(translate("menu.settings")); menuSettings.add(autoDeobfuscateMenuItem); menuSettings.add(miInternalViewer); menuSettings.add(miParallelSpeedUp); menuSettings.add(miDecompile); menuSettings.add(miCacheDisk); - + menuSettings.add(miGotoMainClassOnStartup); miAssociate = new JCheckBoxMenuItem(translate("menu.settings.addtocontextmenu")); miAssociate.setActionCommand("ASSOCIATE"); miAssociate.addActionListener(this); - miAssociate.setState(isAddedToContextMenu()); + miAssociate.setState(Main.isAddedToContextMenu()); JMenuItem miLanguage = new JMenuItem(translate("menu.settings.language")); @@ -963,7 +968,6 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection //Opening files with drag&drop to main window enableDrop(true); - } public void enableDrop(boolean value) { @@ -1020,6 +1024,9 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection splitPos = splitPane2.getDividerLocation(); splitsInited = true; + if (miGotoMainClassOnStartup.isSelected()) { + gotoDocumentClass(); + } } }); @@ -1572,9 +1579,33 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection } } + public void gotoDocumentClass() { + String documentClass = null; + loopdc: + for (Tag t : swf.tags) { + if (t instanceof SymbolClassTag) { + SymbolClassTag sc = (SymbolClassTag) t; + for (int i = 0; i < sc.tagIDs.length; i++) { + if (sc.tagIDs[i] == 0) { + documentClass = sc.classNames[i]; + break loopdc; + } + } + } + } + if (documentClass != null) { + showDetail(DETAILCARDAS3NAVIGATOR); + showCard(CARDACTIONSCRIPTPANEL); + abcPanel.hilightScript(documentClass); + } + } + @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { + case "GOTODOCUMENTCLASSONSTARTUP": + Configuration.setConfig("gotoMainClassOnStartup", miGotoMainClassOnStartup.isSelected()); + break; case "CACHEONDISK": Configuration.setConfig("cacheOnDisk", miCacheDisk.isSelected()); if (miCacheDisk.isSelected()) { @@ -1618,22 +1649,7 @@ public class MainFrame extends AppFrame implements ActionListener, TreeSelection }, 500); //It takes some time registry change to apply break; case "GOTODOCUMENTCLASS": - String documentClass = null; - loopdc: - for (Tag t : swf.tags) { - if (t instanceof SymbolClassTag) { - SymbolClassTag sc = (SymbolClassTag) t; - for (int i = 0; i < sc.tagIDs.length; i++) { - if (sc.tagIDs[i] == 0) { - documentClass = sc.classNames[i]; - break loopdc; - } - } - } - } - if (documentClass != null) { - abcPanel.hilightScript(documentClass); - } + gotoDocumentClass(); break; case "PARALLELSPEEDUP": String confStr = translate("message.confirm.parallel") + "\r\n"; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame.properties b/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame.properties index 45c384c5c..906c24546 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame.properties @@ -40,6 +40,7 @@ menu.settings.disabledecompilation = Disable decompilation (Disassemble only) menu.settings.addtocontextmenu = Add FFDec to SWF files context menu menu.settings.language = Change language menu.settings.cacheOnDisk = Use caching on disk +menu.settings.gotoMainClassOnStartup = Hilight document class on startup menu.help = Help menu.help.checkupdates = Check for updates... diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame_cs.properties b/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame_cs.properties index 550a8cab2..291461ed2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame_cs.properties +++ b/trunk/src/com/jpexs/decompiler/flash/gui/resources/MainFrame_cs.properties @@ -41,6 +41,7 @@ menu.settings.disabledecompilation = Zak\u00e1zat dekompilaci (Pouze P-k\u00f3d) menu.settings.addtocontextmenu = P\u0159idat FFDec do kontextov\u00e9ho menu SWF menu.settings.language = Zm\u011bnit jazyk menu.settings.cacheOnDisk = Pou\u017e\u00edvat cache na disku +menu.settings.gotoMainClassOnStartup = Zv\u00fdraznit hlavn\u00ed t\u0159\u00eddu po startu menu.help = N\u00e1pov\u011bda menu.help.checkupdates = Zkontrolovat novou verzi...