Skip to content

Commit

Permalink
process check
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Oct 14, 2022
1 parent f183580 commit 8913767
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion resources/card-generator.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion resources/overlay-generator.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 35 additions & 1 deletion src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
}
}
24 changes: 1 addition & 23 deletions src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.");
Expand Down Expand Up @@ -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();
}
}
}
}

0 comments on commit 8913767

Please sign in to comment.