Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Sep 29, 2022
1 parent eef4a4d commit 33026a4
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 11 deletions.
4 changes: 2 additions & 2 deletions resources/card-generator.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Binary file modified resources/highscore-card-sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions resources/overlay-generator.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Binary file modified resources/overlay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/de/mephisto/vpin/extensions/ServiceRunnerTray.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/mephisto/vpin/extensions/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 33026a4

Please sign in to comment.