-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply code formatting with Spotless and palantir format
- Loading branch information
1 parent
4661c19
commit a198728
Showing
46 changed files
with
1,264 additions
and
1,027 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 54 additions & 49 deletions
103
ice-adapter/src/main/java/com/faforever/iceadapter/debug/Debug.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,71 @@ | ||
package com.faforever.iceadapter.debug; | ||
|
||
import com.faforever.iceadapter.IceAdapter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class Debug { | ||
//TODO | ||
public static boolean ENABLE_DEBUG_WINDOW_LOG_TEXT_AREA = false; // disabled as this causes high memory and cpu load, should be replaced by limiting the number of lines in the text area | ||
|
||
public static boolean ENABLE_DEBUG_WINDOW = false; | ||
public static boolean ENABLE_INFO_WINDOW = false; | ||
public static int DELAY_UI_MS = 0;//delays the launch of the user interface by X ms | ||
// TODO | ||
public static boolean ENABLE_DEBUG_WINDOW_LOG_TEXT_AREA = | ||
false; // disabled as this causes high memory and cpu load, should be replaced by limiting the number of | ||
// lines in the text area | ||
|
||
private final static DebugFacade debugFacade = new DebugFacade(); | ||
public static boolean ENABLE_DEBUG_WINDOW = false; | ||
public static boolean ENABLE_INFO_WINDOW = false; | ||
public static int DELAY_UI_MS = 0; // delays the launch of the user interface by X ms | ||
|
||
public static void register(Debugger debugger) { | ||
debugFacade.add(debugger); | ||
} | ||
private static final DebugFacade debugFacade = new DebugFacade(); | ||
|
||
public static void remove(Debugger debugger) { | ||
debugFacade.remove(debugger); | ||
} | ||
public static void register(Debugger debugger) { | ||
debugFacade.add(debugger); | ||
} | ||
|
||
public static void init() { | ||
new TelemetryDebugger(IceAdapter.TELEMETRY_SERVER, IceAdapter.gameId, IceAdapter.id); | ||
public static void remove(Debugger debugger) { | ||
debugFacade.remove(debugger); | ||
} | ||
|
||
// 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 | ||
// This is not used anymore as the debug window is started and hidden in case it is requested via the tray icon | ||
if(! ENABLE_DEBUG_WINDOW && ! ENABLE_INFO_WINDOW) { | ||
return; | ||
} | ||
public static void init() { | ||
new TelemetryDebugger(IceAdapter.TELEMETRY_SERVER, IceAdapter.gameId, IceAdapter.id); | ||
|
||
if(isJavaFxSupported()) { | ||
new Thread(() -> { | ||
try { | ||
Class.forName("com.faforever.iceadapter.debug.DebugWindow").getMethod("launchApplication").invoke(null); | ||
} catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { | ||
e.printStackTrace(); | ||
log.error("Could not create DebugWindow. Running without debug window."); | ||
} | ||
}).start(); //Completes future once application started | ||
} else { | ||
log.info("No JavaFX support detected. Running without debug window."); | ||
} | ||
} | ||
// 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 | ||
// This is not used anymore as the debug window is started and hidden in case it is requested via the tray icon | ||
if (!ENABLE_DEBUG_WINDOW && !ENABLE_INFO_WINDOW) { | ||
return; | ||
} | ||
|
||
if (isJavaFxSupported()) { | ||
new Thread(() -> { | ||
try { | ||
Class.forName("com.faforever.iceadapter.debug.DebugWindow") | ||
.getMethod("launchApplication") | ||
.invoke(null); | ||
} catch (IllegalAccessException | ||
| ClassNotFoundException | ||
| NoSuchMethodException | ||
| InvocationTargetException e) { | ||
e.printStackTrace(); | ||
log.error("Could not create DebugWindow. Running without debug window."); | ||
} | ||
}) | ||
.start(); // Completes future once application started | ||
} else { | ||
log.info("No JavaFX support detected. Running without debug window."); | ||
} | ||
} | ||
|
||
public static Debugger debug() { | ||
return debugFacade; | ||
} | ||
public static Debugger debug() { | ||
return debugFacade; | ||
} | ||
|
||
public static boolean isJavaFxSupported() { | ||
try { | ||
Debug.class.getClassLoader().loadClass("javafx.application.Application"); | ||
return true; | ||
} catch(ClassNotFoundException e) { | ||
log.warn("Could not create debug window, no JavaFX found."); | ||
return false; | ||
} | ||
} | ||
public static boolean isJavaFxSupported() { | ||
try { | ||
Debug.class.getClassLoader().loadClass("javafx.application.Application"); | ||
return true; | ||
} catch (ClassNotFoundException e) { | ||
log.warn("Could not create debug window, no JavaFX found."); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.