diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 803cc2592..32017a0fb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -918,7 +918,7 @@ public class AVM2Code implements Serializable { boolean markOffsets = code.size() <= largeLimit; if (exportMode == ExportMode.HEX) { - Helper.byteArrayToHex(writer, getBytes()); + Helper.byteArrayToHexWithHeader(writer, getBytes()); } else { for (AVM2Instruction ins : code) { if (exportMode == ExportMode.PCODEWITHHEX) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java new file mode 100644 index 000000000..f6f835c1a --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; +import com.jpexs.helpers.Helper; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JColorChooser; +import javax.swing.JPanel; + +public final class BinaryPanel extends JPanel implements ActionListener { + + public LineMarkedEditorPane hexEditor = new LineMarkedEditorPane(); + + public BinaryPanel() { + super(new BorderLayout()); + setOpaque(true); + setBackground(View.DEFAULT_BACKGROUND_COLOR); + add(hexEditor, BorderLayout.CENTER); + + JPanel bottomPanel = new JPanel(new BorderLayout()); + JPanel buttonsPanel = new JPanel(new FlowLayout()); + bottomPanel.add(buttonsPanel, BorderLayout.EAST); + add(bottomPanel, BorderLayout.SOUTH); + } + + @Override + public void actionPerformed(ActionEvent e) { + } + + public void setBinaryData(byte[] data) { + setBackground(View.swfBackgroundColor); + hexEditor.setEditable(false); + hexEditor.setText(Helper.byteArrayToHex(data, 32)); + //hexEditor.setContentType("text/plain"); //throws exception. why? + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java index ee03442af..7d3726a65 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -57,7 +57,7 @@ public class FontPanel extends JPanel implements ActionListener { static final String ACTION_FONT_EMBED = "FONTEMBED"; static final String ACTION_FONT_ADD_CHARS = "FONTADDCHARS"; - private MainFramePanel mainFramePanel; + private MainPanel mainPanel; public Map sourceFontsMap = new HashMap<>(); @@ -73,8 +73,8 @@ public class FontPanel extends JPanel implements ActionListener { private ComponentListener fontChangeList; private JComboBox fontSelection; - public FontPanel(MainFramePanel mainFramePanel) { - this.mainFramePanel = mainFramePanel; + public FontPanel(MainPanel mainPanel) { + this.mainPanel = mainPanel; createFontPanel(); } @@ -187,8 +187,8 @@ public class FontPanel extends JPanel implements ActionListener { fontSelection.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - if (mainFramePanel.oldTag instanceof FontTag) { - FontTag f = (FontTag) mainFramePanel.oldTag; + if (mainPanel.oldTag instanceof FontTag) { + FontTag f = (FontTag) mainPanel.oldTag; sourceFontsMap.put(f.getFontId(), (String) fontSelection.getSelectedItem()); } } @@ -211,11 +211,11 @@ public class FontPanel extends JPanel implements ActionListener { } private String translate(String key) { - return mainFramePanel.translate(key); + return mainPanel.translate(key); } private void fontAddChars(FontTag ft, Set selChars, String selFont) { - FontTag f = (FontTag) mainFramePanel.oldTag; + FontTag f = (FontTag) mainPanel.oldTag; SWF swf = ft.getSwf(); String oldchars = f.getCharacters(swf.tags); for (int ic : selChars) { @@ -266,7 +266,7 @@ public class FontPanel extends JPanel implements ActionListener { if (tag instanceof TextTag) { TextTag textTag = (TextTag) tag; String text = textTag.getFormattedText(textTag.getSwf().tags); - mainFramePanel.saveText(textTag, text); + mainPanel.saveText(textTag, text); } } } @@ -294,30 +294,30 @@ public class FontPanel extends JPanel implements ActionListener { public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { case ACTION_FONT_EMBED: - if (mainFramePanel.oldTag instanceof FontTag) { - FontEmbedDialog fed = new FontEmbedDialog(fontSelection.getSelectedItem().toString(), fontAddCharactersField.getText(), ((FontTag) mainFramePanel.oldTag).getFontStyle()); + if (mainPanel.oldTag instanceof FontTag) { + FontEmbedDialog fed = new FontEmbedDialog(fontSelection.getSelectedItem().toString(), fontAddCharactersField.getText(), ((FontTag) mainPanel.oldTag).getFontStyle()); if (fed.display()) { Set selChars = fed.getSelectedChars(); if (!selChars.isEmpty()) { String selFont = fed.getSelectedFont(); fontSelection.setSelectedItem(selFont); - fontAddChars((FontTag) mainFramePanel.oldTag, selChars, selFont); + fontAddChars((FontTag) mainPanel.oldTag, selChars, selFont); fontAddCharactersField.setText(""); - mainFramePanel.reload(true); + mainPanel.reload(true); } } } break; case ACTION_FONT_ADD_CHARS: String newchars = fontAddCharactersField.getText(); - if (mainFramePanel.oldTag instanceof FontTag) { + if (mainPanel.oldTag instanceof FontTag) { Set selChars = new TreeSet<>(); for (int c = 0; c < newchars.length(); c++) { selChars.add(newchars.codePointAt(c)); } - fontAddChars((FontTag) mainFramePanel.oldTag, selChars, fontSelection.getSelectedItem().toString()); + fontAddChars((FontTag) mainPanel.oldTag, selChars, fontSelection.getSelectedItem().toString()); fontAddCharactersField.setText(""); - mainFramePanel.reload(true); + mainPanel.reload(true); } break; } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 2dece4258..7c983ab75 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -24,7 +24,7 @@ public interface MainFrame { public void setTitle(String string); public String translate(String key); - public MainFramePanel getPanel(); + public MainPanel getPanel(); public boolean isVisible(); public void setVisible(boolean b); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java index e8783fb4d..6be7ca1d6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameClassic.java @@ -33,7 +33,7 @@ import javax.swing.JFrame; */ public final class MainFrameClassic extends AppFrame implements MainFrame { - public MainFramePanel panel; + public MainPanel panel; private MainFrameMenu mainMenu; public MainFrameClassic() { @@ -48,7 +48,7 @@ public final class MainFrameClassic extends AppFrame implements MainFrame { boolean externalFlashPlayerUnavailable = flashPanel == null; mainMenu = new MainFrameClassicMenu(this, externalFlashPlayerUnavailable); - panel = new MainFramePanel(this, mainMenu, flashPanel); + panel = new MainPanel(this, mainMenu, flashPanel); int w = Configuration.guiWindowWidth.get(); int h = Configuration.guiWindowHeight.get(); @@ -130,7 +130,7 @@ public final class MainFrameClassic extends AppFrame implements MainFrame { } @Override - public MainFramePanel getPanel() { + public MainPanel getPanel() { return panel; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index e9b4469b7..9236c8a9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -48,7 +48,7 @@ import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationM */ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { - public MainFramePanel panel; + public MainPanel panel; private MainFrameMenu mainMenu; public MainFrameRibbon() { @@ -68,7 +68,7 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { boolean externalFlashPlayerUnavailable = flashPanel == null; mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable); - panel = new MainFramePanel(this, mainMenu, flashPanel); + panel = new MainPanel(this, mainMenu, flashPanel); panel.setBackground(Color.yellow); cnt.add(panel, BorderLayout.CENTER); @@ -230,7 +230,7 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame { } @Override - public MainFramePanel getPanel() { + public MainPanel getPanel() { return panel; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java index 6ad0aebad..bcf431b9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameStatusPanel.java @@ -39,7 +39,7 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener { static final String ACTION_SHOW_ERROR_LOG = "SHOWERRORLOG"; - private MainFramePanel mainFramePanel; + private MainPanel mainPanel; private LoadingPanel loadingPanel = new LoadingPanel(20, 20); private JLabel statusLabel = new JLabel(""); @@ -51,8 +51,8 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener { private CancellableWorker currentWorker; - public MainFrameStatusPanel(MainFramePanel mainFramePanel) { - this.mainFramePanel = mainFramePanel; + public MainFrameStatusPanel(MainPanel mainPanel) { + this.mainPanel = mainPanel; createStatusPanel(); } @@ -108,7 +108,7 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener { } private String translate(String key) { - return mainFramePanel.translate(key); + return mainPanel.translate(key); } public void setStatus(String s) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFramePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java similarity index 95% rename from trunk/src/com/jpexs/decompiler/flash/gui/MainFramePanel.java rename to trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 3c781c6d3..db67f5921 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFramePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -191,7 +191,7 @@ import javax.swing.tree.TreeSelectionModel; * * @author JPEXS */ -public final class MainFramePanel extends JPanel implements ActionListener, TreeSelectionListener, Freed { +public final class MainPanel extends JPanel implements ActionListener, TreeSelectionListener, Freed { private MainFrame mainFrame; private List swfs; @@ -208,6 +208,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree private JPanel contentPanel; private JPanel displayPanel; private ImagePanel imagePanel; + private BinaryPanel binaryPanel; private ImagePanel previewImagePanel; private SWFPreviwPanel swfPreviewPanel; private boolean isWelcomeScreen = true; @@ -215,6 +216,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree private static final String CARDSWFPREVIEWPANEL = "SWF card"; private static final String CARDDRAWPREVIEWPANEL = "Draw card"; private static final String CARDIMAGEPANEL = "Image card"; + private static final String CARDBINARYPANEL = "Binary card"; private static final String CARDEMPTYPANEL = "Empty card"; private static final String CARDACTIONSCRIPTPANEL = "ActionScript card"; private static final String CARDACTIONSCRIPT3PANEL = "ActionScript3 card"; @@ -241,6 +243,8 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree private JSplitPane previewSplitPane; private JButton imageReplaceButton; private JPanel imageButtonsPanel; + private JButton binaryReplaceButton; + private JPanel binaryButtonsPanel; private PlayerControls flashControls; private ImagePanel internelViewerPanel; private JPanel viewerCards; @@ -274,7 +278,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree try { File.createTempFile("temp", ".swf").delete(); //First call to this is slow, so make it first } catch (IOException ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex); } } @@ -434,6 +438,22 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree return imagesCard; } + private JPanel createBinaryCard() { + JPanel binaryCard = new JPanel(new BorderLayout()); + binaryPanel = new BinaryPanel(); + binaryCard.add(binaryPanel, BorderLayout.CENTER); + + binaryReplaceButton = new JButton(translate("button.replace"), View.getIcon("edit16")); + binaryReplaceButton.setMargin(new Insets(3, 3, 3, 10)); + binaryReplaceButton.setActionCommand(ACTION_REPLACE_BINARY); + binaryReplaceButton.addActionListener(this); + binaryButtonsPanel = new JPanel(new FlowLayout()); + binaryButtonsPanel.add(binaryReplaceButton); + + binaryCard.add(binaryButtonsPanel, BorderLayout.SOUTH); + return binaryCard; + } + private void showHideImageReplaceButton(boolean show) { imageReplaceButton.setVisible(show); setImageButtonPanelVisibility(); @@ -450,7 +470,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree return mainFrame.translate(key); } - public MainFramePanel(MainFrame mainFrame, MainFrameMenu mainMenu, FlashPlayerPanel flashPanel) { + public MainPanel(MainFrame mainFrame, MainFrameMenu mainMenu, FlashPlayerPanel flashPanel) { super(); this.mainFrame = mainFrame; @@ -727,6 +747,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree displayPanel.add(previewSplitPane, CARDFLASHPANEL); displayPanel.add(createImagesCard(), CARDIMAGEPANEL); + displayPanel.add(createBinaryCard(), CARDBINARYPANEL); JPanel shapesCard = new JPanel(new BorderLayout()); @@ -897,7 +918,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree } updateClassesList(); } catch (InterruptedException ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex); } } @@ -1054,7 +1075,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree actionPanel.initSplits(); } - final MainFramePanel t = this; + final MainPanel t = this; SwingUtilities.invokeLater(new Runnable() { @Override @@ -1636,7 +1657,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree try { renameIdentifier(swf, identifier); } catch (InterruptedException ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex); } return null; } @@ -1761,7 +1782,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree swf.exportActionScript(errorHandler, selFile, exportMode, Configuration.parallelSpeedUp.get()); } } catch (Exception ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, "Error during export", ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Error during export", ex); View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage()); } return null; @@ -1856,7 +1877,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree updateClassesList(); reload(true); } catch (Exception ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, "Error during renaming identifiers", ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Error during renaming identifiers", ex); Main.stopWork(); View.showMessageDialog(null, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); } @@ -1906,7 +1927,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abcPanel.abc, t); } } catch (Exception ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, "Deobfuscation error", ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Deobfuscation error", ex); } return true; } @@ -2030,7 +2051,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree it.setImage(data); it.getSwf().clearImageCache(); } catch (IOException ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, "Invalid image", ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Invalid image", ex); View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } reload(true); @@ -2301,7 +2322,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree swf.saveTo(new BufferedOutputStream(new FileOutputStream(tempFile))); flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, swf.frameRate); } catch (IOException iex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, "Cannot create tempfile", iex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, "Cannot create tempfile", iex); } } } @@ -2311,7 +2332,9 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree } else if ((tagObj instanceof DefineSoundTag) || (tagObj instanceof SoundStreamHeadTag) || (tagObj instanceof SoundStreamHead2Tag)) { showCard(CARDEMPTYPANEL); } */ else if (tagObj instanceof DefineBinaryDataTag) { - showCard(CARDEMPTYPANEL); + DefineBinaryDataTag binaryTag = (DefineBinaryDataTag) tagObj; + showCard(CARDBINARYPANEL); + binaryPanel.setBinaryData(binaryTag.binaryData); } else if (tagObj instanceof ASMSource) { showCard(CARDACTIONSCRIPTPANEL); actionPanel.setSource((ASMSource) tagObj, !forceReload); @@ -2740,7 +2763,7 @@ public final class MainFramePanel extends JPanel implements ActionListener, Tree flashPanel.displaySWF(tempFile.getAbsolutePath(), backgroundColor, frameRate); } } catch (IOException | com.jpexs.decompiler.flash.action.parser.ParseException ex) { - Logger.getLogger(MainFramePanel.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 0b4dcaf18..888aa2fbc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -72,7 +72,7 @@ public class TagTreeModel implements TreeModel { List ret = new ArrayList<>(); int frameCnt = 0; for (ContainerItem o : list) { - TagType ttype = MainFramePanel.getTagType(o); + TagType ttype = MainPanel.getTagType(o); if (ttype == TagType.SHOW_FRAME && type == TagType.FRAME) { frameCnt++; ret.add(new TagNode(new FrameNode(o.getSwf(), frameCnt, parent, display), o.getSwf())); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 509940f58..a9ef7819e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -39,7 +39,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.Main; -import com.jpexs.decompiler.flash.gui.MainFramePanel; +import com.jpexs.decompiler.flash.gui.MainPanel; import com.jpexs.decompiler.flash.gui.MyTextField; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; @@ -80,7 +80,7 @@ import jsyntaxpane.actions.DocumentSearchData; public class ABCPanel extends JPanel implements ItemListener, ActionListener, Freed { - private MainFramePanel mainFramePanel; + private MainPanel mainPanel; public TraitsList navigator; public ABC abc; public SWF swf; @@ -119,8 +119,8 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr if ((txt != null) && (!txt.isEmpty())) { searchIgnoreCase = ignoreCase; searchRegexp = regexp; - TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel(); - ClassesListTreeModel clModel = ttm.getSwfRoot(mainFramePanel.getCurrentSwf()).classTreeModel; + TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel(); + ClassesListTreeModel clModel = ttm.getSwfRoot(mainPanel.getCurrentSwf()).classTreeModel; List> allpacks = clModel.getList(); found = new ArrayList<>(); final Pattern pat = regexp ? @@ -331,10 +331,10 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } @SuppressWarnings("unchecked") - public ABCPanel(MainFramePanel mainFramePanel) { + public ABCPanel(MainPanel mainPanel) { DefaultSyntaxKit.initKit(); - this.mainFramePanel = mainFramePanel; + this.mainPanel = mainPanel; setLayout(new BorderLayout()); decompiledTextArea = new DecompiledEditorPane(this); @@ -529,7 +529,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } public void hilightScript(SWF swf, String name) { - TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel(); + TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel(); ClassesListTreeModel clModel = ttm.getSwfRoot(swf).classTreeModel; ScriptPack pack = null; for (MyEntry item : clModel.getList()) { @@ -544,13 +544,13 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Fr } public void hilightScript(ScriptPack pack) { - TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel(); + TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel(); final TreePath tp = ttm.getTagPath(pack); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - mainFramePanel.tagTree.setSelectionPath(tp); - mainFramePanel.tagTree.scrollPathToVisible(tp); + mainPanel.tagTree.setSelectionPath(tp); + mainPanel.tagTree.scrollPathToVisible(tp); } }); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 25e4a6b36..55d837f9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -93,7 +93,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi setContentType("text/plain"); if (textHexOnly == null) { HilightedTextWriter writer = new HilightedTextWriter(true); - Helper.byteArrayToHex(writer, abc.bodies[bodyIndex].code.getBytes()); + Helper.byteArrayToHexWithHeader(writer, abc.bodies[bodyIndex].code.getBytes()); textHexOnly = new HilightedText(writer); } setText(textHexOnly); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 0fa7666b7..bba8cd55f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -31,7 +31,7 @@ import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.HeaderLabel; import com.jpexs.decompiler.flash.gui.Main; -import com.jpexs.decompiler.flash.gui.MainFramePanel; +import com.jpexs.decompiler.flash.gui.MainPanel; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; @@ -93,7 +93,7 @@ public class ActionPanel extends JPanel implements ActionListener { static final String ACTION_EDIT_DECOMPILED = "EDITDECOMPILED"; static final String ACTION_CANCEL_DECOMPILED = "CANCELDECOMPILED"; - private MainFramePanel mainFramePanel; + private MainPanel mainPanel; public LineMarkedEditorPane editor; public LineMarkedEditorPane decompiledEditor; public JSplitPane splitPane; @@ -232,7 +232,7 @@ public class ActionPanel extends JPanel implements ActionListener { if ((txt != null) && (!txt.isEmpty())) { searchIgnoreCase = ignoreCase; searchRegexp = regexp; - List list = SWF.createASTagList(mainFramePanel.getCurrentSwf().tags, null); + List list = SWF.createASTagList(mainPanel.getCurrentSwf().tags, null); Map asms = getASMs("", list); found = new ArrayList<>(); Pattern pat = null; @@ -337,7 +337,7 @@ public class ActionPanel extends JPanel implements ActionListener { editor.setContentType("text/plain"); if (srcHexOnly == null) { HilightedTextWriter writer = new HilightedTextWriter(true); - Helper.byteArrayToHex(writer, src.getActionBytes()); + Helper.byteArrayToHexWithHeader(writer, src.getActionBytes()); srcHexOnly = new HilightedText(writer); } setText(srcHexOnly); @@ -435,9 +435,9 @@ public class ActionPanel extends JPanel implements ActionListener { public void hilightOffset(long offset) { } - public ActionPanel(MainFramePanel mainFramePanel) { + public ActionPanel(MainPanel mainPanel) { DefaultSyntaxKit.initKit(); - this.mainFramePanel = mainFramePanel; + this.mainPanel = mainPanel; editor = new LineMarkedEditorPane(); editor.setEditable(false); decompiledEditor = new LineMarkedEditorPane(); @@ -824,10 +824,10 @@ public class ActionPanel extends JPanel implements ActionListener { public void updateSearchPos() { searchPos.setText((foundPos + 1) + "/" + found.size()); setSource(found.get(foundPos), true); - TagTreeModel ttm = (TagTreeModel) mainFramePanel.tagTree.getModel(); + TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel(); TreePath tp = ttm.getTagPath(found.get(foundPos)); - mainFramePanel.tagTree.setSelectionPath(tp); - mainFramePanel.tagTree.scrollPathToVisible(tp); + mainPanel.tagTree.setSelectionPath(tp); + mainPanel.tagTree.scrollPathToVisible(tp); decompiledEditor.setCaretPosition(0); java.util.Timer t = new java.util.Timer(); SwingUtilities.invokeLater(new Runnable() { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 7c0fdc207..918158df5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -203,7 +203,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHex(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index 5bd47de6d..a10c29117 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -146,7 +146,7 @@ public class DoActionTag extends Tag implements ASMSource { @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHex(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes); } List listeners = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 316df3fd4..11dc9e73c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -156,7 +156,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHex(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index a2f0f7ff2..75f4d4a3b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -210,7 +210,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem { @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHex(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes); } List listeners = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index e6435e8f9..9f00b4d66 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -209,7 +209,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem { @Override public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { - return Helper.byteArrayToHex(writer, actionBytes); + return Helper.byteArrayToHexWithHeader(writer, actionBytes); } List listeners = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index f651ab95a..2d8a225d0 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -568,8 +568,12 @@ public class Helper { return timeStr; } - public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data) { - writer.appendNoHilight("#hexdata").newLine(); + public static GraphTextWriter byteArrayToHexWithHeader(GraphTextWriter writer, byte[] data) { + writer.appendNoHilight("#hexdata").newLine().newLine(); + return byteArrayToHex(writer, data, 8, 8); + } + + public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data, int bytesPerRow, int groupSize) { /* // hex data from decompiled actions Scanner scanner = new Scanner(srcWithHex); @@ -583,8 +587,12 @@ public class Helper { }*/ for (int i = 0; i < data.length; i++) { - if (i % 8 == 0) { - writer.newLine(); + if (i > 0) { + if (i % bytesPerRow == 0) { + writer.newLine(); + } else if (i % groupSize == 0) { + writer.appendNoHilight(" "); + } } writer.appendNoHilight(String.format("%02x ", data[i])); } @@ -593,9 +601,9 @@ public class Helper { return writer; } - public static String byteArrayToHex(byte[] data) { + public static String byteArrayToHex(byte[] data, int bytesPerRow) { HilightedTextWriter writer = new HilightedTextWriter(false); - byteArrayToHex(writer, data); + byteArrayToHex(writer, data, bytesPerRow, 8); return writer.toString(); }