diff --git a/G-Earth/src/main/java/gearth/GEarth.java b/G-Earth/src/main/java/gearth/GEarth.java index 6cb6041..281c5fa 100644 --- a/G-Earth/src/main/java/gearth/GEarth.java +++ b/G-Earth/src/main/java/gearth/GEarth.java @@ -3,67 +3,135 @@ package gearth; import gearth.misc.AdminValidator; import gearth.misc.Cacher; import gearth.misc.UpdateChecker; +import gearth.misc.listenerpattern.Observable; +import gearth.misc.listenerpattern.ObservableObject; import gearth.ui.GEarthController; +import gearth.ui.subforms.logger.loggerdisplays.PacketLogger; +import gearth.ui.themes.Theme; +import gearth.ui.themes.ThemeFactory; +import gearth.ui.titlebar.TitleBarConfig; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Application; import javafx.application.Platform; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.ToolBar; import javafx.scene.image.Image; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.Pane; -import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.stage.StageStyle; +import sun.misc.Cache; + +import java.util.function.Consumer; public class GEarth extends Application { - public static Application main; + public static GEarth main; public static String version = "1.5.1"; public static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest"; - public static String theme = "G-Earth_Dark"; - public static String[] themes = new String[] {"G-Earth", "Tanji", "G-Earth_Dark"}; + public static ObservableObject observableTheme; + + private Stage stage; + private GEarthController controller; static { - if (Cacher.getCacheContents().has("theme")) { - theme = Cacher.getCacheContents().getString("theme"); - } + observableTheme = new ObservableObject<>( + Cacher.getCacheContents().has("theme") ? + ThemeFactory.themeForTitle(Cacher.getCacheContents().getString("theme")) : + ThemeFactory.getDefaultTheme() + ); } @Override public void start(Stage primaryStage) throws Exception{ main = this; + stage = primaryStage; FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/G-Earth.fxml")); Parent root = loader.load(); - GEarthController companion = loader.getController(); - companion.setStage(primaryStage); - primaryStage.initStyle(StageStyle.TRANSPARENT); + controller = loader.getController(); + controller.setStage(primaryStage); + stage.initStyle(StageStyle.TRANSPARENT); - // https://stackoverflow.com/questions/20732100/javafx-why-does-stage-setresizablefalse-cause-additional-margins -// primaryStage.setScene(new Scene(root, 650, 295)); primaryStage.setScene(new Scene(root)); + TitleBarController.create(primaryStage, new TitleBarConfig() { + @Override + public boolean displayThemePicker() { + return true; + } + + @Override + public boolean displayMinimizeButton() { + return true; + } + +// @Override +// public boolean allowResizing() { +// return false; +// } + + @Override + public void onCloseClicked() { + closeGEarth(); + } + + @Override + public void onMinimizeClicked() { + stage.setIconified(true); + } + + @Override + public void setTheme(Theme theme) { + setGearthTheme(theme); + } + + @Override + public Theme getCurrentTheme() { + return observableTheme.getObject(); + } + }); primaryStage.setResizable(false); primaryStage.sizeToScene(); - - primaryStage.getScene().setFill(Color.TRANSPARENT); - companion.setTheme(theme); + + setGearthTheme(observableTheme.getObject()); primaryStage.show(); - primaryStage.setOnCloseRequest( event -> { - companion.exit(); - Platform.exit(); - - // Platform.exit doesn't seem to be enough on Windows? - System.exit(0); - }); + primaryStage.setOnCloseRequest(event -> closeGEarth()); AdminValidator.validate(); UpdateChecker.checkForUpdates(); } + private void closeGEarth() { + controller.exit(); + Platform.exit(); + System.exit(0); + } + + private void setGearthTheme(Theme theme) { + Cacher.put("theme", theme.title()); + observableTheme.setObject(theme); + Theme defaultTheme = ThemeFactory.getDefaultTheme(); + +// Platform.runLater(() -> { + stage.getScene().getStylesheets().clear(); + stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", theme.internalName())).toExternalForm()); + + stage.getIcons().clear(); + stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", theme.overridesLogo() ? theme.internalName() : defaultTheme.internalName())))); + stage.setTitle((theme.overridesTitle() ? theme.title() : defaultTheme.title()) + " " + GEarth.version); + + controller.infoController.img_logo.setImage(new Image(GEarth.class.getResourceAsStream( + String.format( + "/gearth/ui/themes/%s/logo.png", + theme.overridesLogo() ? theme.internalName() : defaultTheme.internalName() + ) + ))); + controller.infoController.version.setText(stage.getTitle()); +// }); + + } + public static String[] args; public static void main(String[] args) { @@ -90,4 +158,12 @@ public class GEarth extends Application { } return null; } + + public static ObservableObject getThemeObservable() { + return observableTheme; + } + + public static Theme getTheme() { + return observableTheme.getObject(); + } } diff --git a/G-Earth/src/main/java/gearth/extensions/Extension.java b/G-Earth/src/main/java/gearth/extensions/Extension.java index c0c848b..9409af0 100644 --- a/G-Earth/src/main/java/gearth/extensions/Extension.java +++ b/G-Earth/src/main/java/gearth/extensions/Extension.java @@ -1,5 +1,6 @@ package gearth.extensions; +import gearth.misc.HostInfo; import gearth.services.packet_info.PacketInfoManager; import gearth.protocol.HMessage; import gearth.protocol.HPacket; @@ -159,6 +160,8 @@ public abstract class Extension extends ExtensionBase { } else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT) { delayed_init = packet.readBoolean(); + HostInfo hostInfo = HostInfo.fromPacket(packet); + updateHostInfo(hostInfo); if (!delayed_init) { initExtension(); } @@ -177,7 +180,10 @@ public abstract class Extension extends ExtensionBase { response.appendLongString(habboMessage.stringify()); writeToStream(response.toBytes()); - + } + else if (packet.headerId() == NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.UPDATEHOSTINFO) { + HostInfo hostInfo = HostInfo.fromPacket(packet); + updateHostInfo(hostInfo); } } diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionBase.java b/G-Earth/src/main/java/gearth/extensions/ExtensionBase.java index 4abe942..d801aeb 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionBase.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionBase.java @@ -1,10 +1,13 @@ package gearth.extensions; +import gearth.misc.HostInfo; import gearth.misc.listenerpattern.Observable; +import gearth.misc.listenerpattern.ObservableObject; import gearth.protocol.HMessage; import gearth.protocol.HPacket; import gearth.services.packet_info.PacketInfo; import gearth.services.packet_info.PacketInfoManager; +import javafx.beans.property.ObjectProperty; import org.reactfx.util.Lists; import java.util.*; @@ -30,6 +33,11 @@ public abstract class ExtensionBase extends IExtension { volatile PacketInfoManager packetInfoManager = PacketInfoManager.EMPTY; + ObservableObject observableHostInfo = new ObservableObject<>(null); + + void updateHostInfo(HostInfo hostInfo) { + observableHostInfo.setObject(hostInfo); + } /** * Register a listener on a specific packet Type @@ -187,4 +195,8 @@ public abstract class ExtensionBase extends IExtension { public PacketInfoManager getPacketInfoManager() { return packetInfoManager; } + + public HostInfo getHostInfo() { + return observableHostInfo.getObject(); + } } diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java index 326eaf0..6922c93 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java @@ -1,12 +1,17 @@ package gearth.extensions; +import gearth.misc.HostInfo; +import gearth.misc.listenerpattern.Observable; import gearth.services.packet_info.PacketInfoManager; import javafx.application.HostServices; import javafx.application.Platform; +import javafx.beans.InvalidationListener; import javafx.stage.Stage; import gearth.protocol.HMessage; import gearth.protocol.HPacket; +import java.util.function.Consumer; + /** * Created by Jonas on 22/09/18. */ @@ -92,4 +97,10 @@ public abstract class ExtensionForm extends ExtensionBase { public HostServices getHostServices() { return hostServices; } + + public HostInfo getHostInfo() { + return extension.observableHostInfo.getObject(); + } + + Observable fieldsInitialized = new Observable<>(Runnable::run); } diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java b/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java index 170b398..8f67369 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java @@ -60,6 +60,7 @@ public class ExtensionFormLauncher extends Application { extensionForm.extension = extension; extensionForm.primaryStage = primaryStage; + extensionForm.fieldsInitialized.fireEvent(); Thread t = new Thread(() -> { extension.run(); //when the extension has ended, close this process diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java index e6fa158..57822a5 100644 --- a/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java +++ b/G-Earth/src/main/java/gearth/extensions/InternalExtensionBuilder.java @@ -1,6 +1,7 @@ package gearth.extensions; +import gearth.misc.HostInfo; import gearth.services.packet_info.PacketInfoManager; import gearth.protocol.HMessage; import gearth.protocol.HPacket; @@ -118,9 +119,11 @@ public class InternalExtensionBuilder extends GEarthExtension { extension.onEndConnection(); } + @Override - public void init(boolean isConnected) { + public void init(boolean isConnected, HostInfo hostInfo) { extension.initExtension(); + extension.updateHostInfo(hostInfo); } // not implementing isConnected, only relevant for g-python @Override @@ -128,6 +131,11 @@ public class InternalExtensionBuilder extends GEarthExtension { // no need in internal ext } + @Override + public void updateHostInfo(HostInfo hostInfo) { + extension.updateHostInfo(hostInfo); + } + @Override public void packetToStringResponse(String string, String expression) { // no need in java ext diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java deleted file mode 100644 index 5db129b..0000000 --- a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java +++ /dev/null @@ -1,79 +0,0 @@ -package gearth.extensions; - -import gearth.GEarth; -import gearth.services.extension_handler.extensions.GEarthExtension; -import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerObserver; -import javafx.application.Platform; -import javafx.stage.Stage; - -public class InternalExtensionFormBuilder, T extends ExtensionForm> { - - public T launch(L launcher, ExtensionProducerObserver observer) { - try { - Stage stage = new Stage(); - T extensionForm = launcher.createForm(stage); - - ExtensionInfo extInfo = extensionForm.getClass().getAnnotation(ExtensionInfo.class); - - InternalExtension internalExtension = new InternalExtension() { - @Override - protected void initExtension() { - extensionForm.initExtension(); - } - - @Override - protected void onClick() { - extensionForm.onClick(); - } - - @Override - protected void onStartConnection() { - extensionForm.onStartConnection(); - } - - @Override - protected void onEndConnection() { - extensionForm.onEndConnection(); - } - - @Override - protected ExtensionInfo getInfoAnnotations() { - return extInfo; - } - - @Override - protected boolean canLeave() { - return extensionForm.canLeave(); - } - - @Override - protected boolean canDelete() { - return extensionForm.canDelete(); - } - }; - extensionForm.hostServices = GEarth.main.getHostServices(); - extensionForm.extension = internalExtension; - extensionForm.primaryStage = stage; - - GEarthExtension gEarthExtension = new InternalExtensionBuilder(internalExtension); - observer.onExtensionProduced(gEarthExtension); - - - Platform.setImplicitExit(false); - - stage.setOnCloseRequest(event -> { - event.consume(); - Platform.runLater(() -> { - stage.hide(); - extensionForm.onHide(); - }); - }); - - return extensionForm; - } catch (Exception e) { - e.printStackTrace(); - } - - return null; - } -} diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormCreator.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormCreator.java new file mode 100644 index 0000000..8637227 --- /dev/null +++ b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormCreator.java @@ -0,0 +1,10 @@ +package gearth.extensions; + +import javafx.stage.Stage; + +public abstract class InternalExtensionFormCreator { + + // creates an ExtensionForm object and initializes the JavaFX application + public abstract T createForm(Stage primaryStage) throws Exception; + +} diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormLauncher.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormLauncher.java index a6a2d74..ecb8ff2 100644 --- a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormLauncher.java +++ b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormLauncher.java @@ -1,10 +1,80 @@ package gearth.extensions; +import gearth.GEarth; +import gearth.services.extension_handler.extensions.GEarthExtension; +import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerObserver; +import javafx.application.Platform; import javafx.stage.Stage; -public abstract class InternalExtensionFormLauncher { +public class InternalExtensionFormLauncher, T extends ExtensionForm> { - // creates an ExtensionForm object and initializes the JavaFX application - public abstract T createForm(Stage primaryStage) throws Exception; + public T launch(L launcher, ExtensionProducerObserver observer) { + try { + Stage stage = new Stage(); + T extensionForm = launcher.createForm(stage); + ExtensionInfo extInfo = extensionForm.getClass().getAnnotation(ExtensionInfo.class); + + InternalExtension internalExtension = new InternalExtension() { + @Override + protected void initExtension() { + extensionForm.initExtension(); + } + + @Override + protected void onClick() { + extensionForm.onClick(); + } + + @Override + protected void onStartConnection() { + extensionForm.onStartConnection(); + } + + @Override + protected void onEndConnection() { + extensionForm.onEndConnection(); + } + + @Override + protected ExtensionInfo getInfoAnnotations() { + return extInfo; + } + + @Override + protected boolean canLeave() { + return extensionForm.canLeave(); + } + + @Override + protected boolean canDelete() { + return extensionForm.canDelete(); + } + }; + extensionForm.hostServices = GEarth.main.getHostServices(); + extensionForm.extension = internalExtension; + extensionForm.primaryStage = stage; + + extensionForm.fieldsInitialized.fireEvent(); + GEarthExtension gEarthExtension = new InternalExtensionBuilder(internalExtension); + observer.onExtensionProduced(gEarthExtension); + + + Platform.setImplicitExit(false); + + stage.setOnCloseRequest(event -> { + event.consume(); + Platform.runLater(() -> { + stage.hide(); + extensionForm.onHide(); + }); + }); + + return extensionForm; + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } } diff --git a/G-Earth/src/main/java/gearth/extensions/ThemedExtensionFormCreator.java b/G-Earth/src/main/java/gearth/extensions/ThemedExtensionFormCreator.java new file mode 100644 index 0000000..2dd1d62 --- /dev/null +++ b/G-Earth/src/main/java/gearth/extensions/ThemedExtensionFormCreator.java @@ -0,0 +1,78 @@ +package gearth.extensions; + +import gearth.ui.themes.Theme; +import gearth.ui.themes.ThemeFactory; +import gearth.ui.titlebar.DefaultTitleBarConfig; +import gearth.ui.titlebar.TitleBarController; +import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.Observable; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.net.URL; + +public abstract class ThemedExtensionFormCreator extends ExtensionFormCreator { + + @Override + protected ExtensionForm createForm(Stage primaryStage) throws Exception { + FXMLLoader loader = new FXMLLoader(getFormResource()); + Parent root = loader.load(); + + primaryStage.setTitle(getTitle()); + primaryStage.setScene(new Scene(root)); + initialize(primaryStage); + primaryStage.setResizable(false); + primaryStage.sizeToScene(); + + Theme defaultTheme = ThemeFactory.getDefaultTheme(); + DefaultTitleBarConfig config = new DefaultTitleBarConfig(primaryStage, defaultTheme) { + @Override + public boolean displayThemePicker() { + return false; + } + }; + TitleBarController.create(primaryStage, config); + Platform.runLater(() -> { + primaryStage.getScene().getRoot().getStyleClass().add(defaultTheme.title().replace(" ", "-").toLowerCase()); + primaryStage.getScene().getRoot().getStyleClass().add(defaultTheme.isDark() ? "g-dark" : "g-light"); + }); + + ExtensionForm extensionForm = loader.getController(); + extensionForm.fieldsInitialized.addListener(() -> extensionForm.extension.observableHostInfo.addListener(hostInfo -> { + if (hostInfo.getAttributes().containsKey("theme")) { + String themeTitle = hostInfo.getAttributes().get("theme"); + Theme theme = ThemeFactory.themeForTitle(themeTitle); + if (config.getCurrentTheme() != theme) { + String styleClassOld = config.getCurrentTheme().title().replace(" ", "-").toLowerCase(); + String lightClassOld = config.getCurrentTheme().isDark() ? "g-dark" : "g-light"; + String styleClassNew = theme.title().replace(" ", "-").toLowerCase(); + String lightClassNew = theme.isDark() ? "g-dark" : "g-light"; + config.setTheme(theme); + Parent currentRoot = primaryStage.getScene().getRoot(); + Platform.runLater(() -> { + currentRoot.getStyleClass().remove(styleClassOld); + currentRoot.getStyleClass().add(styleClassNew); + if (!lightClassOld.equals(lightClassNew)) { + currentRoot.getStyleClass().remove(lightClassOld); + currentRoot.getStyleClass().add(lightClassNew); + } + }); + } + } + })); + + + return extensionForm; + } + + protected abstract String getTitle(); + protected abstract URL getFormResource(); + + // can be overridden for more settings + protected void initialize(Stage primaryStage) { + + } +} diff --git a/G-Earth/src/main/java/gearth/misc/AdminValidator.java b/G-Earth/src/main/java/gearth/misc/AdminValidator.java index 338b89f..7a96735 100644 --- a/G-Earth/src/main/java/gearth/misc/AdminValidator.java +++ b/G-Earth/src/main/java/gearth/misc/AdminValidator.java @@ -1,13 +1,13 @@ package gearth.misc; -import gearth.GEarth; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; -import javafx.scene.image.Image; +import javafx.scene.control.Label; import javafx.scene.layout.Region; -import javafx.stage.Stage; +import java.io.IOException; import java.io.PrintStream; import java.util.prefs.Preferences; @@ -46,13 +46,13 @@ public class AdminValidator { new Thread(() -> { if (!AdminValidator.isAdmin()) { Platform.runLater(() -> { - Alert alert = new Alert(Alert.AlertType.WARNING, "G-Earth needs admin privileges in order to work on Flash, please restart G-Earth with admin permissions unless you're using Unity", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); - alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); - alert.setResizable(false); - alert.show(); + Alert alert = new Alert(Alert.AlertType.WARNING, "", ButtonType.OK); + alert.getDialogPane().setContent(new Label("G-Earth needs admin privileges in order to work on Flash,\nplease restart G-Earth with admin permissions unless\nyou're using Unity")); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); } diff --git a/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java b/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java index d607e04..81ede90 100644 --- a/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java +++ b/G-Earth/src/main/java/gearth/misc/ConfirmationDialog.java @@ -26,9 +26,6 @@ public class ConfirmationDialog { Alert alert = new Alert(type); // Need to force the alert to layout in order to grab the graphic, // as we are replacing the dialog pane with a custom pane - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); alert.getDialogPane().applyCss(); Node graphic = alert.getDialogPane().getGraphic(); // Create a new dialog pane that has a checkbox instead of the hide/show details button diff --git a/G-Earth/src/main/java/gearth/misc/HostInfo.java b/G-Earth/src/main/java/gearth/misc/HostInfo.java new file mode 100644 index 0000000..e027f35 --- /dev/null +++ b/G-Earth/src/main/java/gearth/misc/HostInfo.java @@ -0,0 +1,53 @@ +package gearth.misc; + +import gearth.protocol.HPacket; + +import java.util.HashMap; + +public class HostInfo { + + private final String packetlogger; + private final String version; + private final HashMap attributes; + + public HostInfo(String packetlogger, String version, HashMap attributes) { + this.packetlogger = packetlogger; + this.version = version; + this.attributes = attributes; + } + + public static HostInfo fromPacket(HPacket packet) { + String packetlogger = packet.readString(); + String version = packet.readString(); + int attributeCount = packet.readInteger(); + HashMap attributes = new HashMap<>(); + for (int i = 0; i < attributeCount; i++) { + String key = packet.readString(); + String value = packet.readString(); + attributes.put(key, value); + } + return new HostInfo(packetlogger, version, attributes); + } + + public void appendToPacket(HPacket packet) { + packet.appendString(packetlogger); + packet.appendString(version); + packet.appendInt(attributes.size()); + attributes.keySet().forEach(k -> { + packet.appendString(k); + packet.appendString(attributes.get(k)); + }); + } + + public String getPacketlogger() { + return packetlogger; + } + + public String getVersion() { + return version; + } + + public HashMap getAttributes() { + return attributes; + } +} diff --git a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java index 5fd42e3..93a0827 100644 --- a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java +++ b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java @@ -1,6 +1,7 @@ package gearth.misc; import gearth.GEarth; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; @@ -37,9 +38,6 @@ public class UpdateChecker { boolean isForcedUpdate = body.contains("(!)"); Alert alert = new Alert(isForcedUpdate ? Alert.AlertType.ERROR : Alert.AlertType.INFORMATION, "G-Earth is outdated!", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); FlowPane fp = new FlowPane(); Label lbl = new Label("A new version of G-Earth has been found ("+gitv+")" + System.lineSeparator()+ System.lineSeparator() + "Update to the latest version:"); @@ -62,7 +60,11 @@ public class UpdateChecker { if (isForcedUpdate) { alert.setOnCloseRequest(event -> System.exit(0)); } - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); } diff --git a/G-Earth/src/main/java/gearth/misc/listenerpattern/ObservableObject.java b/G-Earth/src/main/java/gearth/misc/listenerpattern/ObservableObject.java new file mode 100644 index 0000000..4fd62de --- /dev/null +++ b/G-Earth/src/main/java/gearth/misc/listenerpattern/ObservableObject.java @@ -0,0 +1,22 @@ +package gearth.misc.listenerpattern; + +import java.util.function.Consumer; + +public class ObservableObject extends Observable> { + + private T object; + + public ObservableObject(T object) { + super(); + this.object = object; + } + + public void setObject(T object) { + this.object = object; + fireEvent(c -> c.accept(object)); + } + + public T getObject() { + return object; + } +} diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java index da9f8b7..783f4d0 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java @@ -9,9 +9,11 @@ import gearth.protocol.connection.HStateSetter; import gearth.protocol.connection.proxy.flash.NormalFlashProxyProvider; import gearth.protocol.connection.proxy.flash.unix.LinuxRawIpFlashProxyProvider; import gearth.protocol.connection.proxy.flash.windows.WindowsRawIpFlashProxyProvider; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.layout.Region; import javafx.stage.Stage; @@ -105,15 +107,17 @@ public class ProxyProviderFactory { } Platform.runLater(() -> { - Alert alert = new Alert(Alert.AlertType.ERROR, "G-Earth is already connected to this hotel. " + + Alert alert = new Alert(Alert.AlertType.ERROR, "", ButtonType.OK); + alert.getDialogPane().getChildren().add(new Label("G-Earth is already connected to this hotel.\n" + "Due to current limitations you can only connect one session per hotel to G-Earth in Raw IP mode on Windows.\n\n" + - "You can bypass this by using a SOCKS proxy [Extra -> Advanced -> SOCKS]", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); + "You can bypass this by using a SOCKS proxy [Extra -> Advanced -> SOCKS]")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.setResizable(false); - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); return null; diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java index 8740163..dbbc7af 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/FlashProxyProvider.java @@ -11,9 +11,11 @@ import gearth.protocol.memory.Rc4Obtainer; import gearth.protocol.packethandler.flash.IncomingFlashPacketHandler; import gearth.protocol.packethandler.flash.OutgoingFlashPacketHandler; import gearth.protocol.packethandler.flash.FlashPacketHandler; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.layout.Region; import javafx.stage.Stage; @@ -123,13 +125,15 @@ public abstract class FlashProxyProvider implements ProxyProvider { protected void showInvalidConnectionError() { Platform.runLater(() -> { - Alert alert = new Alert(Alert.AlertType.ERROR, "You entered invalid connection information, G-Earth could not connect", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); + Alert alert = new Alert(Alert.AlertType.ERROR, "", ButtonType.OK); + alert.getDialogPane().getChildren().add(new Label("You entered invalid connection information, G-Earth could not connect")); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.setResizable(false); - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); } diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java index 4cf7b5f..49b4c6e 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/flash/NormalFlashProxyProvider.java @@ -10,6 +10,7 @@ import gearth.protocol.hostreplacer.hostsfile.HostReplacer; import gearth.protocol.hostreplacer.hostsfile.HostReplacerFactory; import gearth.protocol.portchecker.PortChecker; import gearth.protocol.portchecker.PortCheckerFactory; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; @@ -109,10 +110,11 @@ public class NormalFlashProxyProvider extends FlashProxyProvider { Platform.runLater(() -> { Alert a = new Alert(Alert.AlertType.ERROR, "The port is in use by " + processName, ButtonType.OK); - Stage stage = (Stage) a.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); - a.showAndWait(); + try { + TitleBarController.create(a).showAlertAndWait(); + } catch (IOException ex) { + ex.printStackTrace(); + } }); throw new IOException(e); } diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java index ad9f575..f056564 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/nitro/http/NitroHttpProxy.java @@ -5,9 +5,11 @@ import gearth.misc.ConfirmationDialog; import gearth.protocol.connection.proxy.nitro.NitroConstants; import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctions; import gearth.protocol.connection.proxy.nitro.os.NitroOsFunctionsFactory; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.stage.Stage; import org.littleshoot.proxy.HttpProxyServer; @@ -16,6 +18,7 @@ import org.littleshoot.proxy.mitm.Authority; import org.littleshoot.proxy.mitm.RootCertificateException; import java.io.File; +import java.io.IOException; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; @@ -51,16 +54,20 @@ public class NitroHttpProxy { Platform.runLater(() -> { Alert alert = ConfirmationDialog.createAlertWithOptOut(Alert.AlertType.WARNING, ADMIN_WARNING_KEY, "Root certificate installation", null, - "G-Earth detected that you do not have the root certificate authority installed. " + - "This is required for Nitro to work, do you want to continue? " + - "G-Earth will ask you for Administrator permission if you do so.", "Remember my choice", + "", "Remember my choice", ButtonType.YES, ButtonType.NO ); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); - shouldInstall.set(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent()); + alert.getDialogPane().setContent(new Label("G-Earth detected that you do not have the root certificate authority installed.\n" + + "This is required for Nitro to work, do you want to continue?\n" + + "G-Earth will ask you for Administrator permission if you do so.")); + + try { + shouldInstall.set(TitleBarController.create(alert).showAlertAndWait() + .filter(t -> t == ButtonType.YES).isPresent()); + } catch (IOException e) { + e.printStackTrace(); + } waitForDialog.release(); }); diff --git a/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java b/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java index 1066821..40ff481 100644 --- a/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java +++ b/G-Earth/src/main/java/gearth/protocol/memory/Rc4Obtainer.java @@ -10,6 +10,7 @@ import gearth.protocol.memory.habboclient.HabboClientFactory; import gearth.protocol.packethandler.flash.BufferChangeListener; import gearth.protocol.packethandler.flash.FlashPacketHandler; import gearth.protocol.packethandler.PayloadBuffer; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; @@ -18,9 +19,11 @@ import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.layout.FlowPane; import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; import javafx.scene.web.WebView; import javafx.stage.Stage; +import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -82,9 +85,6 @@ public class Rc4Obtainer { Platform.runLater(() -> { Alert alert = new Alert(Alert.AlertType.WARNING, "Something went wrong!", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); FlowPane fp = new FlowPane(); Label lbl = new Label("G-Earth has experienced an issue" + System.lineSeparator()+ System.lineSeparator() + "Head over to our Troubleshooting page to solve the problem:"); @@ -95,15 +95,16 @@ public class Rc4Obtainer { event.consume(); }); - WebView webView = new WebView(); - webView.getEngine().loadContent("G-Earth has experienced an issue

