mirror of
https://bitbucket.org/projectswg/packet-master.git
synced 2026-01-16 23:04:26 -05:00
Getting close to having a scroll bar in the GUI
This commit is contained in:
@@ -44,6 +44,7 @@ public class PacketMaster {
|
||||
private String [] files;
|
||||
private PacketAnalysis packetAnalysis;
|
||||
private List <GUIPacket> packets;
|
||||
private InetAddress client;
|
||||
private int crc = 0x76FBC4BA;
|
||||
|
||||
public static final void main(String [] args) throws Exception {
|
||||
@@ -130,10 +131,11 @@ public class PacketMaster {
|
||||
return;
|
||||
if (port != REMOTE_PING_PORT) {
|
||||
if (data[0] == 0 && data[1] == 1) {
|
||||
System.out.println("Client: " + addr.toString());
|
||||
// System.out.println("Client: " + addr.toString());
|
||||
this.client = addr;
|
||||
packetAnalysis.setClient(addr);
|
||||
} else if (data[0] == 0 && data[1] == 2) { // SessionResponse
|
||||
System.out.println("Server: " + addr.toString());
|
||||
// System.out.println("Server: " + addr.toString());
|
||||
packetAnalysis.setServer(addr);
|
||||
processSessionResponse(data);
|
||||
} else {
|
||||
@@ -185,7 +187,7 @@ public class PacketMaster {
|
||||
data.position(0);
|
||||
SWGPacket packet = PacketType.getForCrc(opcode);
|
||||
packet.decode(data);
|
||||
packets.add(packet);
|
||||
packets.add(new GUIPacket(packet, PacketType.fromCrc(opcode), opcode, addr.equals(client)));
|
||||
gui.repaint();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class GUI extends JFrame {
|
||||
public void paint(Graphics g) {
|
||||
int maxWidth = getWidth() - getInsets().left - getInsets().right;
|
||||
int maxHeight = getHeight() - getInsets().top - getInsets().bottom;
|
||||
packetFrame.setBounds(0, 0, packetFrame.getDesiredWidth(maxWidth), maxHeight);
|
||||
packetFrame.setBounds(0, 0, packetFrame.getDesiredWidth(maxWidth), packetFrame.getDesiredHeight());
|
||||
analysisFrame.setBounds(packetFrame.getWidth(), 0, analysisFrame.getDesiredWidth(maxWidth), maxHeight);
|
||||
packetFrame.setPackets(packets);
|
||||
super.paint(g);
|
||||
|
||||
@@ -11,7 +11,14 @@ public class GUIPacket {
|
||||
private boolean client;
|
||||
|
||||
public GUIPacket() {
|
||||
|
||||
this(null, null, 0, false);
|
||||
}
|
||||
|
||||
public GUIPacket(SWGPacket packet, PacketType type, int swgOpcode, boolean client) {
|
||||
this.packet = packet;
|
||||
this.type = type;
|
||||
this.swgOpcode = swgOpcode;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public void setPacket(SWGPacket packet, PacketType type) { this.packet = packet; this.type = type; }
|
||||
|
||||
@@ -7,20 +7,21 @@ import java.util.List;
|
||||
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.swgnge.network.packets.swg.SWGPacket;
|
||||
|
||||
public class PacketFrame extends JLayeredPane {
|
||||
public class PacketFrame extends JScrollPane {
|
||||
|
||||
private static final long serialVersionUID = -8556958984246755647L;
|
||||
|
||||
private List <SWGPacket> packets = null;
|
||||
private List <GUIPacket> packets = null;
|
||||
|
||||
public PacketFrame() {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void setPackets(List <SWGPacket> packets) {
|
||||
public void setPackets(List <GUIPacket> packets) {
|
||||
this.packets = packets;
|
||||
}
|
||||
|
||||
@@ -29,10 +30,10 @@ public class PacketFrame extends JLayeredPane {
|
||||
super.paint(g);
|
||||
Rectangle b = getBounds();
|
||||
g.drawRect(0, 0, (int)b.getWidth()-1, (int)b.getHeight()-1);
|
||||
List <SWGPacket> packets = new ArrayList<SWGPacket>(this.packets);
|
||||
List <GUIPacket> packets = new ArrayList<GUIPacket>(this.packets);
|
||||
for (int i = 0; i < packets.size(); i++) {
|
||||
g.drawRect(0, i*30, (int)b.getWidth()-1, (i+1)*30);
|
||||
g.drawString(packets.get(i).getClass().getSimpleName(), 5, i*30+20);
|
||||
g.drawString(packets.get(i).getPacket().getClass().getSimpleName(), 5, i*30+20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +45,10 @@ public class PacketFrame extends JLayeredPane {
|
||||
return maxWidth/4;
|
||||
}
|
||||
|
||||
public int getDesiredHeight() {
|
||||
if (packets == null)
|
||||
return 0;
|
||||
return packets.size()*30;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user