diff --git a/src/com/jpexs/decompiler/flash/gui/HexView.java b/src/com/jpexs/decompiler/flash/gui/HexView.java index adc6ac243..633f670e5 100644 --- a/src/com/jpexs/decompiler/flash/gui/HexView.java +++ b/src/com/jpexs/decompiler/flash/gui/HexView.java @@ -51,19 +51,23 @@ public class HexView extends JTable { JLabel l = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); int level = -1; if (col > 0 && highlightStarts != null) { - int idx = row * bytesInRow + ((col > bytesInRow) ? (col - bytesInRow - 1) : (col - 1)); - for (int i = 0; i < highlightStarts.length; i++) { - if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) { - level++; - } else { - break; + if(col!=bytesInRow+1){ + int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1)); + for (int i = 0; i < highlightStarts.length; i++) { + if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) { + level++; + } else { + break; + } } } } if (level > -1) { + l.setForeground(Color.white); l.setBackground(highlightColors[level % highlightColors.length]); } else { + l.setForeground(Color.black); l.setBackground(row % 2 == 0 ? bgColor : bgColorAlternate); } @@ -94,7 +98,7 @@ public class HexView extends JTable { @Override public int getColumnCount() { - return 2 * bytesInRow + 1; + return 2 * bytesInRow + 1 + 1; } @Override @@ -117,8 +121,10 @@ public class HexView extends JTable { return String.format("%02X", data[pos]); } return null; + } else if (column == 1 + bytesInRow) { + return null; } else { - int pos = row * bytesInRow + column - bytesInRow - 1; + int pos = row * bytesInRow + column - bytesInRow - 1 - 1; if (pos < data.length) { return (char) data[pos]; } @@ -146,8 +152,12 @@ public class HexView extends JTable { column.setMaxWidth(25); column.setCellRenderer(cellRenderer); } + + column = columnModel.getColumn(bytesInRow + 1); + column.setMaxWidth(10); + for (int i = 0; i < bytesInRow; i++) { - column = columnModel.getColumn(i + bytesInRow + 1); + column = columnModel.getColumn(i + bytesInRow + 1 + 1); column.setMaxWidth(10); column.setCellRenderer(cellRenderer); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index 7ad39a49e..ab2d111ad 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -50,9 +50,12 @@ import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; +import org.pushingpixels.flamingo.api.common.AbstractCommandButton; import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState; +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.ribbon.JRibbon; import org.pushingpixels.flamingo.api.ribbon.JRibbonBand; import org.pushingpixels.flamingo.api.ribbon.JRibbonComponent; @@ -118,6 +121,8 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { static final String ACTION_REFRESH_DECOMPILED = "REFRESHDECOMPILED"; static final String ACTION_CLEAR_RECENT_FILES = "CLEARRECENTFILES"; static final String ACTION_CHECK_RESOURCES = "CHECKRESOURCES"; + static final String ACTION_VIEWMODE_RESOURCES = "VIEWMODERESOURCES"; + static final String ACTION_VIEWMODE_HEX = "VIEWMODEHEX"; private final MainFrameRibbon mainFrame; @@ -137,6 +142,8 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { private JCommandButton exportFlaCommandButton; private JCommandButton exportSelectionCommandButton; private JCommandButton importTextCommandButton; + private JCommandToggleButton viewModeResourcesToggleButton; + private JCommandToggleButton viewModeHexToggleButton; private JCommandButton reloadCommandButton; private JCommandButton renameinvalidCommandButton; @@ -177,7 +184,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { return mainFrame.translate(key); } - private void assignListener(JCommandButton b, final String command) { + private void assignListener(AbstractCommandButton b, final String command) { final MainFrameRibbonMenu t = this; b.addActionListener(new ActionListener() { @Override @@ -322,8 +329,33 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { assignListener(importTextCommandButton, ACTION_IMPORT_TEXT); importBand.addCommandButton(importTextCommandButton, RibbonElementPriority.TOP); + + + JRibbonBand viewBand = new JRibbonBand(translate("menu.view"), null); + viewBand.setResizePolicies(getResizePolicies(viewBand)); + + CommandToggleButtonGroup grp=new CommandToggleButtonGroup(); + + viewModeResourcesToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.view.resources")), View.getResizableIcon("viewresources16")); + assignListener(viewModeResourcesToggleButton, ACTION_VIEWMODE_RESOURCES); + + viewModeHexToggleButton = new JCommandToggleButton(fixCommandTitle(translate("menu.file.view.hex")), View.getResizableIcon("viewhex16")); + assignListener(viewModeHexToggleButton, ACTION_VIEWMODE_HEX); + + grp.add(viewModeResourcesToggleButton); + grp.add(viewModeHexToggleButton); + + if(Configuration.dumpView.get()){ + grp.setSelected(viewModeHexToggleButton, true); + }else{ + grp.setSelected(viewModeResourcesToggleButton, true); + } + + + viewBand.addCommandButton(viewModeResourcesToggleButton, RibbonElementPriority.MEDIUM); + viewBand.addCommandButton(viewModeHexToggleButton, RibbonElementPriority.MEDIUM); - return new RibbonTask(translate("menu.file"), editBand, exportBand, importBand); + return new RibbonTask(translate("menu.file"), editBand, exportBand, importBand, viewBand); } private RibbonTask createToolsRibbonTask() { @@ -427,10 +459,10 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { miAutoRenameIdentifiers.setActionCommand(ACTION_AUTO_RENAME_IDENTIFIERS); miAutoRenameIdentifiers.addActionListener(this); - miDumpView = new JCheckBox(translate("menu.settings.dumpView")); + /*miDumpView = new JCheckBox(translate("menu.settings.dumpView")); miDumpView.setSelected(Configuration.dumpView.get()); miDumpView.setActionCommand(ACTION_DUMP_VIEW_SWITCH); - miDumpView.addActionListener(this); + miDumpView.addActionListener(this);*/ settingsBand.addRibbonComponent(new JRibbonComponent(miAutoDeobfuscation)); settingsBand.addRibbonComponent(new JRibbonComponent(miInternalViewer)); @@ -442,7 +474,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { settingsBand.addRibbonComponent(new JRibbonComponent(miCacheDisk)); settingsBand.addRibbonComponent(new JRibbonComponent(miGotoMainClassOnStartup)); settingsBand.addRibbonComponent(new JRibbonComponent(miAutoRenameIdentifiers)); - settingsBand.addRibbonComponent(new JRibbonComponent(miDumpView)); + //settingsBand.addRibbonComponent(new JRibbonComponent(miDumpView)); JRibbonBand languageBand = new JRibbonBand(translate("menu.language"), null); List languageBandResizePolicies = getIconBandResizePolicies(languageBand); @@ -620,6 +652,15 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener { Configuration.internalFlashViewer.set(miInternalViewer.isSelected()); mainFrame.panel.reload(true); break; + + case ACTION_VIEWMODE_RESOURCES: + Configuration.dumpView.set(false); + mainFrame.panel.showDumpView(false); + break; + case ACTION_VIEWMODE_HEX: + Configuration.dumpView.set(true); + mainFrame.panel.showDumpView(true); + break; case ACTION_DUMP_VIEW_SWITCH: Configuration.dumpView.set(miDumpView.isSelected()); mainFrame.panel.showDumpView(miDumpView.isSelected()); diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png b/src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png new file mode 100644 index 000000000..f6b74cc40 Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/viewhex16.png differ diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/viewresources16.png b/src/com/jpexs/decompiler/flash/gui/graphics/viewresources16.png new file mode 100644 index 000000000..448e46fd5 Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/viewresources16.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 69f14c709..787fa0763 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -488,3 +488,7 @@ contextmenu.rawEdit = Raw edit contextmenu.jumpToCharacter = Jump to character menu.settings.dumpView = Dump view + +menu.view = View +menu.file.view.resources = Resources +menu.file.view.hex = Hex dump \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties index bd3dbc71c..521f267be 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties @@ -478,4 +478,8 @@ error.text.import = Chyba b\u011bhem importu textu. Chcete pokra\u010dovat? contextmenu.removeWithDependencies = Odstranit se z\u00e1vislostmi abc.action.find-usages = Naj\u00edt pou\u017eit\u00ed -abc.action.find-declaration = Naj\u00edt deklaraci \ No newline at end of file +abc.action.find-declaration = Naj\u00edt deklaraci + +menu.view = Zobrazen\u00ed +menu.file.view.resources = Zdroje +menu.file.view.hex = Hex dump \ No newline at end of file