Added nitro button, reworked last selected client mode

This commit is contained in:
UnfamiliarLegacy 2021-11-26 01:06:57 +01:00
parent d9d1785a33
commit dbf692cb3d
3 changed files with 35 additions and 11 deletions

View File

@ -2,5 +2,6 @@ package gearth.protocol.connection;
public enum HClient {
UNITY,
FLASH
FLASH,
NITRO
}

View File

@ -2,6 +2,7 @@ package gearth.ui.connection;
import gearth.Main;
import gearth.misc.Cacher;
import gearth.protocol.connection.HClient;
import gearth.protocol.connection.HState;
import gearth.protocol.connection.proxy.ProxyProviderFactory;
import gearth.services.Constants;
@ -38,10 +39,11 @@ public class ConnectionController extends SubForm {
private volatile int fullyInitialized = 0;
public static final String USE_UNITY_CLIENT_CACHE_KEY = "use_unity";
public static final String CLIENT_CACHE_KEY = "last_client_mode";
public ToggleGroup tgl_clientMode;
public RadioButton rd_unity;
public RadioButton rd_flash;
public RadioButton rd_nitro;
public GridPane grd_clientSelection;
private volatile int initcount = 0;
@ -54,9 +56,18 @@ public class ConnectionController extends SubForm {
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));
if (Cacher.getCacheContents().has(CLIENT_CACHE_KEY)) {
switch (Cacher.getCacheContents().getEnum(HClient.class, CLIENT_CACHE_KEY)) {
case FLASH:
rd_flash.setSelected(true);
break;
case UNITY:
rd_unity.setSelected(true);
break;
case NITRO:
rd_nitro.setSelected(true);
break;
}
}
@ -269,7 +280,13 @@ public class ConnectionController extends SubForm {
@Override
protected void onExit() {
Cacher.put(USE_UNITY_CLIENT_CACHE_KEY, rd_unity.isSelected());
if (rd_flash.isSelected()) {
Cacher.put(CLIENT_CACHE_KEY, HClient.FLASH);
} else if (rd_unity.isSelected()) {
Cacher.put(CLIENT_CACHE_KEY, HClient.UNITY);
} else if (rd_nitro.isSelected()) {
Cacher.put(CLIENT_CACHE_KEY, HClient.NITRO);
}
getHConnection().abort();
}

View File

@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane alignment="CENTER" 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.connection.ConnectionController">
<GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="258.0" prefWidth="650.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.connection.ConnectionController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
@ -132,9 +132,9 @@
<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 hgrow="SOMETIMES" maxWidth="177.0" minWidth="66.0" prefWidth="90.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="133.0" minWidth="8.0" prefWidth="70.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="242.0" minWidth="10.0" prefWidth="70.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="20.0" prefHeight="34.0" vgrow="SOMETIMES" />
@ -156,7 +156,13 @@
<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>
</GridPane.margin>
</RadioButton>
<RadioButton fx:id="rd_nitro" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefHeight="22.0" prefWidth="54.0" selected="true" text="Nitro" toggleGroup="$tgl_clientMode" GridPane.columnIndex="4">
<GridPane.margin>
<Insets />
</GridPane.margin>
</RadioButton>
</children>
<padding>
<Insets bottom="8.0" top="8.0" />