From c1188ab228a1ca9f6560e0904978b851494bd448 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Fri, 12 Feb 2021 00:13:51 +0100 Subject: [PATCH] redesign --- .../ui/connection/ConnectionController.java | 26 ++++++++- .../java/gearth/ui/extra/ExtraController.java | 22 ------- .../gearth/ui/connection/Connection.fxml | 54 +++++++++++++++--- .../main/resources/gearth/ui/extra/Extra.fxml | 57 ++++++------------- 4 files changed, 90 insertions(+), 69 deletions(-) diff --git a/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java b/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java index 2f9eae2..e7b1f22 100644 --- a/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java +++ b/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java @@ -3,11 +3,13 @@ package gearth.ui.connection; import gearth.misc.Cacher; import gearth.protocol.connection.HState; import gearth.protocol.connection.proxy.ProxyProviderFactory; +import gearth.services.Constants; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.control.*; import gearth.protocol.HConnection; import gearth.ui.SubForm; +import javafx.scene.layout.GridPane; import org.json.JSONObject; import java.io.IOException; @@ -35,7 +37,27 @@ public class ConnectionController extends SubForm { private final Object lock = new Object(); 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() { + + 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; String hostRemember = null; String portRemember = null; @@ -95,6 +117,7 @@ public class ConnectionController extends SubForm { } private void updateInputUI() { + grd_clientSelection.setDisable(getHConnection().getState() != HState.NOT_CONNECTED); txtfield_hotelversion.setText(getHConnection().getHotelVersion()); btnConnect.setDisable(getHConnection().getState() == HState.PREPARING || getHConnection().getState() == HState.ABORTING); @@ -193,6 +216,7 @@ public class ConnectionController extends SubForm { @Override protected void onExit() { + Cacher.put(USE_UNITY_CLIENT_CACHE_KEY, rd_unity.isSelected()); getHConnection().abort(); } @@ -201,6 +225,6 @@ public class ConnectionController extends SubForm { } private boolean useFlash() { - return parentController.extraController.rd_flash.isSelected(); + return rd_flash.isSelected(); } } diff --git a/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java b/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java index d86dca2..f21abc3 100644 --- a/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java +++ b/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java @@ -30,8 +30,6 @@ public class ExtraController extends SubForm implements SocksConfiguration { public static final String SOCKS_CACHE_KEY = "socks_config"; 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_PORT = "port"; // 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_socksIp; - - public ToggleGroup tgl_clientMode; - public RadioButton rd_unity; - public RadioButton rd_flash; - public GridPane grd_clientSelection; - 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")); InfoController.activateHyperlink(url_troubleshooting); @@ -88,11 +74,6 @@ public class ExtraController extends SubForm implements SocksConfiguration { 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_disableDecryption.selectedProperty().addListener(observable -> HConnection.DECRYPTPACKETS = !cbx_disableDecryption.isSelected()); @@ -120,7 +101,6 @@ public class ExtraController extends SubForm implements SocksConfiguration { protected void onExit() { Cacher.put(NOTEPAD_CACHE_KEY, txtarea_notepad.getText()); Cacher.put(GPYTHON_CACHE_KEY, cbx_gpython.isSelected()); - Cacher.put(USE_UNITY_CLIENT_CACHE_KEY, rd_unity.isSelected()); saveSocksConfig(); } @@ -133,8 +113,6 @@ public class ExtraController extends SubForm implements SocksConfiguration { } private void updateAdvancedUI() { - grd_clientSelection.setDisable(getHConnection().getState() != HState.NOT_CONNECTED); - if (!cbx_advanced.isSelected()) { cbx_debug.setSelected(false); cbx_useSocks.setSelected(false); diff --git a/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml b/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml index a8eda4e..78a27b1 100644 --- a/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml +++ b/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml @@ -5,13 +5,15 @@ + + - + @@ -104,23 +106,24 @@ - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml b/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml index 23479de..dfd74eb 100644 --- a/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml +++ b/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml @@ -1,10 +1,17 @@ - - - + + + + + + + + + + - + @@ -27,24 +34,23 @@ - - + - + - + - + - + @@ -104,7 +110,7 @@ - + @@ -112,38 +118,11 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - -