Add Java version checking to the content downloader UI

This commit is contained in:
Krazy
2017-04-27 23:48:31 +00:00
parent 25b5a4f375
commit 176cdf4d26

View File

@@ -52,25 +52,40 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
* Constructor. * Constructor.
*/ */
VSubmenuDownloaders() { VSubmenuDownloaders() {
final String constraintsLBL = "w 90%!, h 20px!, center, gap 0 0 3px 8px"; final String constraintsLBL = "w 90%!, h 20px!, center, gap 0 0 3px 8px";
final String constraintsBTN = "h 30px!, w 50%!, center"; final String constraintsBTN = "h 30px!, w 50%!, center";
pnlContent.setOpaque(false); pnlContent.setOpaque(false);
pnlContent.add(btnDownloadPics, constraintsBTN); if (javaRecentEnough()) {
pnlContent.add(_makeLabel("Download default card picture for each card."), constraintsLBL);
pnlContent.add(btnDownloadSetPics, constraintsBTN); pnlContent.add(btnDownloadPics, constraintsBTN);
pnlContent.add(_makeLabel("Download all pictures of each card (one for each set the card appeared in)"), constraintsLBL); pnlContent.add(_makeLabel("Download default card picture for each card."), constraintsLBL);
pnlContent.add(btnDownloadQuestImages, constraintsBTN); pnlContent.add(btnDownloadSetPics, constraintsBTN);
pnlContent.add(_makeLabel("Download tokens and icons used in Quest mode."), constraintsLBL); pnlContent.add(_makeLabel("Download all pictures of each card (one for each set the card appeared in)"), constraintsLBL);
pnlContent.add(btnDownloadAchievementImages, constraintsBTN); pnlContent.add(btnDownloadQuestImages, constraintsBTN);
pnlContent.add(_makeLabel("Download achievement images to really make your trophies stand out."), constraintsLBL); pnlContent.add(_makeLabel("Download tokens and icons used in Quest mode."), constraintsLBL);
pnlContent.add(btnDownloadPrices, constraintsBTN); pnlContent.add(btnDownloadAchievementImages, constraintsBTN);
pnlContent.add(_makeLabel("Download up-to-date price list for in-game card shops."), constraintsLBL); pnlContent.add(_makeLabel("Download achievement images to really make your trophies stand out."), constraintsLBL);
pnlContent.add(btnDownloadPrices, constraintsBTN);
pnlContent.add(_makeLabel("Download up-to-date price list for in-game card shops."), constraintsLBL);
} else {
String text = "Your version of Java is too old to use the content downloaders.";
FLabel label = new FLabel.Builder().fontAlign(SwingConstants.CENTER).text(text).fontStyle(Font.BOLD).fontSize(18).build();
pnlContent.add(label, "w 90%!, h 25px!, center, gap 0 0 30px 3px");
text = "Please update to the latest version of Java 8 to use this feature.";
label = new FLabel.Builder().fontAlign(SwingConstants.CENTER).text(text).fontStyle(Font.BOLD).fontSize(18).build();
pnlContent.add(label, "w 90%!, h 25px!, center, gap 0 0 0 36px");
}
pnlContent.add(btnImportPictures, constraintsBTN); pnlContent.add(btnImportPictures, constraintsBTN);
pnlContent.add(_makeLabel("Import data from a local directory."), constraintsLBL); pnlContent.add(_makeLabel("Import data from a local directory."), constraintsLBL);
@@ -83,6 +98,18 @@ public enum VSubmenuDownloaders implements IVSubmenu<CSubmenuDownloaders> {
pnlContent.add(btnLicensing, constraintsBTN); pnlContent.add(btnLicensing, constraintsBTN);
pnlContent.add(_makeLabel("Forge legal."), constraintsLBL); pnlContent.add(_makeLabel("Forge legal."), constraintsLBL);
}
private boolean javaRecentEnough() {
String fullJavaVersion = System.getProperty("java.version");
int majorVersion = Integer.parseInt(fullJavaVersion.split("_")[0].split("\\.")[1]);
int minorVersion = Integer.parseInt(fullJavaVersion.split("_")[1]);
return majorVersion > 8 || (majorVersion == 8 && minorVersion >= 101);
} }
/* (non-Javadoc) /* (non-Javadoc)