Skip to content

Commit f0e26f2

Browse files
committed
Tray icon / Info Window fixes
1 parent 1333c1d commit f0e26f2

6 files changed

Lines changed: 27 additions & 8 deletions

File tree

ice-adapter/src/main/java/com/faforever/iceadapter/IceAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public static void close() {
143143
onFAShutdown();//will close gameSession aswell
144144
GPGNetServer.close();
145145
RPCService.close();
146+
TrayIcon.close();
146147

147148
System.exit(0);
148149
}

ice-adapter/src/main/java/com/faforever/iceadapter/debug/Debug.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Debug {
1919

2020
public static void init() {
2121
// Debugger window is started and set to debugFuture when either window is requested as the info window can be used to open the debug window
22+
// This is not used anymore as the debug window is started and hidden in case it is requested via the tray icon
2223
if(! ENABLE_DEBUG_WINDOW && ! ENABLE_INFO_WINDOW) {
2324
debug.complete(new NoDebugger());
2425
return;

ice-adapter/src/main/java/com/faforever/iceadapter/debug/DebugWindow.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public void start(Stage stage) {
7676

7777
// new Thread(() -> Debug.debug.complete(this)).start();
7878
log.info("Created debug window.");
79+
80+
//TODO: this is pretty hacky, replaces NoDebugger in case the context got just created from the tray icon
81+
if (Debug.debug.isDone()) {
82+
Debug.debug = new CompletableFuture<>();
83+
}
7984
Debug.debug.complete(this);
8085

8186
if(Debug.ENABLE_INFO_WINDOW) {

ice-adapter/src/main/java/com/faforever/iceadapter/debug/InfoWindow.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ public void init() {
5959
}
6060

6161
public void minimize() {
62+
Platform.setImplicitExit(false);
6263
Platform.runLater(this.stage::hide);
6364
}
6465

6566
public void show() {
66-
Platform.runLater(this.stage::show);
67+
Platform.runLater(() -> {
68+
this.stage.show();
69+
Platform.setImplicitExit(true);
70+
});
6771
}
6872
}

ice-adapter/src/main/java/com/faforever/iceadapter/util/TrayIcon.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.faforever.iceadapter.util;
22

3+
import com.faforever.iceadapter.debug.Debug;
4+
import com.faforever.iceadapter.debug.DebugWindow;
35
import com.faforever.iceadapter.debug.InfoWindow;
46
import lombok.extern.slf4j.Slf4j;
57

@@ -42,9 +44,14 @@ public void mouseClicked(MouseEvent mouseEvent) {
4244

4345
@Override
4446
public void mousePressed(MouseEvent mouseEvent) {
45-
if (InfoWindow.INSTANCE != null) {
46-
InfoWindow.INSTANCE.show();
47-
}
47+
new Thread(() -> {
48+
if (InfoWindow.INSTANCE == null) {
49+
Debug.ENABLE_INFO_WINDOW = true;
50+
DebugWindow.launchApplication();
51+
} else {
52+
InfoWindow.INSTANCE.show();
53+
}
54+
}).start();
4855
}
4956

5057
@Override
@@ -60,14 +67,14 @@ public void mouseExited(MouseEvent mouseEvent) {
6067
}
6168
});
6269

63-
showMessage("ICE Adapter started");
64-
6570
try {
6671
SystemTray.getSystemTray().add(trayIcon);
6772
} catch (AWTException e) {
6873
log.error("Tray icon could not be added", e);
6974
}
7075

76+
showMessage("ICE Adapter started");
77+
7178
log.info("Created tray icon");
7279
}
7380

ice-adapter/src/main/resources/infoWindow.fxml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</padding>
2828
</HBox>
2929

30-
<Label text="FAForever is currently testing a new connectivity solution to reduce&#10;disconnects while in game."
30+
<Label text="This adapter establishes and monitors your connection to other players in game.&#10;Closing it will terminate all connections."
3131
wrapText="true" textAlignment="CENTER"></Label>
3232

3333

@@ -37,7 +37,8 @@
3737
</padding>
3838
</HBox>
3939

40-
<Label text="Please keep this window open while the game is in progress." styleClass="bold-text" textAlignment="CENTER"/>
40+
<Label text="Please keep it running while the game is in progress." styleClass="bold-text"
41+
textAlignment="CENTER"/>
4142

4243
<HBox>
4344
<padding>

0 commit comments

Comments
 (0)