Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Sep 23, 2022
1 parent 94bda19 commit be2b55e
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 40 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ This section gives a brief overview about the functionality provided by this pro
*Configuration screen for highscore card generation.*

<img src="/documentation/sample-card-1.png" width="300"><img src="/documentation/sample-card-2.png" width="300">
<img src="/documentation/sample-card-3.png" width="300"><img src="/documentation/sample-card-4.png" width="300">
<img src="/documentation/sample-card-5.png" width="300">

*Samples generated with the highscore card generator.*

Expand Down
Binary file added documentation/card-sample-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/sample-card-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/sample-card-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/sample-card-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@
<include>*.png</include>
<include>background2k.jpg</include>
<include>background4k.jpg</include>
<include>highscore-card-background.jpg</include>
<include>highscore-card-background-2.jpg</include>
<include>highscore-card-background-*.jpg</include>
<include>*.ttf</include>
<include>DOFTest/*</include>
<include>overlay.properties</include>
Expand Down
22 changes: 11 additions & 11 deletions resources/card-generator.properties
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#Thu Sep 22 20:06:02 CEST 2022
card.alphacomposite.black=28
#Fri Sep 23 12:58:26 CEST 2022
card.alphacomposite.black=41
card.alphacomposite.white=10
card.background=highscore-card-background-2.jpg
card.background=highscore-card-background-4.png
card.border.width=4
card.font.color=\#ffffff
card.highscore.font.file=digital-7.ttf
card.highscore.font.name=Digital-7 Italic
card.highscores.row.padding.left=80
card.highscores.row.separator=7
card.sampleTable=11
card.highscores.row.padding.left=66
card.highscores.row.separator=36
card.sampleTable=8
card.score.font.font.style=0
card.score.font.name=Computerfont
card.score.font.size=100
card.score.font.name=Brush Script MT
card.score.font.size=80
card.score.font.style=0
card.table.font.font.style=0
card.table.font.name=Bernard MT Condensed
card.table.font.name=Brush Script MT
card.table.font.size=100
card.table.font.style=0
card.title.font.file=MediaCore-Bold.ttf
card.title.font.font.style=0
card.title.font.name=Computerfont
card.title.font.name=Brush Script MT
card.title.font.size=120
card.title.font.style=0
card.title.text=Highscores
card.title.y.offset=15
card.title.y.offset=22
popper.screen=Other2
Binary file added resources/highscore-card-background-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/highscore-card-background-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/highscore-card-background-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/highscore-card-background-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 +1,8 @@
#Thu Sep 22 20:07:21 CEST 2022
#Fri Sep 23 12:53:08 CEST 2022
overlay.alphacomposite.black=36
overlay.alphacomposite.white=0
overlay.background=background4k.jpg
overlay.challengedTable=11
overlay.challengedTable=7
overlay.font.color=\#ffffff
overlay.highscores.row.padding.left=87
overlay.highscores.row.separator=24
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.
39 changes: 22 additions & 17 deletions src/main/java/de/mephisto/vpin/extensions/ServiceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.VPinServiceException;
import de.mephisto.vpin.extensions.generator.HighscoreCardGenerator;
import de.mephisto.vpin.extensions.generator.OverlayGenerator;
import de.mephisto.vpin.extensions.util.Config;
Expand All @@ -13,29 +14,33 @@

public class ServiceRunner implements TableStatusChangeListener {
private final static Logger LOG = LoggerFactory.getLogger(ServiceRunner.class);
private final VPinService service;
private VPinService service;

public ServiceRunner() {
service = VPinService.create(true);
LOG.info("ServiceRunner started.");
try {
service = VPinService.create(true);
LOG.info("ServiceRunner started.");

LOG.info("Added VPin service listener for highscore changes.");
service.addTableStatusChangeListener(this);
LOG.info("Added VPin service listener for highscore changes.");
service.addTableStatusChangeListener(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.");
}
String targetScreen = Config.getCardGeneratorConfig().get("popper.screen");
if (StringUtils.isEmpty(targetScreen)) {
LOG.info("Skipped starting highscore card generator, no PinUP popper target screen configured.");
}

try {
LOG.info("Executing highscore overlay generation.");
OverlayGenerator.generateOverlay(service);
} catch (Exception e) {
LOG.error("Initial overlay generation failed: " + e.getMessage(), e);
}
try {
LOG.info("Executing highscore overlay generation.");
OverlayGenerator.generateOverlay(service);
} catch (Exception e) {
LOG.error("Initial overlay generation failed: " + e.getMessage(), e);
}

LOG.info("Overlay window listener started.");
OverlayWindowFX.launch(OverlayWindowFX.class);
LOG.info("Overlay window listener started.");
OverlayWindowFX.launch(OverlayWindowFX.class);
} catch (VPinServiceException e) {
LOG.error("Failed to start service runner: " + e.getMessage(), e);
}
}

@Override
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/de/mephisto/vpin/extensions/Splash.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.VPinServiceException;
import de.mephisto.vpin.extensions.cardsettings.CardSettingsTabActionListener;
import de.mephisto.vpin.extensions.resources.ResourceLoader;
import de.mephisto.vpin.extensions.table.TableScanProgressModel;
Expand Down Expand Up @@ -66,11 +67,17 @@ public Splash() {
setVisible(true);

new Thread(() -> {
checkForUpdates();

vPinService = VPinService.create(false);
runInitialCheck();
startMain();
try {
checkForUpdates();

vPinService = VPinService.create(false);
runInitialCheck();
startMain();
} catch (VPinServiceException e) {
LOG.error("Failed to start UI: " + e.getMessage(), e);
JOptionPane.showMessageDialog(this.getContentPane(), "Failed to start VPin Extension configuration window: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
}).start();
} catch (Exception e) {
LOG.error("Failed to launch: " + e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public CardSettingsTab(ConfigWindow configWindow, VPinService service) {

/******************************** Generator Fields ****************************************************************/
WidgetFactory.createFileChooser(settingsPanel, "Background Image:", "Select File", store, "card.background", "highscore-card-background.jpg");
WidgetFactory.createCombobox(settingsPanel, new File(SystemInfo.RESOURCES), "highscore-card-background-","Background Image:", store, "card.background");
WidgetFactory.createTextField(settingsPanel, "Card Title:", store, "card.title.text", "Highscore");
WidgetFactory.createFontSelector(settingsPanel, "Title Font:", store, "card.title.font", 120);
WidgetFactory.createFontSelector(settingsPanel, "Table Name Font:", store, "card.table.font", 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static int renderTableChallenge(BufferedImage image, GameInfo challenged
String scoreString = score.getPosition() + ". " + score.getUserInitials() + " " + score.getScore();
scores.add(scoreString);

int singleScoreWidth = g.getFontMetrics().stringWidth(title);
int singleScoreWidth = g.getFontMetrics().stringWidth(scoreString);
if (scoreWidth < singleScoreWidth) {
scoreWidth = singleScoreWidth;
}
Expand All @@ -122,14 +122,20 @@ private static int renderTableChallenge(BufferedImage image, GameInfo challenged
}
else {
for(int i=1; i<= 3; i++) {
scores.add( i + ". ??? 000.000.000");
String scoreString = i + ". ??? 000.000.000";
int singleScoreWidth = g.getFontMetrics().stringWidth(scoreString);
if (scoreWidth < singleScoreWidth) {
scoreWidth = singleScoreWidth;
}
scores.add(scoreString);
}
}

int position = 0;
int wheelWidth = (3 * SCORE_FONT_SIZE) + (3 * ROW_SEPARATOR);
int totalScoreAndWheelWidth = scoreWidth + wheelWidth;

tableNameY = tableNameY + ROW_SEPARATOR;
for (String score : scores) {
position++;
int scoreY = tableNameY + (position * SCORE_FONT_SIZE) + (position * ROW_SEPARATOR);
Expand All @@ -144,7 +150,6 @@ private static int renderTableChallenge(BufferedImage image, GameInfo challenged
g.drawImage(wheelImage, imageWidth / 2 - totalScoreAndWheelWidth / 2, wheelY, wheelWidth, wheelWidth, null);
}

returnOffset += TITLE_FONT_SIZE / 2;
return returnOffset;
}

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/de/mephisto/vpin/extensions/util/WidgetFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
import java.awt.*;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -104,6 +106,34 @@ public static JComboBox createCombobox(JPanel parent, List<String> values, Strin
return combo;
}

public static JComboBox createCombobox(JPanel parent, File folder, String prefix, String title, PropertiesStore store, String property) {
String[] files = folder.list((dir, name) -> name.startsWith(prefix));
Vector<String> data = new Vector<>(Arrays.asList(files));
final JComboBox combo = new JComboBox(data);
combo.addActionListener(e -> {
String selectedItem = (String) combo.getSelectedItem();
if (selectedItem == null) {
selectedItem = "";
}
store.set(property, selectedItem);
});
String selection = store.getString(property);
if (!StringUtils.isEmpty(selection)) {
combo.setSelectedItem(selection);
}
else {
combo.setSelectedItem(files[0]);
store.set(property, files[0]);
}

parent.add(new JLabel(title));
parent.add(combo, "span 3");
parent.add(new JLabel(""), "width 30:200:200");
parent.add(new JLabel(""), "wrap");

return combo;
}

public static JLabel createLabel(JPanel parent, String title, Color color) {
parent.add(new JLabel(""));
JLabel label = new JLabel(title);
Expand Down

0 comments on commit be2b55e

Please sign in to comment.