Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Sep 28, 2022
1 parent b5b0f9c commit 416cd47
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 234 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 @@
#Wed Sep 28 17:53:16 CEST 2022
#Wed Sep 28 22:09:57 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 @@
#Wed Sep 28 17:54:24 CEST 2022
#Wed Sep 28 22:09:57 CEST 2022
overlay.alphacomposite.black=0
overlay.alphacomposite.white=0
overlay.background=background4k.jpg
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/de/mephisto/vpin/extensions/ConfigWindow.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
package de.mephisto.vpin.extensions;

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.extensions.cardsettings.CardSettingsTab;
import de.mephisto.vpin.extensions.commands.CommandsTab;
import de.mephisto.vpin.extensions.overlaysettings.OverlaySettingsTab;
import de.mephisto.vpin.extensions.resources.ResourceLoader;
import de.mephisto.vpin.extensions.service.ServiceTab;
import de.mephisto.vpin.extensions.util.Updater;
import de.mephisto.vpin.extensions.util.ProgressDialog;
import de.mephisto.vpin.extensions.util.ProgressResultModel;
import de.mephisto.vpin.extensions.overlaysettings.OverlaySettingsTab;
import de.mephisto.vpin.extensions.table.TableScanProgressModel;
import de.mephisto.vpin.extensions.table.TablesTab;
import org.apache.commons.lang3.StringUtils;
import de.mephisto.vpin.extensions.util.Updater;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.List;

public class ConfigWindow extends JFrame {
private final static Logger LOG = LoggerFactory.getLogger(ConfigWindow.class);
Expand Down Expand Up @@ -54,7 +48,6 @@ public ConfigWindow(VPinService service) {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");



this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

JTabbedPane tabbedPane = new JTabbedPane();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/mephisto/vpin/extensions/FXTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import javafx.stage.Screen;
import javafx.stage.Stage;

public class FXTest extends Application {
public class FXTest extends Application {
private Stage stage;

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void main(String[] args) {
public void start(Stage primaryStage) throws Exception {
this.stage = primaryStage;
String hotkey = Config.getOverlayGeneratorConfig().getString("overlay.hotkey");
if(StringUtils.isEmpty(hotkey)) {
if (StringUtils.isEmpty(hotkey)) {
LOG.error("No overlay hotkey defined! Define a key binding on the overlay configuration tab and restart the service.");
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/mephisto/vpin/extensions/Splash.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void checkForUpdates() {
if (!StringUtils.isEmpty(nextVersion)) {
Splash.this.setVisible(false);
int option = JOptionPane.showConfirmDialog(this, new MessageWithLink("New version " + nextVersion + " found. Download and install update?<br><br>" +
"Release Notes:<br><a href=\"https://github.com/syd711/vpin-extensions/releases/tag/" + nextVersion + "\">https://github.com/syd711/vpin-extensions/releases/tag/" + nextVersion + "</a>"), "Update Available",
"Release Notes:<br><a href=\"https://github.com/syd711/vpin-extensions/releases/tag/" + nextVersion + "\">https://github.com/syd711/vpin-extensions/releases/tag/" + nextVersion + "</a>"), "Update Available",
JOptionPane.YES_NO_OPTION);

if (option == JOptionPane.YES_OPTION) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/mephisto/vpin/extensions/SuperMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

public class SuperMain {
public static void main(String[] args) throws Exception {
if(args != null && args.length > 0 && args[0].contains("config")) {
if (args != null && args.length > 0 && args[0].contains("config")) {
new Splash();
}
else if(args != null && args.length > 0 && args[0].contains("test")) {
else if (args != null && args.length > 0 && args[0].contains("test")) {
FXTest.main(args);
}
else if(args != null && args.length > 0 && args[0].contains("overlay")) {
else if (args != null && args.length > 0 && args[0].contains("overlay")) {
OverlayGenerator.main(args);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ 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.setEnabled(store.getBoolean("card.useDirectB2S"));

backgroundSelector = WidgetFactory.createCombobox(settingsPanel, new File(SystemInfo.RESOURCES + "backgrounds/"),"Default Background:", store, "card.background");
backgroundSelector = WidgetFactory.createCombobox(settingsPanel, new File(SystemInfo.RESOURCES + "backgrounds/"), "Default Background:", store, "card.background");
backgroundSelector.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ImageIcon previewIcon = getPreviewIcon();
if(previewIcon != null) {
if (previewIcon != null) {
previewLabel.setIcon(previewIcon);
}
}
});
previewLabel = WidgetFactory.createLabel(settingsPanel, "", "");
ImageIcon previewIcon = getPreviewIcon();
if(previewIcon != null) {
if (previewIcon != null) {
previewLabel.setIcon(previewIcon);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ public void generateSampleCard() {
generateButton.setEnabled(false);

File directB2SImage = getSampleGame().getDirectB2SImage();
if(directB2SImage.exists()) {
if (directB2SImage.exists()) {
directB2SImage.delete();
}
CardGenerator.generateCard(service, getSampleGame(), getScreen(), CardGenerator.SAMPLE_FILE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import de.mephisto.vpin.GameInfo;
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.extensions.generator.CardGenerator;
import de.mephisto.vpin.extensions.util.ProgressModel;
import de.mephisto.vpin.extensions.util.ProgressResultModel;
import de.mephisto.vpin.popper.PopperScreen;
import de.mephisto.vpin.extensions.generator.CardGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public CommandTable(CommandsTab commandsTab, VPinService service, CommandTableMo
setRowHeight(20);
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent mouseEvent) {
JTable table =(JTable) mouseEvent.getSource();
JTable table = (JTable) mouseEvent.getSource();
Point point = mouseEvent.getPoint();
if (mouseEvent.getClickCount() == 2 && table.getSelectedRow() != -1) {
commandsTab.editRule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Object getValueAt(int rowIndex, int columnIndex) {
}
if (columnIndex == 2) {
Unit unit = service.getUnit(command.getUnit());
if(unit == null) {
if (unit == null) {
return "UNKNOWN UNIT";
}
return unit.toString();
Expand All @@ -58,10 +58,10 @@ public Object getValueAt(int rowIndex, int columnIndex) {
}
if (columnIndex == 7) {
String keyBinding = command.getKeyBinding();
if(!StringUtils.isEmpty(keyBinding)) {
if (!StringUtils.isEmpty(keyBinding)) {
if (keyBinding.contains("+")) {
String[] split = keyBinding.split("\\+");
if(split.length > 1) {
if (split.length > 1) {
String key = split[1];
String modifier = Keys.getModifierName(Integer.parseInt(split[0]));
return modifier + " + " + key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import de.mephisto.vpin.VPinService;
import de.mephisto.vpin.dof.DOFCommand;
import de.mephisto.vpin.dof.Trigger;
import de.mephisto.vpin.extensions.util.WidgetFactory;
import de.mephisto.vpin.extensions.ConfigWindow;
import de.mephisto.vpin.extensions.util.WidgetFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void executeDOFCommand(int value) {
try {
Unit unit = (Unit) boardSelector.getSelectedItem();
String port = (String) outputCombo.getSelectedItem();
if(unit != null) {
if (unit != null) {
List<String> commands = Arrays.asList(String.valueOf(unit.getId()), String.valueOf(port), String.valueOf(value));
DOFCommandResult dofCommandResult = DOFCommandExecutor.executeDOFTester(commands);
JOptionPane.showMessageDialog(this, "Command Result: " + dofCommandResult.getOut(), "Result", JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import de.mephisto.vpin.dof.DOFCommand;
import de.mephisto.vpin.dof.Trigger;
import de.mephisto.vpin.dof.Unit;
import de.mephisto.vpin.extensions.util.WidgetFactory;
import de.mephisto.vpin.extensions.ConfigWindow;
import de.mephisto.vpin.extensions.util.Keys;
import de.mephisto.vpin.extensions.util.WidgetFactory;
import de.mephisto.vpin.util.PropertiesStore;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -132,7 +132,7 @@ private void updateViewState() {
timeSpinner.setValue(0);
}

if(!keyTrigger) {
if (!keyTrigger) {
this.keyCombo.setSelectedIndex(0);
this.modifierCombo.setSelectedIndex(0);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ private JPanel addKeySelection(JPanel rootPanel, String pKey, PropertiesStore st
if (hotkey != null) {
if (hotkey.contains("+")) {
String[] split = hotkey.split("\\+");
if(split.length > 1) {
if (split.length > 1) {
String key = split[1];
modifierCombo.setSelectedItem(Keys.getModifierName(Integer.parseInt(split[0])));
keyCombo.setSelectedItem(key.toUpperCase(Locale.ROOT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import de.mephisto.vpin.extensions.util.Config;
import de.mephisto.vpin.highscores.Highscore;
import de.mephisto.vpin.highscores.Score;
import de.mephisto.vpin.util.ImageCropper;
import de.mephisto.vpin.util.ImageUtil;
import de.mephisto.vpin.util.SystemInfo;
import org.slf4j.Logger;
Expand All @@ -19,59 +18,13 @@
import java.util.ArrayList;
import java.util.List;

public class CardGraphics extends VPinGraphics {
public class CardGraphics {
private final static Logger LOG = LoggerFactory.getLogger(CardGraphics.class);

private static int ROW_SEPARATOR = Config.getCardGeneratorConfig().getInt("card.highscores.row.separator");
private static int ROW_PADDING_LEFT = Config.getCardGeneratorConfig().getInt("card.highscores.row.padding.left");

private static String TITLE_TEXT = Config.getCardGeneratorConfig().getString("card.title.text");

private static String SCORE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.score.font.name");
private static int SCORE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.score.font.style");
private static int SCORE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.score.font.size");

private static String TITLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.title.font.name");
private static int TITLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.title.font.style");
private static int TITLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.title.font.size");

private static String TABLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.table.font.name");
private static int TABLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.table.font.style");
private static int TABLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.table.font.size");

private static int TITLE_Y_OFFSET = Config.getCardGeneratorConfig().getInt("card.title.y.offset");
private static int BLUR_PIXELS = Config.getCardGeneratorConfig().getInt("card.blur");

private static boolean USE_DIRECTB2S = Config.getCardGeneratorConfig().getBoolean("card.useDirectB2S");
private static B2SImageRatio DIRECTB2S_RATIO = B2SImageRatio.valueOf(Config.getCardGeneratorConfig().getString("card.ratio", B2SImageRatio.RATIO_16x9.name()));

private static void initValues() {
ROW_SEPARATOR = Config.getCardGeneratorConfig().getInt("card.highscores.row.separator");
ROW_PADDING_LEFT = Config.getCardGeneratorConfig().getInt("card.highscores.row.padding.left");

TITLE_TEXT = Config.getCardGeneratorConfig().getString("card.title.text");

SCORE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.score.font.name");
SCORE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.score.font.style");
SCORE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.score.font.size");

TITLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.title.font.name");
TITLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.title.font.style");
TITLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.title.font.size");

TABLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.table.font.name");
TABLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.table.font.style");
TABLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.table.font.size");

TITLE_Y_OFFSET = Config.getCardGeneratorConfig().getInt("card.title.y.offset");
BLUR_PIXELS = Config.getCardGeneratorConfig().getInt("card.blur");

USE_DIRECTB2S = Config.getCardGeneratorConfig().getBoolean("card.useDirectB2S");
DIRECTB2S_RATIO = B2SImageRatio.valueOf(Config.getCardGeneratorConfig().getString("card.ratio", B2SImageRatio.RATIO_16x9.name()));
}

public BufferedImage drawHighscores(VPinService service, GameInfo game) throws Exception {
initValues();
boolean USE_DIRECTB2S = Config.getCardGeneratorConfig().getBoolean("card.useDirectB2S");
B2SImageRatio DIRECTB2S_RATIO = B2SImageRatio.valueOf(Config.getCardGeneratorConfig().getString("card.ratio", B2SImageRatio.RATIO_16x9.name()));
int BLUR_PIXELS = Config.getCardGeneratorConfig().getInt("card.blur");

File sourceFile = new File(SystemInfo.RESOURCES + "backgrounds", Config.getCardGeneratorConfig().get("card.background"));
if (USE_DIRECTB2S && game.getDirectB2SFile().exists()) {
Expand All @@ -81,23 +34,22 @@ public BufferedImage drawHighscores(VPinService service, GameInfo game) throws E
}
}

BufferedImage backgroundImage = super.loadBackground(sourceFile);
BufferedImage backgroundImage = ImageUtil.loadBackground(sourceFile);
if (USE_DIRECTB2S) {
ImageCropper cropper = new ImageCropper(backgroundImage);
backgroundImage = cropper.crop(DIRECTB2S_RATIO.getXRatio(), DIRECTB2S_RATIO.getYRatio());
backgroundImage = ImageUtil.crop(backgroundImage, DIRECTB2S_RATIO.getXRatio(), DIRECTB2S_RATIO.getYRatio());
}

if(BLUR_PIXELS > 0) {
if (BLUR_PIXELS > 0) {
backgroundImage = ImageUtil.blurImage(backgroundImage, BLUR_PIXELS);
}

float alphaWhite = Config.getCardGeneratorConfig().getFloat("card.alphacomposite.white");
float alphaBlack = Config.getCardGeneratorConfig().getFloat("card.alphacomposite.black");
applyAlphaComposites(backgroundImage, alphaWhite, alphaBlack);
ImageUtil.applyAlphaComposites(backgroundImage, alphaWhite, alphaBlack);
renderTableChallenge(backgroundImage, game);

int borderWidth = Config.getCardGeneratorConfig().getInt("card.border.width");
drawBorder(backgroundImage, borderWidth);
ImageUtil.drawBorder(backgroundImage, borderWidth);

return backgroundImage;
}
Expand All @@ -106,10 +58,29 @@ public BufferedImage drawHighscores(VPinService service, GameInfo game) throws E
* The upper section, usually with the three topscores.
*/
private void renderTableChallenge(BufferedImage image, GameInfo game) throws Exception {
int ROW_SEPARATOR = Config.getCardGeneratorConfig().getInt("card.highscores.row.separator");
int ROW_PADDING_LEFT = Config.getCardGeneratorConfig().getInt("card.highscores.row.padding.left");

String TITLE_TEXT = Config.getCardGeneratorConfig().getString("card.title.text");

String SCORE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.score.font.name");
int SCORE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.score.font.style");
int SCORE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.score.font.size");

String TITLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.title.font.name");
int TITLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.title.font.style");
int TITLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.title.font.size");

String TABLE_FONT_NAME = Config.getCardGeneratorConfig().getString("card.table.font.name");
int TABLE_FONT_STYLE = Config.getCardGeneratorConfig().getInt("card.table.font.style");
int TABLE_FONT_SIZE = Config.getCardGeneratorConfig().getInt("card.table.font.size");

int TITLE_Y_OFFSET = Config.getCardGeneratorConfig().getInt("card.title.y.offset");

Highscore highscore = game.resolveHighscore();
if (highscore != null) {
Graphics g = image.getGraphics();
setDefaultColor(g, Config.getCardGeneratorConfig().getString("card.font.color"));
ImageUtil.setDefaultColor(g, Config.getCardGeneratorConfig().getString("card.font.color"));
int imageWidth = image.getWidth();

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

0 comments on commit 416cd47

Please sign in to comment.