update UI

This commit is contained in:
sirjonasxx 2020-12-24 23:46:52 +01:00
parent d5a3783a1d
commit 3ed0575e05
3 changed files with 70 additions and 19 deletions

View File

@ -98,7 +98,9 @@ public class ConnectionController extends SubForm {
txtfield_hotelversion.setText(getHConnection().getHotelVersion()); txtfield_hotelversion.setText(getHConnection().getHotelVersion());
btnConnect.setDisable(getHConnection().getState() == HState.PREPARING || getHConnection().getState() == HState.ABORTING); btnConnect.setDisable(getHConnection().getState() == HState.PREPARING || getHConnection().getState() == HState.ABORTING);
if (!cbx_autodetect.isSelected() && !btnConnect.isDisable()) {
if (!cbx_autodetect.isSelected() && !btnConnect.isDisable() && useFlash()) {
try { try {
int i = Integer.parseInt(inpPort.getEditor().getText()); int i = Integer.parseInt(inpPort.getEditor().getText());
btnConnect.setDisable(i < 0 || i >= 256 * 256); btnConnect.setDisable(i < 0 || i >= 256 * 256);
@ -110,6 +112,13 @@ public class ConnectionController extends SubForm {
inpHost.setDisable(getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected()); inpHost.setDisable(getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected());
inpPort.setDisable(getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected()); inpPort.setDisable(getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected());
cbx_autodetect.setDisable(!useFlash());
outHost.setDisable(!useFlash());
outPort.setDisable(!useFlash());
inpHost.setDisable(!useFlash() || getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected());
inpPort.setDisable(!useFlash() || getHConnection().getState() != HState.NOT_CONNECTED || cbx_autodetect.isSelected());
} }
public void onParentSet(){ public void onParentSet(){
@ -134,14 +143,15 @@ public class ConnectionController extends SubForm {
if (newState == HState.CONNECTED) { if (newState == HState.CONNECTED) {
lblState.setText("Connected"); lblState.setText("Connected");
outHost.setText(getHConnection().getDomain());
outPort.setText(getHConnection().getServerPort()+"");
} }
if (newState == HState.WAITING_FOR_CLIENT) { if (newState == HState.WAITING_FOR_CLIENT) {
lblState.setText("Waiting for connection"); lblState.setText("Waiting for connection");
} }
if (newState == HState.CONNECTED) { if (newState == HState.CONNECTED && useFlash()) {
outHost.setText(getHConnection().getDomain());
outPort.setText(getHConnection().getServerPort()+"");
JSONObject connectionSettings = new JSONObject(); JSONObject connectionSettings = new JSONObject();
connectionSettings.put(AUTODETECT_CACHE, cbx_autodetect.isSelected()); connectionSettings.put(AUTODETECT_CACHE, cbx_autodetect.isSelected());
connectionSettings.put(HOST_CACHE, inpHost.getEditor().getText()); connectionSettings.put(HOST_CACHE, inpHost.getEditor().getText());
@ -179,4 +189,11 @@ public class ConnectionController extends SubForm {
getHConnection().abort(); getHConnection().abort();
} }
public void changeClientMode() {
updateInputUI();
}
private boolean useFlash() {
return parentController.extraController.rd_flash.isSelected();
}
} }

View File

@ -10,12 +10,13 @@ import gearth.services.gpython.GPythonVersionUtils;
import gearth.ui.SubForm; import gearth.ui.SubForm;
import gearth.ui.info.InfoController; import gearth.ui.info.InfoController;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.FlowPane; import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.web.WebView;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
@ -29,6 +30,8 @@ public class ExtraController extends SubForm implements SocksConfiguration {
public static final String SOCKS_CACHE_KEY = "socks_config"; public static final String SOCKS_CACHE_KEY = "socks_config";
public static final String GPYTHON_CACHE_KEY = "use_gpython"; public static final String GPYTHON_CACHE_KEY = "use_gpython";
public static final String USE_UNITY_CLIENT_CACHE_KEY = "use_unity";
public static final String SOCKS_IP = "ip"; public static final String SOCKS_IP = "ip";
public static final String SOCKS_PORT = "port"; public static final String SOCKS_PORT = "port";
// public static final String IGNORE_ONCE = "ignore_once"; // public static final String IGNORE_ONCE = "ignore_once";
@ -52,9 +55,14 @@ public class ExtraController extends SubForm implements SocksConfiguration {
public GridPane grd_socksInfo; public GridPane grd_socksInfo;
public TextField txt_socksPort; public TextField txt_socksPort;
public TextField txt_socksIp; public TextField txt_socksIp;
// public CheckBox cbx_socksUseIfNeeded;
public ToggleGroup tgl_clientMode;
public RadioButton rd_unity;
public RadioButton rd_flash;
public void initialize() { public void initialize() {
tgl_clientMode.selectedToggleProperty().addListener(observable -> parentController.connectionController.changeClientMode());
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting")); url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
InfoController.activateHyperlink(url_troubleshooting); InfoController.activateHyperlink(url_troubleshooting);
@ -75,6 +83,11 @@ public class ExtraController extends SubForm implements SocksConfiguration {
cbx_gpython.setSelected(Cacher.getCacheContents().getBoolean(GPYTHON_CACHE_KEY)); cbx_gpython.setSelected(Cacher.getCacheContents().getBoolean(GPYTHON_CACHE_KEY));
} }
if (Cacher.getCacheContents().has(USE_UNITY_CLIENT_CACHE_KEY)) {
rd_unity.setSelected(Cacher.getCacheContents().getBoolean(USE_UNITY_CLIENT_CACHE_KEY));
rd_flash.setSelected(!Cacher.getCacheContents().getBoolean(USE_UNITY_CLIENT_CACHE_KEY));
}
cbx_debug.selectedProperty().addListener(observable -> HConnection.DEBUG = cbx_debug.isSelected()); cbx_debug.selectedProperty().addListener(observable -> HConnection.DEBUG = cbx_debug.isSelected());
cbx_disableDecryption.selectedProperty().addListener(observable -> HConnection.DECRYPTPACKETS = !cbx_disableDecryption.isSelected()); cbx_disableDecryption.selectedProperty().addListener(observable -> HConnection.DECRYPTPACKETS = !cbx_disableDecryption.isSelected());
@ -102,6 +115,7 @@ public class ExtraController extends SubForm implements SocksConfiguration {
protected void onExit() { protected void onExit() {
Cacher.put(NOTEPAD_CACHE_KEY, txtarea_notepad.getText()); Cacher.put(NOTEPAD_CACHE_KEY, txtarea_notepad.getText());
Cacher.put(GPYTHON_CACHE_KEY, cbx_gpython.isSelected()); Cacher.put(GPYTHON_CACHE_KEY, cbx_gpython.isSelected());
Cacher.put(USE_UNITY_CLIENT_CACHE_KEY, rd_unity.isSelected());
saveSocksConfig(); saveSocksConfig();
} }

View File

@ -4,7 +4,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.extra.ExtraController"> <GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.extra.ExtraController">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" /> <ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" />
@ -28,31 +28,31 @@
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="7.0" minHeight="7.0" prefHeight="7.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="7.0" minHeight="7.0" prefHeight="7.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" prefHeight="232.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" prefHeight="232.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<GridPane fx:id="grd_advanced" disable="true" style="-fx-border-color: #888888; -fx-border-radius: 5px;" GridPane.rowIndex="3"> <GridPane fx:id="grd_advanced" disable="true" prefHeight="161.0" prefWidth="299.0" style="-fx-border-color: #888888; -fx-border-radius: 5px;" GridPane.rowIndex="4">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="60.0" minHeight="60.0" prefHeight="60.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="60.0" minHeight="60.0" prefHeight="60.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="6.0" prefHeight="15.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<GridPane.margin> <GridPane.margin>
<Insets bottom="12.0" left="10.0" right="10.0" /> <Insets bottom="5.0" left="10.0" right="10.0" top="6.0" />
</GridPane.margin> </GridPane.margin>
<padding> <padding>
<Insets bottom="4.0" left="7.0" top="7.0" /> <Insets left="7.0" top="3.0" />
</padding> </padding>
<children> <children>
<CheckBox fx:id="cbx_useSocks" mnemonicParsing="false" text="Use SOCKS proxy" /> <CheckBox fx:id="cbx_useSocks" mnemonicParsing="false" text="Use SOCKS proxy" />
<CheckBox fx:id="cbx_disableDecryption" mnemonicParsing="false" text="Disable decryption" GridPane.rowIndex="3" /> <CheckBox fx:id="cbx_disableDecryption" mnemonicParsing="false" text="Disable decryption" GridPane.rowIndex="2" />
<CheckBox fx:id="cbx_debug" mnemonicParsing="false" text="Debug to stdout" GridPane.rowIndex="4" /> <CheckBox fx:id="cbx_debug" mnemonicParsing="false" text="Debug to stdout" GridPane.rowIndex="3" />
<GridPane fx:id="grd_socksInfo" disable="true" prefHeight="54.0" prefWidth="81.0" GridPane.rowIndex="1"> <GridPane fx:id="grd_socksInfo" disable="true" prefHeight="54.0" prefWidth="81.0" GridPane.rowIndex="1">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
@ -104,7 +104,7 @@
</GridPane> </GridPane>
</children> </children>
</GridPane> </GridPane>
<CheckBox fx:id="cbx_advanced" mnemonicParsing="false" text="Advanced" textFill="#000000ba" GridPane.rowIndex="2"> <CheckBox fx:id="cbx_advanced" mnemonicParsing="false" text="Advanced" textFill="#000000ba" GridPane.rowIndex="3">
<GridPane.margin> <GridPane.margin>
<Insets left="10.0" top="2.0" /> <Insets left="10.0" top="2.0" />
</GridPane.margin> </GridPane.margin>
@ -112,11 +112,31 @@
<Insets top="2.0" /> <Insets top="2.0" />
</padding> </padding>
</CheckBox> </CheckBox>
<CheckBox fx:id="cbx_gpython" mnemonicParsing="false" onAction="#gpythonCbxClick" text="Enable G-Python scripting" textFill="#000000ba" GridPane.rowIndex="1"> <CheckBox fx:id="cbx_gpython" mnemonicParsing="false" onAction="#gpythonCbxClick" text="Enable G-Python scripting" textFill="#000000ba" GridPane.rowIndex="2">
<GridPane.margin> <GridPane.margin>
<Insets left="10.0" top="2.0" /> <Insets left="10.0" top="2.0" />
</GridPane.margin> </GridPane.margin>
</CheckBox> </CheckBox>
<GridPane GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="149.0" minWidth="10.0" prefWidth="67.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="242.0" minWidth="10.0" prefWidth="242.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<RadioButton fx:id="rd_unity" mnemonicParsing="false" selected="true" text="Unity">
<toggleGroup>
<ToggleGroup fx:id="tgl_clientMode" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="rd_flash" mnemonicParsing="false" text="Flash" toggleGroup="$tgl_clientMode" GridPane.columnIndex="1" />
</children>
<GridPane.margin>
<Insets bottom="2.0" left="10.0" top="2.0" />
</GridPane.margin>
</GridPane>
</children> </children>
<GridPane.margin> <GridPane.margin>
<Insets /> <Insets />