mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 01:20:56 +00:00
dumpview fixes: negative byte values, node selecting
This commit is contained in:
@@ -2172,8 +2172,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
return;
|
||||
}
|
||||
|
||||
dumpViewPanel.setSelectedNode(dumpInfo);
|
||||
dumpViewPanel.revalidate();
|
||||
dumpViewPanel.setSelectedNode(dumpInfo);
|
||||
showCard(CARDDUMPVIEW);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ public class DumpViewPanel extends JPanel {
|
||||
private final HexView dumpViewHexTable;
|
||||
private final DumpTree dumpTree;
|
||||
private DumpInfo selectedDumpInfo;
|
||||
private boolean skipNextScroll;
|
||||
private boolean skipValueChange;
|
||||
|
||||
public DumpViewPanel(final DumpTree dumpTree) {
|
||||
super(new BorderLayout());
|
||||
@@ -55,13 +57,18 @@ public class DumpViewPanel extends JPanel {
|
||||
|
||||
dumpViewLabel = new JLabel();
|
||||
dumpViewLabel.setMinimumSize(new Dimension(100, 20));
|
||||
dumpViewLabel.setText("-");
|
||||
add(dumpViewLabel, BorderLayout.SOUTH);
|
||||
|
||||
dumpViewHexTable = new HexView();
|
||||
dumpViewHexTable.addListener(new HexViewListener() {
|
||||
|
||||
@Override
|
||||
public void byteMouseClicked(int address, byte b) {
|
||||
public void byteValueChanged(int address, byte b) {
|
||||
if (skipValueChange) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeModel model = dumpTree.getModel();
|
||||
DumpInfo di = DumpInfoSwfNode.getSwfNode(selectedDumpInfo);
|
||||
while (model.getChildCount(di) > 0) {
|
||||
@@ -86,17 +93,19 @@ public class DumpViewPanel extends JPanel {
|
||||
}
|
||||
path.add(0, model.getRoot());
|
||||
TreePath tp = new TreePath(path.toArray());
|
||||
skipNextScroll = true;
|
||||
dumpTree.setSelectionPath(tp);
|
||||
dumpTree.scrollPathToVisible(tp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void byteMouseMoved(int address, byte b) {
|
||||
int b2 = b & 0xff;
|
||||
selectedByteInfo.setText("Addr: " + Helper.padZeros(address, 8) +
|
||||
" Hex: " + Helper.padZeros(Integer.toHexString(b), 2) +
|
||||
" Dec: " + b +
|
||||
" Bin: " + Helper.padZeros(Integer.toBinaryString(b), 8) +
|
||||
" Ascii: " + (char) b);
|
||||
" Hex: " + Helper.padZeros(Integer.toHexString(b2), 2) +
|
||||
" Dec: " + b2 +
|
||||
" Bin: " + Helper.padZeros(Integer.toBinaryString(b2), 8) +
|
||||
" Ascii: " + (char) b2);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -105,6 +114,7 @@ public class DumpViewPanel extends JPanel {
|
||||
|
||||
public void setSelectedNode(DumpInfo dumpInfo) {
|
||||
if (this.selectedDumpInfo == dumpInfo) {
|
||||
skipNextScroll = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,12 +134,17 @@ public class DumpViewPanel extends JPanel {
|
||||
highlightEnds[i] = di2.getEndByte();
|
||||
}
|
||||
dumpViewHexTable.setData(data, highlightStarts, highlightEnds);
|
||||
dumpViewHexTable.revalidate();
|
||||
|
||||
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
|
||||
int selectionStart = (int) dumpInfo.startByte;
|
||||
int selectionEnd = (int) dumpInfo.getEndByte();
|
||||
|
||||
dumpViewHexTable.scrollToByte(highlightStarts, highlightEnds);
|
||||
if (!skipNextScroll) {
|
||||
skipValueChange = true;
|
||||
dumpViewHexTable.scrollToByte(highlightStarts, highlightEnds);
|
||||
skipValueChange = false;
|
||||
}
|
||||
|
||||
setLabelText("startByte: " + dumpInfo.startByte
|
||||
+ " startBit: " + dumpInfo.startBit
|
||||
@@ -139,6 +154,7 @@ public class DumpViewPanel extends JPanel {
|
||||
+ " selectionEnd: " + selectionEnd);
|
||||
}
|
||||
|
||||
skipNextScroll = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ public class HexView extends JTable {
|
||||
private int itsRow = 0;
|
||||
private int itsColumn = 0;
|
||||
private HexViewListener listener;
|
||||
private boolean disableScroll;
|
||||
|
||||
private class HighlightCellRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
@@ -112,10 +111,11 @@ public class HexView extends JTable {
|
||||
|
||||
if (col > 0 && highlightStarts != null && col != bytesInRow + 1) {
|
||||
int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
|
||||
if (listener != null) {
|
||||
disableScroll = true;
|
||||
listener.byteMouseClicked(idx, getModel().getData()[idx]);
|
||||
disableScroll = false;
|
||||
byte[] data = getModel().getData();
|
||||
if (idx < data.length) {
|
||||
if (listener != null) {
|
||||
listener.byteValueChanged(idx, data[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,9 +213,6 @@ public class HexView extends JTable {
|
||||
}
|
||||
|
||||
public void scrollToByte(long byteNum) {
|
||||
if (disableScroll) {
|
||||
return;
|
||||
}
|
||||
|
||||
int row = (int) (byteNum / bytesInRow);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.gui.hexview;
|
||||
*/
|
||||
public interface HexViewListener {
|
||||
|
||||
public void byteMouseClicked(int address, byte b);
|
||||
public void byteValueChanged(int address, byte b);
|
||||
|
||||
public void byteMouseMoved(int address, byte b);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class HexViewTableModel extends AbstractTableModel {
|
||||
} else {
|
||||
int pos = row * bytesInRow + column - bytesInRow - 1 - 1;
|
||||
if (pos < data.length) {
|
||||
return (char) data[pos];
|
||||
return (char) (data[pos] & 0xff);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user