diff --git a/resources/card-generator.properties b/resources/card-generator.properties index b9e077b..ca6aaa8 100644 --- a/resources/card-generator.properties +++ b/resources/card-generator.properties @@ -1,4 +1,4 @@ -#Fri Oct 14 14:46:43 CEST 2022 +#Fri Oct 14 15:26:47 CEST 2022 card.alphacomposite.black=5 card.alphacomposite.white=0 card.background=Old Bumbers.jpg diff --git a/resources/overlay-generator.properties b/resources/overlay-generator.properties index 899a805..b4fd20b 100644 --- a/resources/overlay-generator.properties +++ b/resources/overlay-generator.properties @@ -1,4 +1,4 @@ -#Fri Oct 14 14:46:43 CEST 2022 +#Fri Oct 14 15:26:46 CEST 2022 overlay.alphacomposite.black=0 overlay.alphacomposite.white=0 overlay.background=background4k.jpg diff --git a/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java b/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java index f54698f..56ee6d7 100644 --- a/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java +++ b/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java @@ -1,10 +1,13 @@ package de.mephisto.vpin.extensions; +import de.mephisto.vpin.VPinService; import de.mephisto.vpin.extensions.generator.OverlayGenerator; import de.mephisto.vpin.extensions.generator.OverlayGraphics; import de.mephisto.vpin.extensions.resources.ResourceLoader; import de.mephisto.vpin.extensions.util.Config; +import de.mephisto.vpin.popper.PopperLaunchListener; import de.mephisto.vpin.util.KeyChecker; +import de.mephisto.vpin.util.SystemInfo; import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Rectangle2D; @@ -25,7 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -public class OverlayWindowFX extends Application implements NativeKeyListener { +public class OverlayWindowFX extends Application implements NativeKeyListener, PopperLaunchListener { private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(OverlayGraphics.class); private boolean visible = false; @@ -76,6 +79,16 @@ public void start(Stage primaryStage) throws Exception { logger.setLevel(Level.OFF); logger.setUseParentHandlers(false); GlobalScreen.addNativeKeyListener(this); + + boolean pinUPRunning = SystemInfo.getInstance().isPinUPRunning(); + if(pinUPRunning) { + popperLaunched(); + } + else { + LOG.info("Added VPin service popper status listener."); + VPinService service = VPinService.create(true); + service.addPopperLaunchListener(this); + } } @Override @@ -109,4 +122,25 @@ public void toggleView() { public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) { } + + + + @Override + public void popperLaunched() { + boolean launch = Config.getOverlayGeneratorConfig().getBoolean("overlay.launchOnStartup"); + if (launch) { + int delay = Config.getOverlayGeneratorConfig().getInt("overlay.launchDelay", 0); + if (delay > 0) { + try { + Thread.sleep(delay * 1000L); + } catch (InterruptedException e) { + LOG.error("Failed to wait for delay: " + e.getMessage(), e); + } + } + + if(OverlayWindowFX.INSTANCE != null) { + OverlayWindowFX.INSTANCE.toggleView(); + } + } + } } diff --git a/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java b/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java index b98eb3c..75f0b3e 100644 --- a/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java +++ b/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java @@ -13,7 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ServiceRunner implements TableStatusChangeListener, PopperLaunchListener { +public class ServiceRunner implements TableStatusChangeListener { private final static Logger LOG = LoggerFactory.getLogger(ServiceRunner.class); private VPinService service; @@ -25,9 +25,6 @@ public ServiceRunner() { LOG.info("Added VPin service listener for highscore changes."); service.addTableStatusChangeListener(this); - LOG.info("Added VPin service popper status listener."); - service.addPopperLaunchListener(this); - String targetScreen = Config.getCardGeneratorConfig().get("popper.screen"); if (StringUtils.isEmpty(targetScreen)) { LOG.info("Skipped starting highscore card generator, no PinUP popper target screen configured."); @@ -70,23 +67,4 @@ public void tableExited(TableStatusChangedEvent tableStatusChangedEvent) { LOG.error("Failed to generate highscore card for " + tableStatusChangedEvent.getGameInfo() + ": " + e.getMessage(), e); } } - - @Override - public void popperLaunched() { - boolean launch = Config.getOverlayGeneratorConfig().getBoolean("overlay.launchOnStartup"); - if (launch) { - int delay = Config.getOverlayGeneratorConfig().getInt("overlay.launchDelay", 0); - if (delay > 0) { - try { - Thread.sleep(delay * 1000L); - } catch (InterruptedException e) { - LOG.error("Failed to wait for delay: " + e.getMessage(), e); - } - } - - if(OverlayWindowFX.INSTANCE != null) { - OverlayWindowFX.INSTANCE.toggleView(); - } - } - } }