Skip to content

Commit

Permalink
show info window instead of debug window
Browse files Browse the repository at this point in the history
  • Loading branch information
Geosearchef committed Apr 19, 2019
1 parent 5db8535 commit f7eb530
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.");
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
23 changes: 2 additions & 21 deletions ice-adapter/src/main/resources/debugWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import java.net.URL?>
Expand All @@ -10,26 +10,7 @@
<VBox prefHeight="700.0" prefWidth="1200.0">
<HBox>
<padding>
<Insets bottom="0" left="5" right="5" top="5" />
</padding>

<Label text="FAForever is currently testing a new connectivity solution to reduce disconnects while in game."></Label>
</HBox>
<HBox>
<padding>
<Insets bottom="0" left="5" right="5" top="0" />
</padding>
<Label text="Please keep this window open while the game is in progress." />
</HBox>
<HBox>
<padding>
<Insets bottom="0" left="5" right="5" top="0" />
</padding>
<Label text="To manually stop the ice adapter click here:" />
</HBox>
<HBox>
<padding>
<Insets bottom="50" left="5" right="5" top="5" />
<Insets bottom="10" left="5" right="5" top="5" />
</padding>
<Button fx:id="killAdapterButton" text="CLOSE ADAPTER. This will disconnect you from the game!" />
</HBox>
Expand Down
71 changes: 71 additions & 0 deletions ice-adapter/src/main/resources/infoWindow.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import java.net.URL?>
<AnchorPane prefHeight="533.0" prefWidth="330.0" xmlns="http://javafx.com/javafx/8.0.121"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.faforever.iceadapter.debug.InfoWindowController">
<children>

<VBox prefHeight="330.0" prefWidth="533.0" alignment="CENTER" spacing="5">
<padding>
<Insets bottom="5" left="5" right="5" top="5"/>
</padding>

<ImageView fitHeight="70.0" fitWidth="70.0">
<image>
<Image url="https://faforever.com/images/faf-logo.png"/>
</image>
</ImageView>

<HBox>
<padding>
<Insets bottom="2" left="5" right="5" top="2"/>
</padding>
</HBox>

<Label text="FAForever is currently testing a new connectivity solution to reduce&#10;disconnects while in game."
wrapText="true" textAlignment="CENTER"></Label>


<HBox>
<padding>
<Insets bottom="5" left="5" right="5" top="5"/>
</padding>
</HBox>

<Label text="Please keep this window open while the game is in progress." styleClass="bold-text" textAlignment="CENTER"/>
<Label text="To manually stop the ice adapter click here:" textAlignment="CENTER"/>

<HBox>
<padding>
<Insets bottom="5" left="5" right="5" top="5"/>
</padding>

</HBox>

<Button fx:id="killAdapterButton"
text="Clicking here will close the adapter&#10;This will disconnect you from the game!"
focusTraversable="false" wrapText="true" textAlignment="CENTER">
</Button>

<HBox>
<padding>
<Insets bottom="5" left="5" right="5" top="5"/>
</padding>

</HBox>

<Button fx:id="showDebugWindowButton" text="Show debug window"/>

</VBox>

</children>

<stylesheets>
<URL value="@infoWindowStyle.css"/>
</stylesheets>
</AnchorPane>
17 changes: 17 additions & 0 deletions ice-adapter/src/main/resources/infoWindowStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.root {
-fx-base: rgba(60, 63, 65, 255);

}

.text-area .content{
/*-fx-background-color: linear-gradient(from 0px 0px to 0px 4px, derive(rgba(36, 36, 36), -8%), rgba(36, 36, 36));*/
-fx-background-color: rgba(36, 36, 36, 36);
}

.text-area {
-fx-text-fill: rgb(154, 154, 154)
}

.bold-text {
-fx-font-weight: bold;
}

0 comments on commit f7eb530

Please sign in to comment.