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 22, 2022
1 parent e80cc93 commit 63b95ef
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 55 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ An additional warning is also shown by the UI for this:

![](./documentation/card-warning.png)

You may get the additional warning that the screen is not bound to any key.
Check the controller settings in PinUP Popper for this screen so that you can hide it if you want.

![](./documentation/key-binding-error.png)

If no screen is selected, the highscore card is generation is disabled.

For testing the generator output, a sample table can be selected and clicking the
Expand Down Expand Up @@ -145,6 +150,13 @@ __In the controller section, make sure that you have a shortcut defined for show
If everything is configured properly, you can press the configured control for the __Other 2__ screen
and the generated highscore card should pop up (if already been generated!).

*Note that all tables will have a highscore card. So you may want to delete the default media stored
for the screen you selected.
The emulator defaults are stored in __pinupsystem\POPMEDIA\<EACH EMULTAOR>\SYTEM__.
You can change or remove the screen's default media there (remember you need to do this for each emulator in system).*

See also https://www.nailbuster.com/wikipinup/doku.php?id=faq

## Configure DOF Rules

__Experimental (not tested yet, board resolving may be broken)__
Expand Down
Binary file added documentation/key-binding-error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@
<include>4k-generator.properties</include>
<include>*.exe</include>
<include>*.png</include>
<include>*.jpg</include>
<include>background2k.jpg</include>
<include>background4k.jpg</include>
<include>highscore-card-background.jpg</include>
<include>highscore-card-background-2.jpg</include>
<include>*.ttf</include>
<include>DOFTest/*</include>
<include>overlay.properties</include>
Expand Down
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 22 18:15:11 CEST 2022
#Thu Sep 22 20:06:02 CEST 2022
card.alphacomposite.black=28
card.alphacomposite.white=10
card.background=highscore-card-background-2.jpg
Expand All @@ -8,7 +8,7 @@ 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=7
card.sampleTable=11
card.score.font.font.style=0
card.score.font.name=Computerfont
card.score.font.size=100
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.
6 changes: 3 additions & 3 deletions resources/overlay-generator.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Thu Sep 22 18:12:11 CEST 2022
#Thu Sep 22 20:07:21 CEST 2022
overlay.alphacomposite.black=36
overlay.alphacomposite.white=0
overlay.background=background4k.jpg
overlay.challengedTable=6
overlay.challengedTable=11
overlay.font.color=\#ffffff
overlay.highscores.row.padding.left=87
overlay.highscores.row.separator=24
Expand All @@ -12,7 +12,7 @@ overlay.score.font.font.style=0
overlay.score.font.name=Digiface
overlay.score.font.size=100
overlay.score.font.style=0
overlay.skipWithMissingWheels=true
overlay.skipWithMissingWheels=false
overlay.table.font.font.style=0
overlay.table.font.name=SF Comic Script
overlay.table.font.size=120
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 @@ -2,13 +2,13 @@

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.popper.PopperScreen;
import de.mephisto.vpin.extensions.ConfigWindow;
import de.mephisto.vpin.extensions.generator.HighscoreCardGenerator;
import de.mephisto.vpin.extensions.util.Config;
import de.mephisto.vpin.extensions.util.ProgressDialog;
import de.mephisto.vpin.extensions.util.ProgressResultModel;
import de.mephisto.vpin.extensions.util.WidgetFactory;
import de.mephisto.vpin.popper.PopperScreen;
import de.mephisto.vpin.util.PropertiesStore;
import de.mephisto.vpin.util.SystemInfo;
import net.miginfocom.swing.MigLayout;
Expand Down Expand Up @@ -63,7 +63,7 @@ public CardSettingsTab(ConfigWindow configWindow, VPinService service) {
separator.setPreferredSize(new Dimension(1, 30));
settingsPanel.add(separator, "wrap");

WidgetFactory.createTableSelector(service, settingsPanel, "Sample Table:", store, "card.sampleTable");
WidgetFactory.createTableSelector(service, settingsPanel, "Sample Table:", store, "card.sampleTable", true);


/******************************** Generator Fields ****************************************************************/
Expand Down Expand Up @@ -130,8 +130,10 @@ public CardSettingsTab(ConfigWindow configWindow, VPinService service) {
previewPanel.setBorder(b);
add(previewPanel, BorderLayout.CENTER);
previewPanel.setLayout(new MigLayout("gap rel 8 insets 10", "left"));
iconLabel = new JLabel(getPreviewImage());
iconLabel = new JLabel("");
iconLabel.setBackground(Color.BLACK);

iconLabel.setIcon(getPreviewImage());
previewPanel.add(iconLabel);
}

Expand Down Expand Up @@ -160,7 +162,7 @@ private ImageIcon getPreviewImage() {
}
BufferedImage image = ImageIO.read(file);
int maxWidth = 540;
int percentage = (maxWidth * 100 / image.getWidth());
int percentage = (maxWidth * 100 / image.getWidth()) - 7;
Image newimg = image.getScaledInstance(image.getWidth() * percentage / 100, image.getHeight() * percentage / 100, Image.SCALE_SMOOTH); // scale it the smooth way
return new ImageIcon(newimg); // transform it back
}
Expand Down Expand Up @@ -197,7 +199,7 @@ public void generateSampleCard() {
try {
GameInfo sampleGame = getSampleGame();
if (sampleGame.resolveHighscore() == null) {
JOptionPane.showMessageDialog(this, "No highscore files found for " + sampleGame.toString() + ".", "Error", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(this, "No highscore files found for " + sampleGame.toString() + ".\nCheck the 'Table Overview' tab for tables with existing highscore files.", "Error", JOptionPane.INFORMATION_MESSAGE);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static void generateOverlay(VPinService service) throws Exception {

public BufferedImage generate() throws Exception {
try {
service.refreshGameInfos();

BufferedImage backgroundImage = super.loadBackground(new File(SystemInfo.RESOURCES, Config.getOverlayGeneratorConfig().getString("overlay.background")));
BufferedImage rotated = rotateRight(backgroundImage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.extensions.util.Config;
import de.mephisto.vpin.highscores.Highscore;
import de.mephisto.vpin.highscores.Score;
import de.mephisto.vpin.extensions.util.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -79,32 +79,33 @@ public static void drawGames(BufferedImage image, VPinService service, GameInfo
private static int renderTableChallenge(BufferedImage image, GameInfo challengedGame, int highscoreListYOffset) throws Exception {
Highscore highscore = challengedGame.resolveHighscore();
int returnOffset = highscoreListYOffset;
if (highscore != null) {
Graphics g = image.getGraphics();
setDefaultColor(g, Config.getOverlayGeneratorConfig().getString("overlay.font.color"));
int imageWidth = image.getWidth();
Graphics g = image.getGraphics();
setDefaultColor(g, Config.getOverlayGeneratorConfig().getString("overlay.font.color"));
int imageWidth = image.getWidth();

g.setFont(new Font(TITLE_FONT_NAME, TITLE_FONT_STYLE, TITLE_FONT_SIZE));
g.setFont(new Font(TITLE_FONT_NAME, TITLE_FONT_STYLE, TITLE_FONT_SIZE));

String title = TITLE_TEXT;
int titleWidth = g.getFontMetrics().stringWidth(title);
int titleY = ROW_SEPARATOR + TITLE_FONT_SIZE + TITLE_Y_OFFSET;
g.drawString(title, imageWidth / 2 - titleWidth / 2, titleY);
String title = TITLE_TEXT;
int titleWidth = g.getFontMetrics().stringWidth(title);
int titleY = ROW_SEPARATOR + TITLE_FONT_SIZE + TITLE_Y_OFFSET;
g.drawString(title, imageWidth / 2 - titleWidth / 2, titleY);

g.setFont(new Font(TABLE_FONT_NAME, TABLE_FONT_STYLE, TABLE_FONT_SIZE));
String challengedTable = challengedGame.getGameDisplayName();
int width = g.getFontMetrics().stringWidth(challengedTable);
g.setFont(new Font(TABLE_FONT_NAME, TABLE_FONT_STYLE, TABLE_FONT_SIZE));
String challengedTable = challengedGame.getGameDisplayName();
int width = g.getFontMetrics().stringWidth(challengedTable);


int tableNameY = titleY + (2* ROW_SEPARATOR) + TITLE_FONT_SIZE;
g.drawString(challengedTable, imageWidth / 2 - width / 2, tableNameY);
int tableNameY = titleY + (2 * ROW_SEPARATOR) + TITLE_FONT_SIZE;
g.drawString(challengedTable, imageWidth / 2 - width / 2, tableNameY);

g.setFont(new Font(SCORE_FONT_NAME, SCORE_FONT_STYLE, SCORE_FONT_SIZE));
g.setFont(new Font(SCORE_FONT_NAME, SCORE_FONT_STYLE, SCORE_FONT_SIZE));

int count = 0;
int scoreWidth = 0;
int count = 0;
int scoreWidth = 0;

List<String> scores = new ArrayList<>();

List<String> scores = new ArrayList<>();
if (highscore != null) {
for (Score score : highscore.getScores()) {
String scoreString = score.getPosition() + ". " + score.getUserInitials() + " " + score.getScore();
scores.add(scoreString);
Expand All @@ -118,27 +119,32 @@ private static int renderTableChallenge(BufferedImage image, GameInfo challenged
break;
}
}
}
else {
for(int i=1; i<= 3; i++) {
scores.add( i + ". ??? 000.000.000");
}
}

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

for (String score : scores) {
position++;
int scoreY = tableNameY + (position * SCORE_FONT_SIZE) + (position * ROW_SEPARATOR);
g.drawString(score, imageWidth / 2 - totalScoreAndWheelWidth / 2 + wheelWidth + ROW_SEPARATOR, scoreY);
}
for (String score : scores) {
position++;
int scoreY = tableNameY + (position * SCORE_FONT_SIZE) + (position * ROW_SEPARATOR);
g.drawString(score, imageWidth / 2 - totalScoreAndWheelWidth / 2 + wheelWidth + ROW_SEPARATOR, scoreY);
}

File wheelIconFile = challengedGame.getWheelIconFile();
int wheelY = tableNameY + ROW_SEPARATOR;
returnOffset = wheelY * 2 + SCORE_FONT_SIZE * 2;
if (wheelIconFile.exists()) {
BufferedImage wheelImage = ImageIO.read(wheelIconFile);
g.drawImage(wheelImage, imageWidth / 2 - totalScoreAndWheelWidth / 2, wheelY, wheelWidth, wheelWidth, null);
}
File wheelIconFile = challengedGame.getWheelIconFile();
int wheelY = tableNameY + ROW_SEPARATOR;
returnOffset = wheelY * 2 + SCORE_FONT_SIZE * 2;
if (wheelIconFile.exists()) {
BufferedImage wheelImage = ImageIO.read(wheelIconFile);
g.drawImage(wheelImage, imageWidth / 2 - totalScoreAndWheelWidth / 2, wheelY, wheelWidth, wheelWidth, null);
}

returnOffset+= TITLE_FONT_SIZE /2;
returnOffset += TITLE_FONT_SIZE / 2;
return returnOffset;
}

Expand Down Expand Up @@ -171,20 +177,18 @@ private static void renderHighscoreList(BufferedImage image, GameInfo gameOfTheM
}

File wheelIconFile = game.getWheelIconFile();
if(!wheelIconFile.exists() && Config.getOverlayGeneratorConfig().getBoolean("overlay.skipWithMissingWheels")) {
if (!wheelIconFile.exists() && Config.getOverlayGeneratorConfig().getBoolean("overlay.skipWithMissingWheels")) {
continue;
}

LOG.info("Rendering row for table " + game + ", last played " + game.getLastPlayed());
if (wheelIconFile.exists()) {
BufferedImage wheelImage = ImageIO.read(wheelIconFile);
g.drawImage(wheelImage, ROW_PADDING_LEFT, yStart + 12, ROW_HEIGHT, ROW_HEIGHT, null);
}

int x = ROW_HEIGHT + ROW_PADDING_LEFT + ROW_HEIGHT / 3;
g.setFont(new Font(TABLE_FONT_NAME, TABLE_FONT_SIZE, TABLE_FONT_SIZE));

String tableName = game.getGameDisplayName();
tableName = "<p color=\"#00FF00\"" + tableName + "</p>";
g.drawString(game.getGameDisplayName(), x, yStart + SCORE_FONT_SIZE);

g.setFont(new Font(SCORE_FONT_NAME, SCORE_FONT_STYLE, SCORE_FONT_SIZE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public OverlaySettingsTab(ConfigWindow configWindow, VPinService service) {
separator.setPreferredSize(new Dimension(1, 30));
settingsPanel.add(separator, "wrap");

WidgetFactory.createTableSelector(service, settingsPanel, "Challenged Table:", store, "overlay.challengedTable");
WidgetFactory.createTableSelector(service, settingsPanel, "Challenged Table:", store, "overlay.challengedTable", false);

/******************************** Generator Fields ****************************************************************/
WidgetFactory.createFileChooser(settingsPanel, "Background Image:", "Select File", store, "overlay.background", "background4k.jpg");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class TablesTabActionListener implements ActionListener {
private final static Logger LOG = LoggerFactory.getLogger(TablesTabActionListener.class);

private ConfigWindow configWindow;
private final ConfigWindow configWindow;
private final VPinService service;
private final TablesTab tablesTab;

Expand Down Expand Up @@ -70,6 +70,7 @@ else if (e.getActionCommand().equals("tableHighscore")) {
}

public void scanAll() {
service.refreshGameInfos();
tablesTab.scanAllButton.setEnabled(false);
ProgressDialog d = new ProgressDialog(configWindow, new TableScanProgressModel(service, "Resolving ROM Names"));
ProgressResultModel progressResultModel = d.showDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ public static JButton createButton(JPanel parent,
return button;
}

public static void createTableSelector(VPinService service, JPanel parent, String title, PropertiesStore store, String property) {
public static void createTableSelector(VPinService service, JPanel parent, String title, PropertiesStore store, String property, boolean filterForHighscores) {
List<GameInfo> gameInfos = service.getActiveGameInfos();
List<GameInfo> collect = gameInfos.stream().filter(g -> g.hasHighscore()).collect(Collectors.toList());
Vector<GameInfo> data = new Vector<>(collect);
if(filterForHighscores) {
gameInfos = gameInfos.stream().filter(g -> g.hasHighscore()).collect(Collectors.toList());
}
Vector<GameInfo> data = new Vector<>(gameInfos);
data.insertElementAt(null, 0);
final JComboBox tableSelection = new JComboBox(data);
tableSelection.addActionListener(e -> {
Expand Down

0 comments on commit 63b95ef

Please sign in to comment.