diff --git a/resources/card-generator.properties b/resources/card-generator.properties index 377cb16..bf143ff 100644 --- a/resources/card-generator.properties +++ b/resources/card-generator.properties @@ -1,4 +1,4 @@ -#Thu Sep 29 19:05:48 CEST 2022 +#Thu Sep 29 22:05:24 CEST 2022 card.alphacomposite.black=5 card.alphacomposite.white=0 card.background=Old Bumbers.jpg @@ -10,7 +10,7 @@ card.highscore.font.name=Digital-7 Italic card.highscores.row.padding.left=87 card.highscores.row.separator=28 card.ratio=RATIO_16x9 -card.sampleTable=19 +card.sampleTable=58 card.score.font.font.style=0 card.score.font.name=Amiri card.score.font.size=80 diff --git a/resources/highscore-card-sample.png b/resources/highscore-card-sample.png index c9cca7f..f363575 100644 Binary files a/resources/highscore-card-sample.png and b/resources/highscore-card-sample.png differ diff --git a/resources/overlay-generator.properties b/resources/overlay-generator.properties index da3160c..4784509 100644 --- a/resources/overlay-generator.properties +++ b/resources/overlay-generator.properties @@ -1,4 +1,4 @@ -#Thu Sep 29 19:01:40 CEST 2022 +#Thu Sep 29 22:05:06 CEST 2022 overlay.alphacomposite.black=0 overlay.alphacomposite.white=0 overlay.background=background4k.jpg @@ -8,7 +8,7 @@ overlay.font.color=\#ffffff overlay.highscores.row.padding.left=87 overlay.highscores.row.separator=24 overlay.highscores.text=Latest Highscores -overlay.hotkey=2+F1 +overlay.hotkey=F4 overlay.score.font.font.style=0 overlay.score.font.name=Digiface overlay.score.font.size=100 diff --git a/resources/overlay.jpg b/resources/overlay.jpg index 5f2effd..f5024a4 100644 Binary files a/resources/overlay.jpg and b/resources/overlay.jpg differ diff --git a/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java b/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java index 282f6f3..cc4b273 100644 --- a/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java +++ b/src/main/java/de/mephisto/vpin/extensions/OverlayWindowFX.java @@ -28,8 +28,6 @@ public class OverlayWindowFX extends Application implements NativeKeyListener { private final static org.slf4j.Logger LOG = LoggerFactory.getLogger(OverlayGraphics.class); - private KeyChecker keyChecker; - private boolean visible = false; private Stage stage; @@ -45,9 +43,6 @@ public void start(Stage primaryStage) throws Exception { if (StringUtils.isEmpty(hotkey)) { LOG.error("No overlay hotkey defined! Define a key binding on the overlay configuration tab and restart the service."); } - else { - keyChecker = new KeyChecker(hotkey); - } Platform.setImplicitExit(false); @@ -87,7 +82,9 @@ public void nativeKeyTyped(NativeKeyEvent nativeKeyEvent) { @Override public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) { - if (keyChecker != null && keyChecker.matches(nativeKeyEvent)) { + String hotkey = Config.getOverlayGeneratorConfig().getString("overlay.hotkey"); + KeyChecker keyChecker = new KeyChecker(hotkey); + if (keyChecker.matches(nativeKeyEvent)) { this.visible = !visible; Platform.runLater(() -> { LOG.info("Toggle show"); diff --git a/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java b/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java index a11ad4f..6a33b64 100644 --- a/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java +++ b/src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java @@ -36,6 +36,8 @@ public ServiceRunner() { LOG.error("Initial overlay generation failed: " + e.getMessage(), e); } + new ServiceRunnerTray(service); + LOG.info("Overlay window listener started."); OverlayWindowFX.launch(OverlayWindowFX.class); } catch (VPinServiceException e) { diff --git a/src/main/java/de/mephisto/vpin/extensions/ServiceRunnerTray.java b/src/main/java/de/mephisto/vpin/extensions/ServiceRunnerTray.java new file mode 100644 index 0000000..89b262f --- /dev/null +++ b/src/main/java/de/mephisto/vpin/extensions/ServiceRunnerTray.java @@ -0,0 +1,63 @@ +package de.mephisto.vpin.extensions; + +import de.mephisto.vpin.VPinService; +import de.mephisto.vpin.extensions.resources.ResourceLoader; +import de.mephisto.vpin.extensions.util.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.awt.*; +import java.io.File; +import java.io.IOException; + +public class ServiceRunnerTray { + private final static Logger LOG = LoggerFactory.getLogger(ServiceRunnerTray.class); + + public ServiceRunnerTray(VPinService service) { + //Check the SystemTray is supported + if (!SystemTray.isSupported()) { + LOG.info("SystemTray is not supported"); + return; + } + final PopupMenu popup = new PopupMenu(); + final TrayIcon trayIcon = new TrayIcon(ResourceLoader.getResource("logo-small.png")); + final SystemTray tray = SystemTray.getSystemTray(); + MenuItem restartItem = new MenuItem("Restart"); + restartItem.addActionListener(e -> { + try { + Config.reloadAll(); + restartItem.setEnabled(false); + service.restart(); + } catch (Exception ex) { + LOG.error("Failed to restart VPin Extension Service: " + ex.getMessage()); + } + finally { + restartItem.setEnabled(true); + } + }); + MenuItem logsItem = new MenuItem("Show Logs"); + logsItem.addActionListener(e -> { + try { + File file = new File("./vpin-extensions.log"); + if(file.exists()) { + Desktop.getDesktop().open(file); + } + } catch (IOException ex) { + LOG.error("Failed to open log file: " + ex.getMessage()); + } + }); + MenuItem exitItem = new MenuItem("Terminate"); + exitItem.addActionListener(e -> System.exit(0)); + popup.add(restartItem); + popup.add(logsItem); + popup.addSeparator(); + popup.add(exitItem); + + trayIcon.setPopupMenu(popup); + try { + tray.add(trayIcon); + } catch (AWTException e) { + LOG.error("TrayIcon could not be added: " + e.getMessage(), e); + } + } +} diff --git a/src/main/java/de/mephisto/vpin/extensions/cardsettings/CardSettingsTab.java b/src/main/java/de/mephisto/vpin/extensions/cardsettings/CardSettingsTab.java index 18bc688..3f2bc89 100644 --- a/src/main/java/de/mephisto/vpin/extensions/cardsettings/CardSettingsTab.java +++ b/src/main/java/de/mephisto/vpin/extensions/cardsettings/CardSettingsTab.java @@ -86,7 +86,7 @@ public void actionPerformed(ActionEvent e) { } }); - ratioCombo = WidgetFactory.createCombobox(settingsPanel, Arrays.asList(B2SImageRatio.RATIO_16x9.toString(), B2SImageRatio.RATIO_4x3.toString()), "Force Image Ratio:", store, "card.ratio"); + ratioCombo = WidgetFactory.createCombobox(settingsPanel, Arrays.asList(B2SImageRatio.RATIO_16x9.toString(), B2SImageRatio.RATIO_4x3.toString()), "Image Ratio:", store, "card.ratio"); ratioCombo.setEnabled(store.getBoolean("card.useDirectB2S")); backgroundSelector = WidgetFactory.createCombobox(settingsPanel, new File(SystemInfo.RESOURCES + "backgrounds/"), "Default Background:", store, "card.background"); diff --git a/src/main/java/de/mephisto/vpin/extensions/util/Config.java b/src/main/java/de/mephisto/vpin/extensions/util/Config.java index bd9f661..f0c71e9 100644 --- a/src/main/java/de/mephisto/vpin/extensions/util/Config.java +++ b/src/main/java/de/mephisto/vpin/extensions/util/Config.java @@ -46,4 +46,10 @@ public static PropertiesStore getVersionConfig() { public static PropertiesStore getConfig(String name) { return PropertiesStore.create(name); } + + public static void reloadAll() { + commandConfig = null; + cardConfig = null; + generatorConfig = null; + } } diff --git a/src/main/resources/de/mephisto/vpin/extensions/resources/logo-small.png b/src/main/resources/de/mephisto/vpin/extensions/resources/logo-small.png index e69de29..f20144a 100644 Binary files a/src/main/resources/de/mephisto/vpin/extensions/resources/logo-small.png and b/src/main/resources/de/mephisto/vpin/extensions/resources/logo-small.png differ