Merge pull request #13 from XePeleato/development

Fixes and improvements from the TODO list
This commit is contained in:
ArachisH 2018-12-31 15:02:59 -08:00 committed by GitHub
commit 754fd9897d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 17 deletions

View File

@ -25,19 +25,32 @@ public class Injection extends SubForm {
}
private void updateUI() {
HPacket packet = new HPacket(inputPacket.getText());
if (!packet.isCorrupted()) {
boolean dirty = false;
String[] rawPackets = inputPacket.getText().split("\n");
HPacket[] packets = new HPacket[rawPackets.length];
lbl_corrruption.setText("isCorrupted: False");
lbl_corrruption.setFill(Paint.valueOf("Green"));
lbl_pcktInfo.setText("header (id:"+packet.headerId()+", length:"+packet.length()+")");
for (int i = 0; i < packets.length; i++) {
packets[i] = new HPacket(rawPackets[i]);
if (packets[i].isCorrupted()) {
if (!dirty) {
lbl_corrruption.setText("isCorrupted: True -> " + i);
lbl_corrruption.setFill(Paint.valueOf("#ee0404b2"));
dirty = true;
} else
lbl_corrruption.setText(lbl_corrruption.getText() + ", " + i);
}
}
if (!dirty) {
btn_sendToClient.setDisable(getHConnection().getState() != HConnection.State.CONNECTED);
btn_sendToServer.setDisable(getHConnection().getState() != HConnection.State.CONNECTED);
}
else {
lbl_corrruption.setText("isCorrupted: True");
lbl_corrruption.setFill(Paint.valueOf("#ee0404b2"));
lbl_pcktInfo.setText("header (id:NULL, length:"+packet.getBytesLength()+")");
lbl_pcktInfo.setText("header (id:" + packets[packets.length - 1].headerId() + ", length:" +
packets[packets.length - 1].length() + ")");
} else {
lbl_pcktInfo.setText("header (id:NULL, length:" + packets[packets.length - 1].getBytesLength()+")");
btn_sendToClient.setDisable(true);
btn_sendToServer.setDisable(true);
@ -46,14 +59,20 @@ public class Injection extends SubForm {
}
public void sendToServer_clicked(ActionEvent actionEvent) {
HPacket packet = new HPacket(inputPacket.getText());
String[] rawPackets = inputPacket.getText().split("\n");
for (String rawPacket : rawPackets) {
HPacket packet = new HPacket(rawPacket);
getHConnection().sendToServerAsync(packet);
writeToLog(Color.BLUE, "SS -> packet with id: " + packet.headerId());
}
}
public void sendToClient_clicked(ActionEvent actionEvent) {
HPacket packet = new HPacket(inputPacket.getText());
String[] rawPackets = inputPacket.getText().split("\n");
for (String rawPacket : rawPackets) {
HPacket packet = new HPacket(rawPacket);
getHConnection().sendToClientAsync(packet);
writeToLog(Color.RED, "CS -> packet with id: " + packet.headerId());
}
}
}

View File

@ -2,6 +2,7 @@ package gearth.ui.logger.loggerdisplays.uilogger;
import gearth.protocol.HPacket;
import gearth.ui.logger.loggerdisplays.PacketLogger;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
@ -38,6 +39,8 @@ public class UiLogger implements PacketLogger {
Scene scene = new Scene(root);
scene.getStylesheets().add("/gearth/ui/bootstrap3.css");
scene.getStylesheets().add("/gearth/ui/logger/uilogger/logger.css");
UiLoggerController controller = (UiLoggerController) loader.getController();
controller.setStage(stage);
// scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
// final KeyCombination keyCombIncoming = new KeyCodeCombination(KeyCode.I,

View File

@ -12,6 +12,7 @@ import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.StyleClassedTextArea;
import org.fxmisc.richtext.model.StyleSpansBuilder;
@ -36,6 +37,8 @@ public class UiLoggerController implements Initializable {
private StyleClassedTextArea area;
private Stage stage;
private boolean viewIncoming = true;
private boolean viewOutgoing = true;
private boolean displayStructure = true;
@ -43,6 +46,7 @@ public class UiLoggerController implements Initializable {
private boolean skiphugepackets = true;
private boolean viewMessageName = true;
private boolean viewMessageHash = false;
private boolean alwaysOnTop = false;
private volatile boolean initialized = false;
private final List<Element> appendLater = new ArrayList<>();
@ -181,6 +185,10 @@ public class UiLoggerController implements Initializable {
});
}
public void setStage(Stage stage) {
this.stage = stage;
}
public void toggleViewIncoming() {
viewIncoming = !viewIncoming;
lblViewIncoming.setText("View Incoming: " + (viewIncoming ? "True" : "False"));
@ -214,4 +222,13 @@ public class UiLoggerController implements Initializable {
public void toggleMessageHash(ActionEvent actionEvent) {
viewMessageHash = !viewMessageHash;
}
public void toggleAlwaysOnTop(ActionEvent actionEvent) {
stage.setAlwaysOnTop(!alwaysOnTop);
alwaysOnTop = !alwaysOnTop;
}
public void clearText(ActionEvent actionEvent) {
area.clear();
}
}

View File

@ -9,6 +9,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.text.TextFlow?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="gearth.ui.injection.Injection">

View File

@ -9,7 +9,7 @@
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.FlowPane?>
<BorderPane fx:id="borderPane" prefHeight="560.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.logger.loggerdisplays.uilogger.UiLoggerController">
<BorderPane fx:id="borderPane" prefHeight="560.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.logger.loggerdisplays.uilogger.UiLoggerController">
<top>
<MenuBar BorderPane.alignment="CENTER">
<Menu mnemonicParsing="false" text="View">
@ -33,6 +33,11 @@
<KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></CheckMenuItem>
<CheckMenuItem fx:id="chkSkipBigPackets" mnemonicParsing="false" onAction="#toggleSkipPackets" selected="true" text="Skip big packets" />
<CheckMenuItem fx:id="chkAlwaysOnTop" mnemonicParsing="false" onAction="#toggleAlwaysOnTop" text="Always on top" />
<CheckMenuItem fx:id="chkClearText" mnemonicParsing="false" onAction="#clearText" text="Clear text">
<accelerator>
<KeyCodeCombination alt="UP" code="E" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></CheckMenuItem>
</Menu>
</MenuBar>
</top>