Head over to our Troubleshooting page to solve the problem:
https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"); - webView.setPrefSize(500, 200); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setContent(fp); alert.setOnCloseRequest(event -> { GEarth.main.getHostServices().showDocument(link.getText()); }); - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java b/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java index 3c8c119..61e01b7 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/ExtensionHandler.java @@ -1,6 +1,7 @@ package gearth.services.extension_handler; import gearth.GEarth; +import gearth.misc.HostInfo; import gearth.misc.listenerpattern.Observable; import gearth.protocol.HConnection; import gearth.protocol.HMessage; @@ -11,10 +12,12 @@ import gearth.services.extension_handler.extensions.GEarthExtension; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducer; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerFactory; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerObserver; +import gearth.ui.themes.Theme; import javafx.util.Pair; import java.io.IOException; import java.util.*; +import java.util.function.Consumer; public class ExtensionHandler { @@ -44,6 +47,14 @@ public class ExtensionHandler { } private void initialize() { + GEarth.getThemeObservable().addListener(theme -> { + synchronized (gEarthExtensions) { + for (GEarthExtension extension : gEarthExtensions) { + extension.updateHostInfo(getHostInfo()); + } + } + }); + hConnection.getStateObservable().addListener((oldState, newState) -> { if (newState == HState.CONNECTED) { synchronized (gEarthExtensions) { @@ -241,7 +252,7 @@ public class ExtensionHandler { extension.getClickedObservable().addListener(extension::doubleclick); observable.fireEvent(l -> l.onExtensionConnect(extension)); - extension.init(hConnection.getState() == HState.CONNECTED); + extension.init(hConnection.getState() == HState.CONNECTED, getHostInfo()); if (hConnection.getState() == HState.CONNECTED) { extension.connectionStart( hConnection.getDomain(), @@ -256,6 +267,16 @@ public class ExtensionHandler { }; } + private HostInfo getHostInfo() { + HashMap attributes = new HashMap<>(); + attributes.put("theme", GEarth.getTheme().title()); + return new HostInfo( + "G-Earth", + GEarth.version, + attributes + ); + } + public List getExtensionProducers() { return extensionProducers; } diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/GEarthExtension.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/GEarthExtension.java index 8310475..7a18161 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/GEarthExtension.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/GEarthExtension.java @@ -1,5 +1,6 @@ package gearth.services.extension_handler.extensions; +import gearth.misc.HostInfo; import gearth.misc.listenerpattern.Observable; import gearth.misc.listenerpattern.SynchronizedObservable; import gearth.services.packet_info.PacketInfoManager; @@ -40,8 +41,9 @@ public abstract class GEarthExtension { public abstract void provideFlags(String[] flags); public abstract void connectionStart(String host, int port, String hotelVersion, String clientIdentifier, HClient clientType, PacketInfoManager packetInfoManager); public abstract void connectionEnd(); - public abstract void init(boolean isConnected); + public abstract void init(boolean isConnected, HostInfo hostInfo); public abstract void close(); + public abstract void updateHostInfo(HostInfo hostInfo); public abstract void packetToStringResponse(String string, String expression); public abstract void stringToPacketResponse(HPacket packet); // --------------------------------------------------------------- diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtension.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtension.java index 3100a76..8b55c95 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtension.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtension.java @@ -1,5 +1,6 @@ package gearth.services.extension_handler.extensions.implementations.network; +import gearth.misc.HostInfo; import gearth.services.packet_info.PacketInfoManager; import gearth.protocol.HMessage; import gearth.protocol.connection.HClient; @@ -213,10 +214,12 @@ public class NetworkExtension extends GEarthExtension { } @Override - public void init(boolean isConnected) { - sendMessage( - new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT, isConnected) - ); + public void init(boolean isConnected, HostInfo hostInfo) { + HPacket initPacket = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.INIT); + initPacket.appendBoolean(isConnected); + hostInfo.appendToPacket(initPacket); + + sendMessage(initPacket); } @Override @@ -226,6 +229,13 @@ public class NetworkExtension extends GEarthExtension { } catch (IOException ignored) { } } + @Override + public void updateHostInfo(HostInfo hostInfo) { + HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.UPDATEHOSTINFO); + hostInfo.appendToPacket(packet); + sendMessage(packet); + } + @Override public void packetToStringResponse(String string, String expression) { HPacket packet = new HPacket(NetworkExtensionInfo.OUTGOING_MESSAGES_IDS.PACKETTOSTRING_RESPONSE); diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtensionInfo.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtensionInfo.java index 6ac87cb..50282cf 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtensionInfo.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/NetworkExtensionInfo.java @@ -88,6 +88,8 @@ public class NetworkExtensionInfo { public static final int CONNECTIONEND = 6; public static final int INIT = 7; + public static final int UPDATEHOSTINFO = 10; + public static final int PACKETTOSTRING_RESPONSE = 20; public static final int STRINGTOPACKET_RESPONSE = 21; } diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java index ebea488..5f6b694 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/network/authentication/Authenticator.java @@ -2,10 +2,13 @@ package gearth.services.extension_handler.extensions.implementations.network.aut import gearth.misc.ConfirmationDialog; import gearth.services.extension_handler.extensions.implementations.network.NetworkExtension; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; +import java.io.IOException; import java.util.*; /** @@ -66,12 +69,20 @@ public class Authenticator { Platform.runLater(() -> { Alert alert = ConfirmationDialog.createAlertWithOptOut(Alert.AlertType.WARNING, connectExtensionKey ,"Confirmation Dialog", null, - "Extension \""+extension.getTitle()+"\" tries to connect but isn't known to G-Earth, accept this connection?", "Remember my choice", + "", "Remember my choice", ButtonType.YES, ButtonType.NO ); - if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) { - allowConnection[0] = false; + alert.getDialogPane().setContent(new Label("Extension \""+extension.getTitle()+"\" tries to connect but isn't known to G-Earth,\n" + + "accept this connection?")); + + try { + if (!(TitleBarController.create(alert).showAlertAndWait() + .filter(t -> t == ButtonType.YES).isPresent())) { + allowConnection[0] = false; + } + } catch (IOException e) { + e.printStackTrace(); } done[0] = true; if (!ConfirmationDialog.showDialog(connectExtensionKey)) { diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/ExampleExtension.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/ExampleExtension.java index 99f4e24..8b29916 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/ExampleExtension.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/ExampleExtension.java @@ -1,5 +1,6 @@ package gearth.services.extension_handler.extensions.implementations.simple; +import gearth.misc.HostInfo; import gearth.services.packet_info.PacketInfoManager; import gearth.protocol.HMessage; import gearth.protocol.HPacket; @@ -96,8 +97,9 @@ public class ExampleExtension extends GEarthExtension { // the habbo connection has ended } + @Override - public void init(boolean isConnected) { + public void init(boolean isConnected, HostInfo hostInfo) { System.out.println("Example extension is connected to G-Earth"); // the extension is now connected with G-Earth } @@ -110,7 +112,10 @@ public class ExampleExtension extends GEarthExtension { hasClosed(); } + @Override + public void updateHostInfo(HostInfo hostInfo) { + } // ignore these diff --git a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/SimpleExtensionProducer.java b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/SimpleExtensionProducer.java index 07219a5..c9b3cf0 100644 --- a/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/SimpleExtensionProducer.java +++ b/G-Earth/src/main/java/gearth/services/extension_handler/extensions/implementations/simple/SimpleExtensionProducer.java @@ -1,10 +1,10 @@ package gearth.services.extension_handler.extensions.implementations.simple; -import gearth.extensions.InternalExtensionFormBuilder; +import gearth.extensions.InternalExtensionFormLauncher; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducer; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerObserver; import gearth.services.internal_extensions.extensionstore.GExtensionStore; -import gearth.services.internal_extensions.extensionstore.GExtensionStoreLauncher; +import gearth.services.internal_extensions.extensionstore.GExtensionStoreCreator; public class SimpleExtensionProducer implements ExtensionProducer { @@ -14,8 +14,8 @@ public class SimpleExtensionProducer implements ExtensionProducer { // uncomment the next line if you want to see an embedded example extension in G-Earth // observer.onExtensionProduced(new ExampleExtension()); - new InternalExtensionFormBuilder() - .launch(new GExtensionStoreLauncher(), observer); + new InternalExtensionFormLauncher() + .launch(new GExtensionStoreCreator(), observer); } } diff --git a/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java b/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java index 0012ff2..da92ac6 100644 --- a/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java +++ b/G-Earth/src/main/java/gearth/services/g_python/GPythonShell.java @@ -1,7 +1,8 @@ package gearth.services.g_python; import gearth.GEarth; -import gearth.ui.extra.ExtraController; +import gearth.ui.subforms.extra.ExtraController; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; @@ -170,9 +171,6 @@ public class GPythonShell { private void showError() { Platform.runLater(() -> { Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python error", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); alert.setTitle("G-Python error"); FlowPane fp = new FlowPane(); @@ -188,7 +186,11 @@ public class GPythonShell { alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setContent(fp); - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } }); } diff --git a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreLauncher.java b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreCreator.java similarity index 81% rename from G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreLauncher.java rename to G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreCreator.java index 5e94d67..c5df82e 100644 --- a/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreLauncher.java +++ b/G-Earth/src/main/java/gearth/services/internal_extensions/extensionstore/GExtensionStoreCreator.java @@ -1,7 +1,7 @@ package gearth.services.internal_extensions.extensionstore; import gearth.GEarth; -import gearth.extensions.InternalExtensionFormLauncher; +import gearth.extensions.InternalExtensionFormCreator; import gearth.services.internal_extensions.extensionstore.application.GExtensionStoreController; import gearth.ui.GEarthController; import javafx.fxml.FXMLLoader; @@ -10,7 +10,7 @@ import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Stage; -public class GExtensionStoreLauncher extends InternalExtensionFormLauncher { +public class GExtensionStoreCreator extends InternalExtensionFormCreator { @Override public GExtensionStore createForm(Stage stage) throws Exception { @@ -26,8 +26,8 @@ public class GExtensionStoreLauncher extends InternalExtensionFormLauncher { +public class UiLoggerCreator extends InternalExtensionFormCreator { @Override public UiLogger createForm(Stage stage) throws Exception { UiLogger uiLogger = new UiLogger(); @@ -17,12 +16,12 @@ public class UiLoggerLauncher extends InternalExtensionFormLauncher { FXMLLoader loader = new FXMLLoader(UiLogger.class.getResource("UiLogger.fxml")); Parent root = loader.load(); - stage.setTitle(String.format("%s | Packet Logger", GEarth.theme)); + stage.setTitle("G-Earth | Packet Logger"); stage.initModality(Modality.NONE); - stage.getIcons().add(new Image(getClass().getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); + stage.getIcons().add(new Image(getClass().getResourceAsStream("/gearth/ui/themes/G-Earth/logoSmall.png"))); Scene scene = new Scene(root); - scene.getStylesheets().add(String.format("/gearth/themes/%s/styling.css", GEarth.theme)); + scene.getStylesheets().add("/gearth/ui/themes/G-Earth/styling.css"); scene.getStylesheets().add("/gearth/services/internal_extensions/uilogger/logger.css"); UiLoggerController controller = loader.getController(); @@ -30,6 +29,13 @@ public class UiLoggerLauncher extends InternalExtensionFormLauncher { controller.setStage(stage); stage.setScene(scene); +// TitleBarController.create(stage, new DefaultTitleBarConfig(stage) { +// @Override +// public void onCloseClicked() { +// stage.hide(); +//// uiLogger.onHide(); +// } +// }); return uiLogger; } } diff --git a/G-Earth/src/main/java/gearth/services/scheduler/Interval.java b/G-Earth/src/main/java/gearth/services/scheduler/Interval.java index 5ff49bb..2c15c15 100644 --- a/G-Earth/src/main/java/gearth/services/scheduler/Interval.java +++ b/G-Earth/src/main/java/gearth/services/scheduler/Interval.java @@ -1,6 +1,6 @@ package gearth.services.scheduler; -import gearth.ui.scheduler.SchedulerController; +import gearth.ui.subforms.scheduler.SchedulerController; /** * Created by Jonas on 11/04/18. diff --git a/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java b/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java index 4a00d9a..8058604 100644 --- a/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java +++ b/G-Earth/src/main/java/gearth/services/unity_tools/GUnityFileServer.java @@ -2,6 +2,7 @@ package gearth.services.unity_tools; import gearth.GEarth; import gearth.misc.Cacher; +import gearth.ui.themes.ThemeFactory; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; @@ -135,7 +136,7 @@ public class GUnityFileServer extends HttpServlet private void getLogo(HttpServletResponse response) throws IOException { OutputStream out = response.getOutputStream(); - InputStream in = GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logo.png", GEarth.theme)); + InputStream in = GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logo.png", ThemeFactory.getDefaultTheme().internalName())); byte[] bytes = new byte[4096]; int bytesRead; diff --git a/G-Earth/src/main/java/gearth/ui/GEarthController.java b/G-Earth/src/main/java/gearth/ui/GEarthController.java index 4627294..557295b 100644 --- a/G-Earth/src/main/java/gearth/ui/GEarthController.java +++ b/G-Earth/src/main/java/gearth/ui/GEarthController.java @@ -1,27 +1,22 @@ package gearth.ui; -import gearth.GEarth; import gearth.protocol.connection.proxy.ProxyProviderFactory; import gearth.protocol.connection.proxy.SocksConfiguration; -import gearth.ui.logger.loggerdisplays.PacketLoggerFactory; -import javafx.application.Platform; +import gearth.ui.subforms.logger.loggerdisplays.PacketLoggerFactory; import javafx.scene.control.*; -import javafx.scene.image.Image; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.Pane; import javafx.stage.Stage; import gearth.protocol.HConnection; -import gearth.ui.connection.ConnectionController; -import gearth.ui.extensions.ExtensionsController; -import gearth.ui.info.InfoController; -import gearth.ui.injection.InjectionController; -import gearth.ui.logger.LoggerController; -import gearth.ui.scheduler.SchedulerController; -import gearth.ui.extra.ExtraController; -import gearth.ui.tools.ToolsController; +import gearth.ui.subforms.connection.ConnectionController; +import gearth.ui.subforms.extensions.ExtensionsController; +import gearth.ui.subforms.info.InfoController; +import gearth.ui.subforms.injection.InjectionController; +import gearth.ui.subforms.logger.LoggerController; +import gearth.ui.subforms.scheduler.SchedulerController; +import gearth.ui.subforms.extra.ExtraController; +import gearth.ui.subforms.tools.ToolsController; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class GEarthController { @@ -43,9 +38,6 @@ public class GEarthController { private List tabs = null; - public Pane titleBar; - public Label titleLabel; - public GEarthController() { SocksConfiguration temporary_socks = new SocksConfiguration() { public boolean useSocks() { return false; } @@ -123,54 +115,9 @@ public class GEarthController { loggerController.miniLogText(color, text); } - public void setTheme(String theme) { - GEarth.theme = theme; - - getStage().getScene().getStylesheets().clear(); - getStage().getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", theme)).toExternalForm()); - - getStage().getIcons().clear(); - getStage().getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", theme)))); - - getStage().setTitle(theme.split("_")[0] + " " + GEarth.version); - titleLabel.setText(getStage().getTitle()); - - infoController.img_logo.setImage(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logo.png", theme)))); - infoController.version.setText(getStage().getTitle()); - } - - public void exit() { tabs.forEach(SubForm::exit); hConnection.abort(); } - public void handleCloseAction(MouseEvent event) { - this.exit(); - Platform.exit(); - - // Platform.exit doesn't seem to be enough on Windows? - System.exit(0); - } - - public void handleMinimizeAction(MouseEvent event) { - getStage().setIconified(true); - } - - private double xOffset, yOffset; - - public void handleClickAction(MouseEvent event) { - xOffset = event.getSceneX(); - yOffset = event.getSceneY(); - } - - public void handleMovementAction(MouseEvent event) { - getStage().setX(event.getScreenX() - xOffset); - getStage().setY(event.getScreenY() - yOffset); - } - - public void toggleTheme(MouseEvent event) { - int themeIndex = Arrays.asList(GEarth.themes).indexOf(GEarth.theme); - setTheme(GEarth.themes[(themeIndex + 1) % GEarth.themes.length]); - } } diff --git a/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java b/G-Earth/src/main/java/gearth/ui/subforms/connection/ConnectionController.java similarity index 99% rename from G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java rename to G-Earth/src/main/java/gearth/ui/subforms/connection/ConnectionController.java index 4afa7c1..3add757 100644 --- a/G-Earth/src/main/java/gearth/ui/connection/ConnectionController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/connection/ConnectionController.java @@ -1,4 +1,4 @@ -package gearth.ui.connection; +package gearth.ui.subforms.connection; import gearth.GEarth; import gearth.misc.Cacher; diff --git a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainer.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java similarity index 91% rename from G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainer.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java index b6f6c24..b1623fe 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainer.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainer.java @@ -1,7 +1,8 @@ -package gearth.ui.extensions; +package gearth.ui.subforms.extensions; import gearth.services.extension_handler.extensions.ExtensionType; import gearth.services.extension_handler.extensions.GEarthExtension; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.event.EventHandler; import javafx.geometry.Insets; @@ -9,7 +10,6 @@ import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; -import javafx.scene.paint.Paint; import javafx.scene.text.Font; import gearth.misc.ConfirmationDialog; import gearth.ui.buttons.*; @@ -18,6 +18,7 @@ import gearth.services.extension_handler.extensions.implementations.network.exec import gearth.services.extension_handler.extensions.implementations.network.executer.ExtensionRunnerFactory; import gearth.services.extension_handler.extensions.implementations.network.executer.NormalExtensionRunner; +import java.io.IOException; import java.nio.file.Paths; /** @@ -114,8 +115,13 @@ public class ExtensionItemContainer extends GridPane { ButtonType.YES, ButtonType.NO ); - if (!(alert.showAndWait().filter(t -> t == ButtonType.YES).isPresent())) { - delet_dis = false; + try { + if (!(TitleBarController.create(alert).showAlertAndWait() + .filter(t -> t == ButtonType.YES).isPresent())) { + delet_dis = false; + } + } catch (IOException e) { + e.printStackTrace(); } } @@ -143,9 +149,12 @@ public class ExtensionItemContainer extends GridPane { parent.getChildren().add(this); + getStyleClass().clear(); + getStyleClass().add("tableRowActive"); + if (item.extensionType() == ExtensionType.INTERNAL) { getStyleClass().clear(); - getStyleClass().add("internalExtension"); + getStyleClass().add("tableRowBlue"); } @@ -178,7 +187,7 @@ public class ExtensionItemContainer extends GridPane { item.getDeletedObservable().addListener(() -> Platform.runLater(() -> { if (item.isInstalledExtension()) { getStyleClass().clear(); - getStyleClass().add("disconnectedExtension"); + getStyleClass().add("tableRowInactive"); getChildren().remove(buttonsBox); add(additionalButtonBox, 4, 0); reloadButton.setVisible(true); @@ -194,7 +203,7 @@ public class ExtensionItemContainer extends GridPane { initExtension(); getStyleClass().clear(); - getStyleClass().add("connectedExtension"); + getStyleClass().add("tableRowActive"); getChildren().remove(additionalButtonBox); if (buttonsBox != null) { add(buttonsBox, 4, 0); diff --git a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainerProducer.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainerProducer.java similarity index 97% rename from G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainerProducer.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainerProducer.java index 6bc2a2e..d183e6d 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionItemContainerProducer.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionItemContainerProducer.java @@ -1,4 +1,4 @@ -package gearth.ui.extensions; +package gearth.ui.subforms.extensions; import gearth.services.extension_handler.extensions.GEarthExtension; import javafx.scene.Node; diff --git a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java similarity index 97% rename from G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java index 979b073..d51f7fd 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/ExtensionsController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/ExtensionsController.java @@ -1,4 +1,4 @@ -package gearth.ui.extensions; +package gearth.ui.subforms.extensions; import gearth.services.extension_handler.ExtensionHandler; import gearth.services.extension_handler.extensions.ExtensionListener; @@ -9,7 +9,7 @@ import gearth.services.extension_handler.extensions.implementations.network.exec import gearth.services.extension_handler.extensions.implementations.network.executer.ExtensionRunnerFactory; import gearth.services.g_python.GPythonShell; import gearth.ui.SubForm; -import gearth.ui.extensions.logger.ExtensionLogger; +import gearth.ui.subforms.extensions.logger.ExtensionLogger; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.control.*; diff --git a/G-Earth/src/main/java/gearth/ui/extensions/logger/Element.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/Element.java similarity index 80% rename from G-Earth/src/main/java/gearth/ui/extensions/logger/Element.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/Element.java index 6dee891..5b91a98 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/logger/Element.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/Element.java @@ -1,4 +1,4 @@ -package gearth.ui.extensions.logger; +package gearth.ui.subforms.extensions.logger; class Element { final String text; diff --git a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLogger.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLogger.java similarity index 70% rename from G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLogger.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLogger.java index bd435b2..bba6600 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLogger.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLogger.java @@ -1,6 +1,9 @@ -package gearth.ui.extensions.logger; +package gearth.ui.subforms.extensions.logger; import gearth.GEarth; +import gearth.ui.titlebar.DefaultTitleBarConfig; +import gearth.ui.titlebar.GEarthThemedTitleBarConfig; +import gearth.ui.titlebar.TitleBarController; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; @@ -21,7 +24,7 @@ public class ExtensionLogger { volatile boolean isVisible = false; public ExtensionLogger() { - FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/extensions/logger/ExtensionLogger.fxml")); + FXMLLoader loader = new FXMLLoader(getClass().getResource("/gearth/ui/subforms/extensions/logger/ExtensionLogger.fxml")); try { Parent root = loader.load(); @@ -35,26 +38,31 @@ public class ExtensionLogger { stage = new Stage(); - stage.setTitle(String.format("%s | Extension Console", GEarth.theme)); + stage.setTitle("G-Earth | Extension Console"); stage.initModality(Modality.NONE); - stage.getIcons().add(new Image(getClass().getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); stage.setAlwaysOnTop(true); stage.setMinHeight(235); stage.setMinWidth(370); Scene scene = new Scene(root); - scene.getStylesheets().add(String.format("/gearth/themes/%s/styling.css", GEarth.theme)); - scene.getStylesheets().add("/gearth/ui/extensions/logger/logger.css"); + scene.getStylesheets().add("/gearth/ui/subforms/extensions/logger/logger.css"); ExtensionLoggerController controller = loader.getController(); controller.setStage(stage); stage.setScene(scene); - - // don't let the user close this window on their own - stage.setOnCloseRequest(windowEvent -> { - stage.hide(); - isVisible = false; + TitleBarController.create(stage, new GEarthThemedTitleBarConfig(stage) { + @Override + public void onCloseClicked() { + stage.hide(); + isVisible = false; + } }); + +// // don't let the user close this window on their own +// stage.setOnCloseRequest(windowEvent -> { +// stage.hide(); +// isVisible = false; +// }); } catch (IOException e) { e.printStackTrace(); } diff --git a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLoggerController.java similarity index 91% rename from G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java rename to G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLoggerController.java index 58f88a6..bafc3a8 100644 --- a/G-Earth/src/main/java/gearth/ui/extensions/logger/ExtensionLoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extensions/logger/ExtensionLoggerController.java @@ -1,8 +1,7 @@ -package gearth.ui.extensions.logger; +package gearth.ui.subforms.extensions.logger; import javafx.application.Platform; import javafx.fxml.Initializable; -import javafx.scene.control.ScrollPane; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import org.fxmisc.flowless.VirtualizedScrollPane; @@ -25,12 +24,14 @@ public class ExtensionLoggerController implements Initializable { @Override public void initialize(URL arg0, ResourceBundle arg1) { area = new StyleClassedTextArea(); - area.getStyleClass().add("white"); + area.getStyleClass().add("themed-background"); area.setWrapText(true); area.setEditable(false); VirtualizedScrollPane vsPane = new VirtualizedScrollPane<>(area); borderPane.setCenter(vsPane); + vsPane.getStyleClass().add("themed-background"); + borderPane.getStyleClass().add("themed-background"); synchronized (appendOnLoad) { initialized = true; @@ -74,7 +75,7 @@ public class ExtensionLoggerController implements Initializable { text = s.substring(s.indexOf("]") + 1); } else { - classname = "black"; + classname = "label"; text = s; } @@ -82,7 +83,7 @@ public class ExtensionLoggerController implements Initializable { int index = text.indexOf(" --> ") + 5; String extensionAnnouncement = text.substring(0, index); text = text.substring(index); - elements.add(new Element(extensionAnnouncement, "black")); + elements.add(new Element(extensionAnnouncement, "label")); } elements.add(new Element(text + "\n", classname.toLowerCase())); diff --git a/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java b/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java similarity index 93% rename from G-Earth/src/main/java/gearth/ui/extra/ExtraController.java rename to G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java index 0705892..ce02079 100644 --- a/G-Earth/src/main/java/gearth/ui/extra/ExtraController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/extra/ExtraController.java @@ -1,4 +1,4 @@ -package gearth.ui.extra; +package gearth.ui.subforms.extra; import gearth.GEarth; import gearth.misc.Cacher; @@ -9,7 +9,8 @@ import gearth.protocol.connection.proxy.SocksConfiguration; import gearth.services.always_admin.AdminService; import gearth.services.g_python.GPythonVersionUtils; import gearth.ui.SubForm; -import gearth.ui.info.InfoController; +import gearth.ui.subforms.info.InfoController; +import gearth.ui.titlebar.TitleBarController; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.control.*; @@ -20,6 +21,8 @@ import javafx.scene.layout.Region; import javafx.stage.Stage; import org.json.JSONObject; +import java.io.IOException; + /** * Created by Jonas on 06/04/18. */ @@ -175,9 +178,6 @@ public class ExtraController extends SubForm implements SocksConfiguration { if (!GPythonVersionUtils.validInstallation()) { Platform.runLater(() -> { Alert alert = new Alert(Alert.AlertType.ERROR, "G-Python installation", ButtonType.OK); - Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/themes/%s/logoSmall.png", GEarth.theme)))); - stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/themes/%s/styling.css", GEarth.theme)).toExternalForm()); alert.setTitle("G-Python installation"); FlowPane fp = new FlowPane(); @@ -192,7 +192,11 @@ public class ExtraController extends SubForm implements SocksConfiguration { alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setContent(fp); - alert.show(); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } cbx_gpython.setDisable(false); }); diff --git a/G-Earth/src/main/java/gearth/ui/info/InfoController.java b/G-Earth/src/main/java/gearth/ui/subforms/info/InfoController.java similarity index 77% rename from G-Earth/src/main/java/gearth/ui/info/InfoController.java rename to G-Earth/src/main/java/gearth/ui/subforms/info/InfoController.java index 38965c8..81e8e07 100644 --- a/G-Earth/src/main/java/gearth/ui/info/InfoController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/info/InfoController.java @@ -1,14 +1,16 @@ -package gearth.ui.info; +package gearth.ui.subforms.info; import gearth.GEarth; +import gearth.ui.titlebar.TitleBarController; import javafx.event.ActionEvent; import javafx.scene.control.*; import gearth.ui.SubForm; -import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; import javafx.scene.web.WebView; -import javafx.stage.Stage; + +import java.io.IOException; /** * Created by Jonas on 06/04/18. @@ -55,15 +57,20 @@ public class InfoController extends SubForm { Alert alert = new Alert(Alert.AlertType.INFORMATION, "Donate Bitcoins", ButtonType.OK); alert.setHeaderText("Donate Bitcoins"); - WebView webView = new WebView(); - webView.getEngine().loadContent("Bitcoin public address:

" + - "" + - ""); - webView.setPrefSize(200, 100); + VBox test = new VBox(); + test.getChildren().add(new Label("Bitcoin public address:")); + TextArea pubText = new TextArea(pubkey); + pubText.setPrefHeight(28); + pubText.setMaxWidth(250); + test.getChildren().add(pubText); alert.setResizable(false); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); - alert.getDialogPane().setContent(webView); - alert.show(); + alert.getDialogPane().setContent(test); + try { + TitleBarController.create(alert).showAlert(); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/G-Earth/src/main/java/gearth/ui/injection/InjectedPackets.java b/G-Earth/src/main/java/gearth/ui/subforms/injection/InjectedPackets.java similarity index 98% rename from G-Earth/src/main/java/gearth/ui/injection/InjectedPackets.java rename to G-Earth/src/main/java/gearth/ui/subforms/injection/InjectedPackets.java index 44208ef..45f8219 100644 --- a/G-Earth/src/main/java/gearth/ui/injection/InjectedPackets.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/injection/InjectedPackets.java @@ -1,4 +1,4 @@ -package gearth.ui.injection; +package gearth.ui.subforms.injection; import gearth.misc.StringifyAble; import gearth.protocol.HMessage; diff --git a/G-Earth/src/main/java/gearth/ui/injection/InjectionController.java b/G-Earth/src/main/java/gearth/ui/subforms/injection/InjectionController.java similarity index 98% rename from G-Earth/src/main/java/gearth/ui/injection/InjectionController.java rename to G-Earth/src/main/java/gearth/ui/subforms/injection/InjectionController.java index 8267791..3ad4317 100644 --- a/G-Earth/src/main/java/gearth/ui/injection/InjectionController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/injection/InjectionController.java @@ -1,4 +1,4 @@ -package gearth.ui.injection; +package gearth.ui.subforms.injection; import gearth.misc.Cacher; import gearth.services.packet_info.PacketInfoManager; @@ -8,8 +8,6 @@ import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.control.*; import javafx.scene.input.MouseButton; -import javafx.scene.input.MouseEvent; -import javafx.scene.layout.GridPane; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.text.Text; @@ -20,7 +18,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import java.util.function.Predicate; import java.util.stream.Collectors; public class InjectionController extends SubForm { diff --git a/G-Earth/src/main/java/gearth/ui/logger/LoggerController.java b/G-Earth/src/main/java/gearth/ui/subforms/logger/LoggerController.java similarity index 96% rename from G-Earth/src/main/java/gearth/ui/logger/LoggerController.java rename to G-Earth/src/main/java/gearth/ui/subforms/logger/LoggerController.java index 1eba104..4f8c581 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/LoggerController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/logger/LoggerController.java @@ -1,4 +1,4 @@ -package gearth.ui.logger; +package gearth.ui.subforms.logger; import gearth.protocol.connection.HState; import javafx.application.Platform; @@ -12,8 +12,8 @@ import javafx.scene.text.Text; import javafx.scene.text.TextFlow; import gearth.protocol.HMessage; import gearth.ui.SubForm; -import gearth.ui.logger.loggerdisplays.PacketLogger; -import gearth.ui.logger.loggerdisplays.PacketLoggerFactory; +import gearth.ui.subforms.logger.loggerdisplays.PacketLogger; +import gearth.ui.subforms.logger.loggerdisplays.PacketLoggerFactory; import java.util.Calendar; diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/LinuxTerminalLogger.java b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/LinuxTerminalLogger.java similarity index 98% rename from G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/LinuxTerminalLogger.java rename to G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/LinuxTerminalLogger.java index 0b125a5..d6f7946 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/LinuxTerminalLogger.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/LinuxTerminalLogger.java @@ -1,4 +1,4 @@ -package gearth.ui.logger.loggerdisplays; +package gearth.ui.subforms.logger.loggerdisplays; import gearth.protocol.HMessage; import gearth.protocol.HPacket; diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLogger.java b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLogger.java similarity index 94% rename from G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLogger.java rename to G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLogger.java index a2e1770..195f844 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLogger.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLogger.java @@ -1,4 +1,4 @@ -package gearth.ui.logger.loggerdisplays; +package gearth.ui.subforms.logger.loggerdisplays; import gearth.protocol.HConnection; import gearth.protocol.HMessage; diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLoggerFactory.java b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLoggerFactory.java similarity index 77% rename from G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLoggerFactory.java rename to G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLoggerFactory.java index 82c8281..1a190b8 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/PacketLoggerFactory.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/PacketLoggerFactory.java @@ -1,13 +1,13 @@ -package gearth.ui.logger.loggerdisplays; +package gearth.ui.subforms.logger.loggerdisplays; import gearth.GEarth; -import gearth.extensions.InternalExtensionFormBuilder; +import gearth.extensions.InternalExtensionFormLauncher; import gearth.misc.OSValidator; import gearth.services.extension_handler.ExtensionHandler; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducer; import gearth.services.extension_handler.extensions.extensionproducers.ExtensionProducerObserver; import gearth.services.internal_extensions.uilogger.UiLogger; -import gearth.services.internal_extensions.uilogger.UiLoggerLauncher; +import gearth.services.internal_extensions.uilogger.UiLoggerCreator; /** * Created by Jonas on 04/04/18. @@ -40,8 +40,8 @@ public class PacketLoggerFactory implements ExtensionProducer { @Override public void startProducing(ExtensionProducerObserver observer) { if (usesUIlogger()) { - uiLogger = new InternalExtensionFormBuilder() - .launch(new UiLoggerLauncher(), observer); + uiLogger = new InternalExtensionFormLauncher() + .launch(new UiLoggerCreator(), observer); } } } diff --git a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/SimpleTerminalLogger.java b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/SimpleTerminalLogger.java similarity index 97% rename from G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/SimpleTerminalLogger.java rename to G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/SimpleTerminalLogger.java index b8aaf4e..0489a01 100644 --- a/G-Earth/src/main/java/gearth/ui/logger/loggerdisplays/SimpleTerminalLogger.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/logger/loggerdisplays/SimpleTerminalLogger.java @@ -1,4 +1,4 @@ -package gearth.ui.logger.loggerdisplays; +package gearth.ui.subforms.logger.loggerdisplays; import gearth.services.packet_info.PacketInfoManager; import gearth.protocol.HConnection; diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/InteractableScheduleItem.java b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/InteractableScheduleItem.java similarity index 95% rename from G-Earth/src/main/java/gearth/ui/scheduler/InteractableScheduleItem.java rename to G-Earth/src/main/java/gearth/ui/subforms/scheduler/InteractableScheduleItem.java index 471fab2..7651cd6 100644 --- a/G-Earth/src/main/java/gearth/ui/scheduler/InteractableScheduleItem.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/InteractableScheduleItem.java @@ -1,17 +1,14 @@ -package gearth.ui.scheduler; +package gearth.ui.subforms.scheduler; import gearth.misc.StringifyAble; import gearth.misc.listenerpattern.Observable; import gearth.protocol.HMessage; -import gearth.protocol.HPacket; import gearth.services.scheduler.Interval; import gearth.services.scheduler.ScheduleItem; import gearth.services.scheduler.listeners.OnBeingUpdatedListener; import gearth.services.scheduler.listeners.OnDeleteListener; import gearth.services.scheduler.listeners.OnEditListener; import gearth.services.scheduler.listeners.OnUpdatedListener; -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.property.SimpleStringProperty; public class InteractableScheduleItem extends ScheduleItem implements StringifyAble { diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/ScheduleItemContainer.java similarity index 89% rename from G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java rename to G-Earth/src/main/java/gearth/ui/subforms/scheduler/ScheduleItemContainer.java index 8907793..89bdaf7 100644 --- a/G-Earth/src/main/java/gearth/ui/scheduler/ScheduleItemContainer.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/ScheduleItemContainer.java @@ -1,6 +1,5 @@ -package gearth.ui.scheduler; +package gearth.ui.subforms.scheduler; -import gearth.services.scheduler.ScheduleItem; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Label; @@ -84,11 +83,21 @@ public class ScheduleItemContainer extends GridPane { parent.getChildren().add(this); + getStyleClass().clear(); + getStyleClass().add("tableRowActive"); GridPane this2 = this; item.onDelete(() -> parent.getChildren().remove(this2)); - item.onIsBeingUpdated(() -> setStyle("-fx-background-color: #faebcc;")); - item.onIsupdated(() -> setStyle("-fx-background-color: #ffffff;")); + item.onIsBeingUpdated(() -> { + getStyleClass().clear(); + getStyleClass().add("tableRowBlue"); +// setStyle("-fx-background-color: #faebcc;") + }); + item.onIsupdated(() -> { + getStyleClass().clear(); + getStyleClass().add("tableRowActive"); +// setStyle("-fx-background-color: #ffffff;") + }); } private Label initNewLabelColumn(String text) { diff --git a/G-Earth/src/main/java/gearth/ui/scheduler/SchedulerController.java b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/SchedulerController.java similarity index 98% rename from G-Earth/src/main/java/gearth/ui/scheduler/SchedulerController.java rename to G-Earth/src/main/java/gearth/ui/subforms/scheduler/SchedulerController.java index 2eef5a1..0f1ea75 100644 --- a/G-Earth/src/main/java/gearth/ui/scheduler/SchedulerController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/scheduler/SchedulerController.java @@ -1,8 +1,7 @@ -package gearth.ui.scheduler; +package gearth.ui.subforms.scheduler; import com.tulskiy.keymaster.common.Provider; import gearth.services.scheduler.Interval; -import gearth.services.scheduler.ScheduleItem; import gearth.services.scheduler.Scheduler; import javafx.application.Platform; import javafx.event.ActionEvent; @@ -17,9 +16,7 @@ import gearth.ui.SubForm; import javax.swing.*; import java.io.*; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; /** * Created by Jonas on 06/04/18. diff --git a/G-Earth/src/main/java/gearth/ui/tools/ToolsController.java b/G-Earth/src/main/java/gearth/ui/subforms/tools/ToolsController.java similarity index 98% rename from G-Earth/src/main/java/gearth/ui/tools/ToolsController.java rename to G-Earth/src/main/java/gearth/ui/subforms/tools/ToolsController.java index 701174c..bd27506 100644 --- a/G-Earth/src/main/java/gearth/ui/tools/ToolsController.java +++ b/G-Earth/src/main/java/gearth/ui/subforms/tools/ToolsController.java @@ -1,7 +1,6 @@ -package gearth.ui.tools; +package gearth.ui.subforms.tools; import gearth.services.packet_info.PacketInfoManager; -import gearth.protocol.HMessage; import javafx.event.ActionEvent; import javafx.scene.control.Button; import javafx.scene.control.TextArea; diff --git a/G-Earth/src/main/java/gearth/ui/themes/AnimeTheme.java b/G-Earth/src/main/java/gearth/ui/themes/AnimeTheme.java new file mode 100644 index 0000000..baf0a34 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/AnimeTheme.java @@ -0,0 +1,7 @@ +package gearth.ui.themes; + +public class AnimeTheme { + + // just kidding + +} diff --git a/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java b/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java new file mode 100644 index 0000000..f7139cc --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java @@ -0,0 +1,28 @@ +package gearth.ui.themes; + +public class DarkTheme implements Theme { + @Override + public String title() { + return "G-Earth Dark"; + } + + @Override + public String internalName() { + return "G-Earth_Dark"; + } + + @Override + public boolean isDark() { + return true; + } + + @Override + public boolean overridesLogo() { + return false; + } + + @Override + public boolean overridesTitle() { + return false; + } +} diff --git a/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java b/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java new file mode 100644 index 0000000..f5738da --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java @@ -0,0 +1,28 @@ +package gearth.ui.themes; + +public class LightTheme implements Theme { + @Override + public String title() { + return "G-Earth"; + } + + @Override + public String internalName() { + return "G-Earth"; + } + + @Override + public boolean isDark() { + return false; + } + + @Override + public boolean overridesLogo() { + return true; + } + + @Override + public boolean overridesTitle() { + return true; + } +} diff --git a/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java b/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java new file mode 100644 index 0000000..8d25128 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java @@ -0,0 +1,28 @@ +package gearth.ui.themes; + +public class TanjiTheme implements Theme { + @Override + public String title() { + return "Tanji"; + } + + @Override + public String internalName() { + return "Tanji"; + } + + @Override + public boolean isDark() { + return false; + } + + @Override + public boolean overridesLogo() { + return false; + } + + @Override + public boolean overridesTitle() { + return false; + } +} diff --git a/G-Earth/src/main/java/gearth/ui/themes/Theme.java b/G-Earth/src/main/java/gearth/ui/themes/Theme.java new file mode 100644 index 0000000..73460d8 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/Theme.java @@ -0,0 +1,12 @@ +package gearth.ui.themes; + +public interface Theme { + + String title(); + String internalName(); + + boolean isDark(); + boolean overridesLogo(); + boolean overridesTitle(); + +} diff --git a/G-Earth/src/main/java/gearth/ui/themes/ThemeFactory.java b/G-Earth/src/main/java/gearth/ui/themes/ThemeFactory.java new file mode 100644 index 0000000..915b27d --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/themes/ThemeFactory.java @@ -0,0 +1,27 @@ +package gearth.ui.themes; + +import java.util.Arrays; +import java.util.List; + +public class ThemeFactory { + + private static List themes = Arrays.asList( + new LightTheme(), + new TanjiTheme(), + new DarkTheme() + ); + + public static Theme getDefaultTheme() { + return themes.get(0); + } + + public static List allThemes() { + return themes; + } + + // returns default theme if not found + public static Theme themeForTitle(String title) { + return allThemes().stream().filter(theme -> theme.title().equals(title)).findFirst().orElse(getDefaultTheme()); + } + +} diff --git a/G-Earth/src/main/java/gearth/ui/titlebar/DefaultTitleBarConfig.java b/G-Earth/src/main/java/gearth/ui/titlebar/DefaultTitleBarConfig.java new file mode 100644 index 0000000..ff91776 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/titlebar/DefaultTitleBarConfig.java @@ -0,0 +1,74 @@ +package gearth.ui.titlebar; + +import gearth.GEarth; +import gearth.ui.themes.Theme; +import gearth.ui.themes.ThemeFactory; +import javafx.application.Platform; +import javafx.scene.image.Image; +import javafx.stage.Stage; + +// a typical config to be used in all windows that is not the g-earth main window +public class DefaultTitleBarConfig implements TitleBarConfig { + + protected Stage stage; + private String currentStylesheet = null; + private Theme currentTheme; + + + public DefaultTitleBarConfig(Stage stage) { + this(stage, ThemeFactory.getDefaultTheme()); + } + + public DefaultTitleBarConfig(Stage stage, Theme theme) { + this.stage = stage; + currentTheme = theme; + setTheme(theme); + } + + @Override + public boolean displayThemePicker() { + return true; + } + + @Override + public boolean displayMinimizeButton() { + return true; + } + +// @Override +// public boolean allowResizing() { +// return false; +// } + + @Override + public void onCloseClicked() { + stage.close(); + } + + @Override + public void onMinimizeClicked() { + stage.setIconified(true); + } + + @Override + public void setTheme(Theme theme) { + currentTheme = theme; + Platform.runLater(() -> { + Theme defaultTheme = ThemeFactory.getDefaultTheme(); + if (currentStylesheet != null) { + stage.getScene().getStylesheets().remove(currentStylesheet); + } + currentStylesheet = GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", theme.internalName())).toExternalForm(); + stage.getScene().getStylesheets().add(currentStylesheet); + + stage.getIcons().clear(); + stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", theme.overridesLogo() ? theme.internalName() : defaultTheme.internalName())))); + + }); + } + + @Override + public Theme getCurrentTheme() { + return currentTheme; + } +} diff --git a/G-Earth/src/main/java/gearth/ui/titlebar/GEarthThemedTitleBarConfig.java b/G-Earth/src/main/java/gearth/ui/titlebar/GEarthThemedTitleBarConfig.java new file mode 100644 index 0000000..83495a0 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/titlebar/GEarthThemedTitleBarConfig.java @@ -0,0 +1,21 @@ +package gearth.ui.titlebar; + +import gearth.GEarth; +import gearth.ui.themes.Theme; +import javafx.stage.Stage; + +import java.util.function.Consumer; + +public class GEarthThemedTitleBarConfig extends DefaultTitleBarConfig { + + public GEarthThemedTitleBarConfig(Stage stage) { + super(stage, GEarth.getTheme()); + GEarth.getThemeObservable().addListener(this::setTheme); + } + + @Override + public boolean displayThemePicker() { + return false; + } + +} diff --git a/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarConfig.java b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarConfig.java new file mode 100644 index 0000000..a83eaa9 --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarConfig.java @@ -0,0 +1,15 @@ +package gearth.ui.titlebar; + +import gearth.ui.themes.Theme; + +public interface TitleBarConfig { + + boolean displayThemePicker(); + boolean displayMinimizeButton(); +// boolean allowResizing(); + + void onCloseClicked(); + void onMinimizeClicked(); + void setTheme(Theme theme); + Theme getCurrentTheme(); +} diff --git a/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java new file mode 100644 index 0000000..aeefe0d --- /dev/null +++ b/G-Earth/src/main/java/gearth/ui/titlebar/TitleBarController.java @@ -0,0 +1,159 @@ +package gearth.ui.titlebar; + +import gearth.GEarth; +import gearth.ui.themes.ThemeFactory; +import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + +import java.io.IOException; +import java.util.Optional; + +public class TitleBarController { + + public Label titleLabel; + public Pane titleBar; + public ImageView titleIcon; + public ImageView themeBtn; + public ImageView minimizeBtn; + + private Stage stage; + private TitleBarConfig config; + + private Alert alert = null; + + public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException { + FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml")); + Parent titleBar = loader.load(); + TitleBarController controller = initNewController(loader, stage, config); + + VBox newParent = new VBox(titleBar, stage.getScene().getRoot()); + newParent.setId("titlebar-main-container"); + stage.getScene().setRoot(newParent); + + return controller; + } + + public static TitleBarController create(Alert alert) throws IOException { + + FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml")); + Parent titleBar = loader.load(); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + + TitleBarConfig config = new GEarthThemedTitleBarConfig(stage) { + @Override + public boolean displayMinimizeButton() { + return false; + } + }; + TitleBarController controller = initNewController(loader, stage, config); + + controller.alert = alert; + Parent parent = alert.getDialogPane().getScene().getRoot(); + VBox newParent = new VBox(titleBar, parent); + newParent.setId("titlebar-main-container"); + stage.setScene(new Scene(newParent)); + stage.getScene().setFill(Color.TRANSPARENT); + + return controller; + } + + private static TitleBarController initNewController(FXMLLoader loader, Stage stage, TitleBarConfig config) throws IOException { + TitleBarController controller = loader.getController(); + + controller.stage = stage; + controller.config = config; + stage.initStyle(StageStyle.TRANSPARENT); + + stage.titleProperty().addListener((i) -> controller.setTitle(stage.getTitle())); + controller.setTitle(stage.getTitle()); + + stage.getIcons().addListener((InvalidationListener) observable -> controller.updateIcon()); + controller.updateIcon(); + + Platform.runLater(() -> { + stage.getScene().setFill(Color.TRANSPARENT); + stage.getScene().getRoot().getStyleClass().add("root-node"); + + controller.themeBtn.setVisible(config.displayThemePicker()); + if (!config.displayMinimizeButton()) { + ((GridPane) controller.minimizeBtn.getParent()).getChildren().remove(controller.minimizeBtn); + } + }); + return controller; + } + + public void updateIcon() { + Platform.runLater(() -> titleIcon.setImage(stage.getIcons().size() > 0 ? stage.getIcons().get(0) : + new Image(GEarth.class.getResourceAsStream( + String.format("/gearth/ui/themes/%s/logoSmall.png", ThemeFactory.getDefaultTheme().internalName()))))); + } + + public void setTitle(String title) { + Platform.runLater(() -> titleLabel.setText(title)); + } + + + public void handleCloseAction(MouseEvent event) { + config.onCloseClicked(); + } + + public void handleMinimizeAction(MouseEvent event) { + config.onMinimizeClicked(); + } + + private double xOffset, yOffset; + private boolean isMoving = false; + + public void handleClickAction(MouseEvent event) { + xOffset = event.getSceneX(); + yOffset = event.getSceneY(); + isMoving = true; + } + + public void handleMovementAction(MouseEvent event) { + if (isMoving) { + stage.setX(event.getScreenX() - xOffset); + stage.setY(event.getScreenY() - yOffset); + } + } + + public void handleClickReleaseAction(MouseEvent mouseEvent) { + isMoving = false; + } + + public void toggleTheme(MouseEvent event) { + int themeIndex = ThemeFactory.allThemes().indexOf(config.getCurrentTheme()); + config.setTheme(ThemeFactory.allThemes().get((themeIndex + 1) % ThemeFactory.allThemes().size())); + } + + public void showAlert() { + if (alert != null) { + alert.show(); + Platform.runLater(() -> stage.sizeToScene()); + } + } + + public Optional showAlertAndWait() { + if (alert != null) { + Platform.runLater(() -> stage.sizeToScene()); + return alert.showAndWait(); + } + return Optional.empty(); + } + +} diff --git a/G-Earth/src/main/resources/gearth/services/internal_extensions/blockreplacepackets/blockreplace.fxml b/G-Earth/src/main/resources/gearth/services/internal_extensions/blockreplacepackets/blockreplace.fxml deleted file mode 100644 index 0e135cf..0000000 --- a/G-Earth/src/main/resources/gearth/services/internal_extensions/blockreplacepackets/blockreplace.fxml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/G-Earth/src/main/resources/gearth/services/internal_extensions/packetinfoexplorer/PacketInfoExplorer.fxml b/G-Earth/src/main/resources/gearth/services/internal_extensions/packetinfoexplorer/PacketInfoExplorer.fxml deleted file mode 100644 index 966234a..0000000 --- a/G-Earth/src/main/resources/gearth/services/internal_extensions/packetinfoexplorer/PacketInfoExplorer.fxml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml b/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml index cb202bf..405c104 100644 --- a/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml +++ b/G-Earth/src/main/resources/gearth/services/internal_extensions/uilogger/UiLogger.fxml @@ -13,7 +13,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/G-Earth.fxml b/G-Earth/src/main/resources/gearth/ui/G-Earth.fxml index 6dc6ac7..549ec24 100644 --- a/G-Earth/src/main/resources/gearth/ui/G-Earth.fxml +++ b/G-Earth/src/main/resources/gearth/ui/G-Earth.fxml @@ -1,64 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + diff --git a/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/connection/Connection.fxml similarity index 99% rename from G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/connection/Connection.fxml index d01b5c4..923279c 100644 --- a/G-Earth/src/main/resources/gearth/ui/connection/Connection.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/connection/Connection.fxml @@ -5,7 +5,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/Extensions.fxml similarity index 98% rename from G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/extensions/Extensions.fxml index c5539f5..0614878 100644 --- a/G-Earth/src/main/resources/gearth/ui/extensions/Extensions.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/Extensions.fxml @@ -4,7 +4,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/extensions/logger/ExtensionLogger.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/ExtensionLogger.fxml similarity index 59% rename from G-Earth/src/main/resources/gearth/ui/extensions/logger/ExtensionLogger.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/ExtensionLogger.fxml index 0fcd89f..b6fc53e 100644 --- a/G-Earth/src/main/resources/gearth/ui/extensions/logger/ExtensionLogger.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/ExtensionLogger.fxml @@ -3,7 +3,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/logger.css similarity index 93% rename from G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css rename to G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/logger.css index 6748947..37f68e3 100644 --- a/G-Earth/src/main/resources/gearth/ui/extensions/logger/logger.css +++ b/G-Earth/src/main/resources/gearth/ui/subforms/extensions/logger/logger.css @@ -64,7 +64,7 @@ } .label { - -fx-text-fill: #000000 !important; + /*-fx-text-fill: #000000 !important;*/ } .scroll-bar:vertical { diff --git a/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/extra/Extra.fxml similarity index 99% rename from G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/extra/Extra.fxml index 7368aba..f16dba0 100644 --- a/G-Earth/src/main/resources/gearth/ui/extra/Extra.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/extra/Extra.fxml @@ -4,7 +4,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/info/Info.fxml similarity index 98% rename from G-Earth/src/main/resources/gearth/ui/info/Info.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/info/Info.fxml index e19c71d..12d7e97 100644 --- a/G-Earth/src/main/resources/gearth/ui/info/Info.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/info/Info.fxml @@ -5,7 +5,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/injection/Injection.fxml similarity index 98% rename from G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/injection/Injection.fxml index 1f57489..d615c13 100644 --- a/G-Earth/src/main/resources/gearth/ui/injection/Injection.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/injection/Injection.fxml @@ -5,7 +5,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/logger/Logger.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/logger/Logger.fxml similarity index 98% rename from G-Earth/src/main/resources/gearth/ui/logger/Logger.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/logger/Logger.fxml index 67f8dc5..41988da 100644 --- a/G-Earth/src/main/resources/gearth/ui/logger/Logger.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/logger/Logger.fxml @@ -14,7 +14,7 @@ + fx:controller="gearth.ui.subforms.logger.LoggerController"> diff --git a/G-Earth/src/main/resources/gearth/ui/scheduler/Scheduler.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/scheduler/Scheduler.fxml similarity index 99% rename from G-Earth/src/main/resources/gearth/ui/scheduler/Scheduler.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/scheduler/Scheduler.fxml index bdbb415..50abd20 100644 --- a/G-Earth/src/main/resources/gearth/ui/scheduler/Scheduler.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/scheduler/Scheduler.fxml @@ -4,7 +4,7 @@ - + diff --git a/G-Earth/src/main/resources/gearth/ui/tools/Tools.fxml b/G-Earth/src/main/resources/gearth/ui/subforms/tools/Tools.fxml similarity index 99% rename from G-Earth/src/main/resources/gearth/ui/tools/Tools.fxml rename to G-Earth/src/main/resources/gearth/ui/subforms/tools/Tools.fxml index e876daa..55f0241 100644 --- a/G-Earth/src/main/resources/gearth/ui/tools/Tools.fxml +++ b/G-Earth/src/main/resources/gearth/ui/subforms/tools/Tools.fxml @@ -12,7 +12,7 @@ + fx:controller="gearth.ui.subforms.tools.ToolsController"> diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth/logo.ico b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.ico similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth/logo.ico rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.ico diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth/logo.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth/logo.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logo.png diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth/logoSmall.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logoSmall.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth/logoSmall.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth/logoSmall.png diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth/styling.css b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/styling.css similarity index 96% rename from G-Earth/src/main/resources/gearth/themes/G-Earth/styling.css rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth/styling.css index 56493f5..16ec23b 100644 --- a/G-Earth/src/main/resources/gearth/themes/G-Earth/styling.css +++ b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/styling.css @@ -1,4 +1,4 @@ -#main-window { +#titlebar-main-container { -fx-body-color : transparent; -fx-background-radius: 15; -fx-outer-border : #cecece; @@ -6,6 +6,19 @@ -fx-border-radius: 11; -fx-border-width: 0 1 1 1; } + +.themed-background { + -fx-background-color: white; +} +.themed-background2 { + -fx-background-color: #f4f4f4; +} + +.root-node > * { + -fx-background-color: white; + -fx-background-radius: 0 0 10 10; +} + .button,.menu-button,.toggle-button,.split-menu-button { -fx-font-size: 14; -fx-background-radius: 4; @@ -57,7 +70,7 @@ .info > .label, .warning > .label, .danger > .label { - -fx-text-fill: white; + -fx-text-fill: black; } .action-btn { @@ -689,7 +702,7 @@ VBox > .split-menu-button.last > .arrow-button { } .titled-pane.primary { - -fx-text-fill: white; + -fx-text-fill: black; } .titled-pane.primary > .title { @@ -903,15 +916,15 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: #0096c8; } -.internalExtension { +.tableRowBlue { -fx-background-color: #F0FFFF; } -.disconnectedExtension { +.tableRowInactive { -fx-background-color: #CCCCCC; } -.connectedExtension { +.tableRowActive { -fx-background-color: #FFFFFF; } @@ -921,39 +934,43 @@ VBox > .split-menu-button.last > .arrow-button { } #close-button { - -fx-image: url("../../ui/titlebar/files/closeButton.png"); + -fx-image: url("../../titlebar/files/closeButton.png"); } #close-button:hover { - -fx-image: url("../../ui/titlebar/files/closeButtonHover.png"); + -fx-image: url("../../titlebar/files/closeButtonHover.png"); } #close-button:pressed { - -fx-image: url("../../ui/titlebar/files/closeButtonPressed.png"); + -fx-image: url("../../titlebar/files/closeButtonPressed.png"); } #minimize-button { - -fx-image: url("../../ui/titlebar/files/minimizeButton.png"); + -fx-image: url("../../titlebar/files/minimizeButton.png"); } #minimize-button:hover { - -fx-image: url("../../ui/titlebar/files/minimizeButtonHover.png"); + -fx-image: url("../../titlebar/files/minimizeButtonHover.png"); } #minimize-button:pressed { - -fx-image: url("../../ui/titlebar/files/minimizeButtonPressed.png"); + -fx-image: url("../../titlebar/files/minimizeButtonPressed.png"); } #main-tab-pane, #main-tab-pane > * { -fx-background-radius: 0 0 10 10; } +.root-node { + -fx-background-radius: 0 0 10 10; +} + #icon { - -fx-image: url("./logoSmall.png"); + /*-fx-image: url("logoSmall.png");*/ } #theme-button { - -fx-image: url("./themeButton.png"); + -fx-image: url("themeButton.png"); } .corrupted-label { @@ -968,6 +985,10 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: black; } +.label.softer { + -fx-text-fill: rgba(0, 0, 0, 0.8); +} + .list-view { -fx-border-color: #cccccc; -fx-border-radius: 4; diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth/themeButton.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth/themeButton.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth/themeButton.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth/themeButton.png diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logo.ico b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logo.ico similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logo.ico rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logo.ico diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logo.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logo.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logo.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logo.png diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logoSmall.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logoSmall.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/logoSmall.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/logoSmall.png diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/styling.css b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/styling.css similarity index 93% rename from G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/styling.css rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/styling.css index 5bb9e90..fd0babd 100644 --- a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/styling.css +++ b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/styling.css @@ -1,4 +1,4 @@ -#main-window { +#titlebar-main-container { -fx-body-color : transparent; -fx-background-radius: 15; -fx-outer-border: #222222; @@ -8,6 +8,18 @@ -fx-border-width: 0 1 1 1; } +.themed-background { + -fx-background-color: #363636; +} +.themed-background2 { + -fx-background-color: #222222; +} + +.root-node > * { + -fx-background-color: #363636; + -fx-background-radius: 0 0 10 10; +} + .button,.menu-button,.toggle-button,.split-menu-button { -fx-font-size: 14; -fx-background-radius: 4; @@ -925,15 +937,15 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: #0096c8; } -.internalExtension { +.tableRowBlue { -fx-background-color: #3d5b69; } -.disconnectedExtension { +.tableRowInactive { -fx-background-color: #5e5e5e; } -.connectedExtension { +.tableRowActive { -fx-background-color: #525252; } @@ -960,49 +972,52 @@ VBox > .split-menu-button.last > .arrow-button { } #close-button { - -fx-image: url("../../ui/titlebar/files/closeButtonDark.png"); + -fx-image: url("../../titlebar/files/closeButtonDark.png"); -fx-padding: 10; -fx-background-color: firebrick; } #close-button:hover { - -fx-image: url("../../ui/titlebar/files/closeButtonHover.png"); + -fx-image: url("../../titlebar/files/closeButtonHover.png"); -fx-background-color: #e81123; } #close-button:pressed { - -fx-image: url("../../ui/titlebar/files/closeButtonPressed.png"); + -fx-image: url("../../titlebar/files/closeButtonPressed.png"); -fx-background-color: rgba(232, 17, 35, 0.8); } #minimize-button { - -fx-image: url("../../ui/titlebar/files/minimizeButtonDark.png"); + -fx-image: url("../../titlebar/files/minimizeButtonDark.png"); } #minimize-button:hover { - -fx-image: url("../../ui/titlebar/files/minimizeButtonDarkHover.png"); + -fx-image: url("../../titlebar/files/minimizeButtonDarkHover.png"); } #minimize-button:pressed { - -fx-image: url("../../ui/titlebar/files/minimizeButtonDarkPressed.png"); + -fx-image: url("../../titlebar/files/minimizeButtonDarkPressed.png"); } #main-tab-pane, #main-tab-pane > * { -fx-background-radius: 0 0 10 10; } +.root-node { + -fx-background-radius: 0 0 10 10; +} + #icon { - -fx-image: url("./logoSmall.png"); + /*-fx-image: url("logoSmall.png");*/ } #theme-button { - -fx-image: url("./themeButton.png"); + -fx-image: url("themeButton.png"); } /* Error window */ .dialog-pane { -fx-background-color: #333333; - -fx-background-radius: 0; } .dialog-pane:header .header-panel { @@ -1031,6 +1046,10 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: #f0f0f0 !important; } +.label.softer { + -fx-text-fill: rgba(240, 240, 240, 0.8); +} + .pckt-info { -fx-fill: #ffffffa0; } @@ -1041,4 +1060,56 @@ VBox > .split-menu-button.last > .arrow-button { .not-corrupted-label { -fx-fill: #8cff8c; +} + +.table-view { + -fx-background-color: rgba(20, 20, 20, 0.4); +} + +.table-view .table-cell{ + -fx-text-fill: #f0f0f0; +} + +.table-row-cell{ + -fx-background-color: #313131; +} + + +.table-view .column-header { + -fx-background-color: #212121; +} + +.table-view .table-cell{ + -fx-border-color: #262626; + -fx-border-width: 0.5; +} + +.table-row-cell:selected, .list-cell:selected { + -fx-background-color: #364349; +} + +.table-view:focused .table-row-cell:selected, .list-view:focused .list-cell:selected { + -fx-background-color: #3d5b69; +} + +.spinner .increment-arrow-button, +.spinner .decrement-arrow-button { + -fx-body-color: #262626; +} + +.spinner .increment-arrow-button .increment-arrow, +.spinner .decrement-arrow-button .decrement-arrow { + -fx-background-color: #d7d7d7; +} + +.slider .track { + -fx-background-color: #222222; + -fx-border-radius: 5; + -fx-border-color: rgba(240, 240, 240, 0.8); +} + +.slider .thumb { + -fx-background-color: #222222; + -fx-border-radius: 10; + -fx-border-color: rgba(240, 240, 240, 0.8); } \ No newline at end of file diff --git a/G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/themeButton.png b/G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/themeButton.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/G-Earth_Dark/themeButton.png rename to G-Earth/src/main/resources/gearth/ui/themes/G-Earth_Dark/themeButton.png diff --git a/G-Earth/src/main/resources/gearth/themes/Tanji/logo.ico b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/logo.ico similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/Tanji/logo.ico rename to G-Earth/src/main/resources/gearth/ui/themes/Tanji/logo.ico diff --git a/G-Earth/src/main/resources/gearth/themes/Tanji/logo.png b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/logo.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/Tanji/logo.png rename to G-Earth/src/main/resources/gearth/ui/themes/Tanji/logo.png diff --git a/G-Earth/src/main/resources/gearth/themes/Tanji/logoSmall.png b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/logoSmall.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/Tanji/logoSmall.png rename to G-Earth/src/main/resources/gearth/ui/themes/Tanji/logoSmall.png diff --git a/G-Earth/src/main/resources/gearth/themes/Tanji/styling.css b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/styling.css similarity index 96% rename from G-Earth/src/main/resources/gearth/themes/Tanji/styling.css rename to G-Earth/src/main/resources/gearth/ui/themes/Tanji/styling.css index 386f8e5..b93c57d 100644 --- a/G-Earth/src/main/resources/gearth/themes/Tanji/styling.css +++ b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/styling.css @@ -1,4 +1,4 @@ -#main-window { +#titlebar-main-container { -fx-body-color : transparent; -fx-background-radius: 15; -fx-outer-border : #cecece; @@ -7,6 +7,18 @@ -fx-border-width: 0 1 1 1; } +.themed-background { + -fx-background-color: white; +} +.themed-background2 { + -fx-background-color: #f4f4f4; +} + +.root-node > * { + -fx-background-color: white; + -fx-background-radius: 0 0 10 10; +} + .button,.menu-button,.toggle-button,.split-menu-button { -fx-font-size: 14; -fx-background-radius: 4; @@ -59,7 +71,7 @@ .info > .label, .warning > .label, .danger > .label { - -fx-text-fill: white; + -fx-text-fill: black; } .action-btn { @@ -691,7 +703,7 @@ VBox > .split-menu-button.last > .arrow-button { } .titled-pane.primary { - -fx-text-fill: white; + -fx-text-fill: black; } .titled-pane.primary > .title { @@ -903,15 +915,15 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: #c88600; } -.internalExtension { +.tableRowBlue { -fx-background-color: #fff0e3; } -.disconnectedExtension { +.tableRowInactive { -fx-background-color: #CCCCCC; } -.connectedExtension { +.tableRowActive { -fx-background-color: #FFFFFF; } @@ -921,39 +933,43 @@ VBox > .split-menu-button.last > .arrow-button { } #close-button { - -fx-image: url("../../ui/titlebar/files/closeButton.png"); + -fx-image: url("../../titlebar/files/closeButton.png"); } #close-button:hover { - -fx-image: url("../../ui/titlebar/files/closeButtonHover.png"); + -fx-image: url("../../titlebar/files/closeButtonHover.png"); } #close-button:pressed { - -fx-image: url("../../ui/titlebar/files/closeButtonPressed.png"); + -fx-image: url("../../titlebar/files/closeButtonPressed.png"); } #minimize-button { - -fx-image: url("../../ui/titlebar/files/minimizeButton.png"); + -fx-image: url("../../titlebar/files/minimizeButton.png"); } #minimize-button:hover { - -fx-image: url("../../ui/titlebar/files/minimizeButtonHover.png"); + -fx-image: url("../../titlebar/files/minimizeButtonHover.png"); } #minimize-button:pressed { - -fx-image: url("../../ui/titlebar/files/minimizeButtonPressed.png"); + -fx-image: url("../../titlebar/files/minimizeButtonPressed.png"); } #main-tab-pane, #main-tab-pane > * { -fx-background-radius: 0 0 10 10; } +.root-node { + -fx-background-radius: 0 0 10 10; +} + #icon { - -fx-image: url("./logoSmall.png"); + /*-fx-image: url("logoSmall.png");*/ } #theme-button { - -fx-image: url("./themeButton.png"); + -fx-image: url("themeButton.png"); } .corrupted-label { @@ -968,6 +984,10 @@ VBox > .split-menu-button.last > .arrow-button { -fx-text-fill: black; } +.label.softer { + -fx-text-fill: rgba(0, 0, 0, 0.8); +} + .list-view { -fx-border-color: #cccccc; -fx-border-radius: 4; diff --git a/G-Earth/src/main/resources/gearth/themes/Tanji/themeButton.png b/G-Earth/src/main/resources/gearth/ui/themes/Tanji/themeButton.png similarity index 100% rename from G-Earth/src/main/resources/gearth/themes/Tanji/themeButton.png rename to G-Earth/src/main/resources/gearth/ui/themes/Tanji/themeButton.png diff --git a/G-Earth/src/main/resources/gearth/ui/titlebar/Titlebar.fxml b/G-Earth/src/main/resources/gearth/ui/titlebar/Titlebar.fxml new file mode 100644 index 0000000..d5c4bf6 --- /dev/null +++ b/G-Earth/src/main/resources/gearth/ui/titlebar/Titlebar.fxml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +