This commit is contained in:
sirjonasxx 2021-02-12 00:13:51 +01:00
parent 8c4e02173a
commit c1188ab228
4 changed files with 90 additions and 69 deletions

View File

@ -3,11 +3,13 @@ package gearth.ui.connection;
import gearth.misc.Cacher; import gearth.misc.Cacher;
import gearth.protocol.connection.HState; import gearth.protocol.connection.HState;
import gearth.protocol.connection.proxy.ProxyProviderFactory; import gearth.protocol.connection.proxy.ProxyProviderFactory;
import gearth.services.Constants;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.control.*; import javafx.scene.control.*;
import gearth.protocol.HConnection; import gearth.protocol.HConnection;
import gearth.ui.SubForm; import gearth.ui.SubForm;
import javafx.scene.layout.GridPane;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
@ -35,7 +37,27 @@ public class ConnectionController extends SubForm {
private final Object lock = new Object(); private final Object lock = new Object();
private volatile int fullyInitialized = 0; private volatile int fullyInitialized = 0;
public static final String USE_UNITY_CLIENT_CACHE_KEY = "use_unity";
public ToggleGroup tgl_clientMode;
public RadioButton rd_unity;
public RadioButton rd_flash;
public GridPane grd_clientSelection;
public void initialize() { public void initialize() {
Constants.UNITY_PACKETS = rd_unity.isSelected();
tgl_clientMode.selectedToggleProperty().addListener(observable -> {
changeClientMode();
Constants.UNITY_PACKETS = rd_unity.isSelected();
});
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));
}
Object object; Object object;
String hostRemember = null; String hostRemember = null;
String portRemember = null; String portRemember = null;
@ -95,6 +117,7 @@ public class ConnectionController extends SubForm {
} }
private void updateInputUI() { private void updateInputUI() {
grd_clientSelection.setDisable(getHConnection().getState() != HState.NOT_CONNECTED);
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);
@ -193,6 +216,7 @@ public class ConnectionController extends SubForm {
@Override @Override
protected void onExit() { protected void onExit() {
Cacher.put(USE_UNITY_CLIENT_CACHE_KEY, rd_unity.isSelected());
getHConnection().abort(); getHConnection().abort();
} }
@ -201,6 +225,6 @@ public class ConnectionController extends SubForm {
} }
private boolean useFlash() { private boolean useFlash() {
return parentController.extraController.rd_flash.isSelected(); return rd_flash.isSelected();
} }
} }

View File

@ -30,8 +30,6 @@ 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";
@ -56,19 +54,7 @@ public class ExtraController extends SubForm implements SocksConfiguration {
public TextField txt_socksPort; public TextField txt_socksPort;
public TextField txt_socksIp; public TextField txt_socksIp;
public ToggleGroup tgl_clientMode;
public RadioButton rd_unity;
public RadioButton rd_flash;
public GridPane grd_clientSelection;
public void initialize() { public void initialize() {
Constants.UNITY_PACKETS = rd_unity.isSelected();
tgl_clientMode.selectedToggleProperty().addListener(observable -> {
if (parentController != null) parentController.connectionController.changeClientMode();
Constants.UNITY_PACKETS = rd_unity.isSelected();
});
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);
@ -88,11 +74,6 @@ 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());
@ -120,7 +101,6 @@ 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();
} }
@ -133,8 +113,6 @@ public class ExtraController extends SubForm implements SocksConfiguration {
} }
private void updateAdvancedUI() { private void updateAdvancedUI() {
grd_clientSelection.setDisable(getHConnection().getState() != HState.NOT_CONNECTED);
if (!cbx_advanced.isSelected()) { if (!cbx_advanced.isSelected()) {
cbx_debug.setSelected(false); cbx_debug.setSelected(false);
cbx_useSocks.setSelected(false); cbx_useSocks.setSelected(false);

View File

@ -5,13 +5,15 @@
<?import javafx.scene.control.CheckBox?> <?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?> <?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.ColumnConstraints?> <?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.connection.ConnectionController"> <GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.connection.ConnectionController">
<columnConstraints> <columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints> </columnConstraints>
@ -104,23 +106,24 @@
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="54.0" minHeight="10.0" prefHeight="39.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="74.0" minHeight="10.0" prefHeight="61.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<GridPane.margin> <GridPane.margin>
<Insets bottom="14.0" left="20.0" right="15.0" top="17.0" /> <Insets bottom="14.0" left="20.0" right="15.0" top="17.0" />
</GridPane.margin> </GridPane.margin>
<children> <children>
<GridPane> <GridPane GridPane.rowIndex="1">
<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="83.0" minHeight="10.0" prefHeight="26.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="83.0" minHeight="10.0" prefHeight="19.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="86.0" minHeight="10.0" prefHeight="33.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="86.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="Hotel version:" textFill="#000000cc" /> <Label text="Hotel version:" textFill="#000000cc" />
<TextField fx:id="txtfield_hotelversion" editable="false" GridPane.rowIndex="1"> <TextField fx:id="txtfield_hotelversion" editable="false" prefHeight="17.0" prefWidth="285.0" GridPane.rowIndex="1">
<opaqueInsets> <opaqueInsets>
<Insets /> <Insets />
</opaqueInsets> </opaqueInsets>
@ -130,10 +133,47 @@
</TextField> </TextField>
</children> </children>
<GridPane.margin> <GridPane.margin>
<Insets bottom="26.0" left="12.0" right="10.0" top="22.0" /> <Insets left="12.0" right="10.0" top="5.0" />
</GridPane.margin> </GridPane.margin>
</GridPane> </GridPane>
<GridPane fx:id="grd_clientSelection" prefHeight="26.0" prefWidth="286.0" style="-fx-border-color: #888888; -fx-border-width: 0 0 1 0;">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="149.0" minWidth="10.0" prefWidth="76.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="149.0" minWidth="10.0" prefWidth="25.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="177.0" minWidth="66.0" prefWidth="93.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="133.0" minWidth="8.0" prefWidth="98.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="242.0" minWidth="10.0" prefWidth="32.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="20.0" prefHeight="34.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Client type:">
<padding>
<Insets left="12.0" />
</padding>
</Label>
<RadioButton fx:id="rd_unity" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Unity" GridPane.columnIndex="3" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
<toggleGroup>
<ToggleGroup fx:id="tgl_clientMode" />
</toggleGroup>
<GridPane.margin>
<Insets />
</GridPane.margin>
</RadioButton>
<RadioButton fx:id="rd_flash" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="35.0" prefWidth="111.0" selected="true" text="Flash / Air" toggleGroup="$tgl_clientMode" GridPane.columnIndex="2">
<GridPane.margin>
<Insets />
</GridPane.margin></RadioButton>
</children>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
</GridPane>
</children> </children>
<padding>
<Insets bottom="5.0" />
</padding>
</GridPane> </GridPane>
</GridPane> </GridPane>
<GridPane alignment="CENTER" GridPane.rowIndex="1"> <GridPane alignment="CENTER" GridPane.rowIndex="1">

View File

@ -1,10 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.CheckBox?>
<?import javafx.scene.layout.*?> <?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<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"> <GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/15.0.1" 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" />
@ -27,24 +34,23 @@
</columnConstraints> </columnConstraints>
<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="34.0" minHeight="34.0" prefHeight="34.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="30.0" minHeight="30.0" prefHeight="30.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" prefHeight="161.0" prefWidth="299.0" style="-fx-border-color: #888888; -fx-border-radius: 5px;" GridPane.rowIndex="4"> <GridPane fx:id="grd_advanced" disable="true" prefHeight="161.0" prefWidth="299.0" style="-fx-border-color: #888888; -fx-border-radius: 5px;" GridPane.rowIndex="3">
<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="28.0" minHeight="28.0" prefHeight="28.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.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="28.0" minHeight="28.0" prefHeight="28.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="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<GridPane.margin> <GridPane.margin>
<Insets bottom="5.0" left="10.0" right="10.0" top="6.0" /> <Insets bottom="20.0" left="10.0" right="10.0" top="6.0" />
</GridPane.margin> </GridPane.margin>
<padding> <padding>
<Insets left="7.0" top="3.0" /> <Insets left="7.0" top="3.0" />
@ -104,7 +110,7 @@
</GridPane> </GridPane>
</children> </children>
</GridPane> </GridPane>
<CheckBox fx:id="cbx_advanced" mnemonicParsing="false" text="Advanced" textFill="#000000ba" GridPane.rowIndex="3"> <CheckBox fx:id="cbx_advanced" mnemonicParsing="false" text="Advanced" 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>
@ -112,38 +118,11 @@
<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="2"> <CheckBox fx:id="cbx_gpython" mnemonicParsing="false" onAction="#gpythonCbxClick" text="Enable G-Python scripting" textFill="#000000ba" GridPane.rowIndex="1">
<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 fx:id="grd_clientSelection" prefHeight="26.0" prefWidth="286.0" style="-fx-border-color: #888888; -fx-border-radius: 5px;" GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="149.0" minWidth="10.0" prefWidth="38.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="81.0" minWidth="69.0" prefWidth="75.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="83.0" minWidth="66.0" prefWidth="72.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="82.0" minWidth="61.0" prefWidth="65.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="242.0" minWidth="10.0" prefWidth="47.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="20.0" prefHeight="34.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<RadioButton fx:id="rd_unity" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Unity" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
<toggleGroup>
<ToggleGroup fx:id="tgl_clientMode" />
</toggleGroup>
</RadioButton>
<RadioButton fx:id="rd_flash" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" selected="true" text="Flash" toggleGroup="$tgl_clientMode" GridPane.columnIndex="2" />
<RadioButton disable="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Anime" GridPane.columnIndex="3" />
</children>
<GridPane.margin>
<Insets left="10.0" right="10.0" />
</GridPane.margin>
<padding>
<Insets bottom="8.0" top="8.0" />
</padding>
</GridPane>
</children> </children>
<GridPane.margin> <GridPane.margin>
<Insets /> <Insets />