From f7eb530629b1ec2039d9ea94739fa27ea2e6bd95 Mon Sep 17 00:00:00 2001 From: Geosearchef Date: Fri, 19 Apr 2019 23:13:02 +0200 Subject: [PATCH] show info window instead of debug window --- .../iceadapter/debug/DebugWindow.java | 16 ++++- .../iceadapter/debug/InfoWindow.java | 57 +++++++++++++++ .../debug/InfoWindowController.java | 28 ++++++++ .../src/main/resources/debugWindow.fxml | 23 +----- .../src/main/resources/infoWindow.fxml | 71 +++++++++++++++++++ .../src/main/resources/infoWindowStyle.css | 17 +++++ 6 files changed, 189 insertions(+), 23 deletions(-) create mode 100644 ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindow.java create mode 100644 ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindowController.java create mode 100644 ice-adapter/src/main/resources/infoWindow.fxml create mode 100644 ice-adapter/src/main/resources/infoWindowStyle.css diff --git a/ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java index a288d86..9e3277f 100644 --- a/ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java +++ b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java @@ -13,10 +13,10 @@ import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import javafx.event.Event; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; +import javafx.scene.image.Image; import javafx.stage.Stage; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; @@ -36,6 +36,7 @@ public class DebugWindow extends Application implements Debugger { private Parent root; private Scene scene; private DebugWindowController controller; + private Stage stage; private static final int WIDTH = 1200; private static final int HEIGHT = 700; @@ -45,6 +46,9 @@ public class DebugWindow extends Application implements Debugger { @Override public void start(Stage stage) { + this.stage = stage; + stage.getIcons().add(new Image("https://faforever.com/images/faf-logo.png")); + try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/debugWindow.fxml")); root = loader.load(); @@ -62,12 +66,20 @@ public void start(Stage stage) { stage.setScene(scene); stage.setTitle(String.format("FAF ICE adapter - Debugger - Build: %s", IceAdapter.VERSION)); - stage.setOnCloseRequest(Event::consume); +// stage.setOnCloseRequest(Event::consume); stage.show(); + stage.hide(); // wait till requested by user + // new Thread(() -> Debug.debug.complete(this)).start(); log.info("Created debug window."); Debug.debug.complete(this); + + new InfoWindow().init(); + } + + public void showWindow() { + runOnUIThread(() -> stage.show()); } @Override diff --git a/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindow.java b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindow.java new file mode 100644 index 0000000..b7e4d6c --- /dev/null +++ b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindow.java @@ -0,0 +1,57 @@ +package com.faforever.iceadapter.debug; + +import javafx.event.Event; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.stage.Stage; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; + +import static javafx.application.Application.STYLESHEET_MODENA; +import static javafx.application.Application.setUserAgentStylesheet; + +@Slf4j +public class InfoWindow { + + private Stage stage; + private Parent root; + private Scene scene; + private InfoWindowController controller; + + private static final int WIDTH = 533; + private static final int HEIGHT = 330; + + public InfoWindow() { + + } + + public void init() { + stage = new Stage(); + stage.getIcons().add(new Image("https://faforever.com/images/faf-logo.png")); + + try { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/infoWindow.fxml")); + root = loader.load(); + + controller = loader.getController(); + + } catch (IOException e) { + log.error("Could not load debugger window fxml", e); + } + + setUserAgentStylesheet(STYLESHEET_MODENA); + + scene = new Scene(root, WIDTH, HEIGHT); + + stage.setScene(scene); + stage.setTitle("FAF ICE adapter"); + stage.setOnCloseRequest(Event::consume); + stage.show(); + + + log.info("Created info window."); + } +} diff --git a/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindowController.java b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindowController.java new file mode 100644 index 0000000..1a2b820 --- /dev/null +++ b/ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindowController.java @@ -0,0 +1,28 @@ +package com.faforever.iceadapter.debug; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; + +public class InfoWindowController { + public Button killAdapterButton; + public Button showDebugWindowButton; + + public void onKillAdapterClicked(ActionEvent actionEvent) { + System.exit(337); + } + + public void onShowDebugWindowClicked(ActionEvent actionEvent) { + Debug.debug.thenAcceptAsync(debugger -> { + if(debugger instanceof DebugWindow) { + ((DebugWindow)debugger).showWindow(); + } + }); + } + + @FXML + private void initialize() { + killAdapterButton.setOnAction(this::onKillAdapterClicked); + showDebugWindowButton.setOnAction(this::onShowDebugWindowClicked); + } +} diff --git a/ice-adapter/src/main/resources/debugWindow.fxml b/ice-adapter/src/main/resources/debugWindow.fxml index 94966ad..31b3b4f 100644 --- a/ice-adapter/src/main/resources/debugWindow.fxml +++ b/ice-adapter/src/main/resources/debugWindow.fxml @@ -1,6 +1,6 @@ - + @@ -10,26 +10,7 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + +