From 2bbf34bf70870d08223cec78a68332752d53b6cb Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Thu, 1 Aug 2024 12:42:21 -0500 Subject: [PATCH] Create separate version ID for nightly auto-builds, shorten awkward "Version Release" string, add Apache Commons dependencies --- .idea/libraries/apache_commons_io.xml | 10 ++++++++++ firestar/build.gradle | 1 + firestar/src/main/java/Ernie.java | 11 ++++++++--- firestar/src/main/java/Main.java | 28 ++++++++++++++++++++++++--- firestar/src/main/java/MissPiggy.java | 8 ++++---- firestar/src/main/java/Rowlf.java | 3 ++- 6 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 .idea/libraries/apache_commons_io.xml diff --git a/.idea/libraries/apache_commons_io.xml b/.idea/libraries/apache_commons_io.xml new file mode 100644 index 0000000..931e2a6 --- /dev/null +++ b/.idea/libraries/apache_commons_io.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/firestar/build.gradle b/firestar/build.gradle index 084d16a..304170b 100644 --- a/firestar/build.gradle +++ b/firestar/build.gradle @@ -19,6 +19,7 @@ dependencies { implementation group: 'org.json', name: 'json', version: '20240303' implementation group: 'io.github.java-diff-utils', name: 'java-diff-utils', version: '4.12' implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0' + implementation group: 'org.netbeans.external', name: 'org-apache-commons-io', version: 'RELEASE113' implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:203.7148.30' antTask 'com.jetbrains.intellij.java:java-compiler-ant-tasks:203.7148.30' diff --git a/firestar/src/main/java/Ernie.java b/firestar/src/main/java/Ernie.java index 764e189..d432e78 100644 --- a/firestar/src/main/java/Ernie.java +++ b/firestar/src/main/java/Ernie.java @@ -62,7 +62,7 @@ public class Ernie implements ActionListener { private JFrame parent; - public Ernie(JFrame parent) { + public Ernie(JFrame parent, boolean isManual) { this.parent = parent; frame.setIconImage(Main.windowIcon); byte[] urlraw = getFile(gitapi+"/releases?draft=false&pre-release=false"); @@ -72,7 +72,9 @@ public class Ernie implements ActionListener { try { JSONArray releases = new JSONArray(new String(urlraw, Charset.forName("utf-8"))); System.out.println("Updater: latest release is " + ((JSONObject)releases.get(0)).get("tag_name")); - if (releases.length() >= 1 && !((JSONObject)releases.get(0)).get("tag_name").equals(Main.vtag)) { + if (releases.length() >= 1 + && (!Main.isNightly && (!((JSONObject)releases.get(0)).get("tag_name").equals(Main.vtag)) + || (Main.isNightly && !((JSONObject)releases.get(0)).get("tag_name").equals(Main.vtagPrevious)))) { System.out.println("Updater: Your version is out of date."); frame.add(frameContainer); notnowbtn.addActionListener(this); @@ -97,7 +99,10 @@ public class Ernie implements ActionListener { } }); frame.setVisible(true); - } else { System.out.println("Updater: No updates."); } + } else { + System.out.println("Updater: No updates."); + if (isManual) {JOptionPane.showMessageDialog(frame, "There are no updates at this time.", "Check for Updates", JOptionPane.INFORMATION_MESSAGE);} + } } catch (IOException | JSONException ex) { Logger.getLogger(Ernie.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/firestar/src/main/java/Main.java b/firestar/src/main/java/Main.java index cdc6a39..1a5454c 100644 --- a/firestar/src/main/java/Main.java +++ b/firestar/src/main/java/Main.java @@ -18,11 +18,13 @@ import net.lingala.zip4j.ZipFile; import net.lingala.zip4j.exception.ZipException; +import org.apache.commons.io.IOUtils; import org.json.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; +import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.util.*; import java.util.List; @@ -31,11 +33,16 @@ import javax.swing.*; public class Main { // Build Information - public static final String vstr = "Release 1.3"; + public static String vstr = "Release 1.3"; public static final String vcode = "Tetsuo"; public static final String vtag = "tetsuo-1.3"; // set to dekka-1.1 for testing public static final int vint = 1; + // Jenkins Build Information + public static boolean isNightly = false; + public static final String vtagPrevious = "dekka-1.2"; + public static String dateOfCompile = null; + // User Settings public static String outpath = System.getProperty("user.home") + "/.firestar/out/"; //game assets location public final static String inpath = System.getProperty("user.home") + "/.firestar/"; //firestar folder -- do not change this @@ -47,6 +54,7 @@ public class Main { public enum ArcTarget { // install target for 2048, type used by downloader BASE("http://zeus.dl.playstation.net/cdn/UP9000/PCSA00015_00/NYEoaBGfiWymSEVZKxoyrKyBFsZNoFqxdyAIpZayZYuLLbCAArYrYXjPNhKCfXcONmhIZzZEeArycSrjiJOuNMWuWsDONUxMIQtMk.pkg"), + FIRST("http://gs.ww.np.dl.playstation.net/ppkg/np/PCSA00015/PCSA00015_T5/a4b7d9e35ed56e86/UP9000-PCSA00015_00-WIPEOUT2048BASE0-A0104-V0100-059564fcab8ce66d19b5a563e92677e581313205-PE.pkg"), // TODO ALLOW DATA1 DOWNLOAD LATEST("http://gs.ww.np.dl.playstation.net/ppkg/np/PCSA00015/PCSA00015_T5/a4b7d9e35ed56e86/UP9000-PCSA00015_00-WIPEOUT2048BASE0-A0104-V0100-059564fcab8ce66d19b5a563e92677e581313205-PE.pkg"), ADDON_HD("http://zeus.dl.playstation.net/cdn/UP9000/PCSA00015_00/JYMqGNXUKqHEyNLjbOgrWcJdnQJUMzgadRFWekbWFBXAwMeGikOyiHkXKogKIfqGhtNwKgmNWwwcrJORmRUTDzylBPwjGVnVjyDfh.pkg"), ADDON_HD_FURY("http://zeus.dl.playstation.net/cdn/UP9000/PCSA00015_00/IAoJQaDpySenBmQCKiqecEPMzSdPfPcdXupxZXLTYYTuRgtsdTaHxbeejwGKRQpjJOKBdMMFzSoeEhsHYxNUasQrEzkZPeBxUEqnp.pkg"); @@ -62,6 +70,7 @@ public class Main { public enum ArcKey { // decryption keys for 2048, type used by downloader BASE("KO5ifR1dQ+eHBlgi6TI0Bdkf7hng6h8aYmRgYuHkCLQNn/9ufV+01fmzjNSmwuVHnO4dEBuN8cENACqVFcgA"), + FIRST("KO5ifR1dQ+eHBlgi6TI0Bdkf7hng6h8aYmRgYuHkCLQNn/9ufV+01fmzjNSmwuVHnO4dEBuN8cENACqVFcgA"), LATEST("KO5ifR1dQ+eHBlgi6TI0Bdkf7hng6h8aYmRgYuHkCLQNn/9ufV+01fmzjNSmwuVHnO4dEBuN8cENACqVFcgA"), ADDON_HD("KO5ifR1dQ+eHBlgi6TI0Bdnv4uNsGG5kYGIR4Ojs7ejuis9/anXfuudVNvzgdu+9z1z+asJojA9uAACgRhTl"), ADDON_HD_FURY("KO5ifR1dQ+eHBlgi6TI0Bdnv4uNsFG5kYGIR4Ojs7ejuis9/3fydBRm3eCJX7biz/vVTm/2jMT64AQCCYhVy"); @@ -97,8 +106,22 @@ public class Main { public static BufferedImage windowIcon; public static void main(String[] args) { + // get Nightly information from Jenkins automatic builds + if (Main.class.getResource("/jenkinsVersionString") != null) { + System.out.println("=== This is a NIGHTLY BUILD! ===\n"); + try { + vstr = "Nightly " + IOUtils.toString(Main.class.getResourceAsStream("/jenkinsVersionString"), StandardCharsets.UTF_8); + dateOfCompile = IOUtils.toString(Main.class.getResourceAsStream("/jenkinsBuildDate"), StandardCharsets.UTF_8); + System.out.println("Compiled on " + dateOfCompile); + isNightly = true; + } catch (Exception e) { + System.out.println("ERROR: Something went wrong trying to get the autobuild information! defaulting to Release values\n\n"); + isNightly = false; + } + } + // license string - System.out.printf("FIRESTAR MOD MANAGER for WipEout 2048\nversion " + vstr + " (codename " + vcode + ") major " + vint + "\n" + + System.out.printf("FIRESTAR MOD MANAGER for WipEout 2048\n" + vstr + " (codename " + vcode + ") major " + vint + "\n" + "JVM host appears to be " + System.getProperty("os.name") + "\nRunning from " + System.getProperty("user.dir") + "\nCopyright (C) 2024 bonkmaykr\n\nThis program is free software: you can redistribute it and/or modify\n" + @@ -114,7 +137,6 @@ public class Main { "You should have received a copy of the GNU General Public License\n" + "along with this program. If not, see https://www.gnu.org/licenses/.\n\n\n\n"); - //begin // load global assets try { fExo2 = Font.createFont(Font.TRUETYPE_FONT, Main.class.getResourceAsStream("/exo2.ttf")); diff --git a/firestar/src/main/java/MissPiggy.java b/firestar/src/main/java/MissPiggy.java index 4d89f5d..9926ceb 100644 --- a/firestar/src/main/java/MissPiggy.java +++ b/firestar/src/main/java/MissPiggy.java @@ -172,7 +172,7 @@ public class MissPiggy implements ActionListener { frame.setLayout(new GridLayout()); frame.setLocationRelativeTo(null); - if (Main.checkUpdates) { StartErnie(); } + if (Main.checkUpdates) { StartErnie(false); } frame.setVisible(true); } @@ -300,11 +300,11 @@ public class MissPiggy implements ActionListener { createSelectionEventListener(); } - private void StartErnie() { + private void StartErnie(boolean isManual) { new Thread(new Runnable() { @Override public void run() { - new Ernie(frame); // changed away from runnable in order to pass params to constructor -bonk + new Ernie(frame, isManual); // changed away from runnable in order to pass params to constructor -bonk } }).start(); } @@ -358,7 +358,7 @@ public class MissPiggy implements ActionListener { JOptionPane.showMessageDialog(frame, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } else - if (actionEvent.getSource() == helpMenu.getItem(5)) {StartErnie();} else + if (actionEvent.getSource() == helpMenu.getItem(5)) {StartErnie(true);} else if (actionEvent.getSource() == helpMenu.getItem(6)) {new Rowlf(frame);} } diff --git a/firestar/src/main/java/Rowlf.java b/firestar/src/main/java/Rowlf.java index 448056d..f0dd4e8 100644 --- a/firestar/src/main/java/Rowlf.java +++ b/firestar/src/main/java/Rowlf.java @@ -58,7 +58,8 @@ public class Rowlf { informationText.getCaret().setVisible(false); informationText.setFocusable(false); - versionLabel.setText("Version " + Main.vstr + " (" + Main.vcode + ")"); + versionLabel.setText(Main.vstr + " (" + Main.vcode + ")"); + //if (Main.isNightly) {versionLabel.setText(versionLabel.getText() + " built " + Main.dateOfCompile);} environmentLabel.setText("Running on Java " + System.getProperty("java.version") + " for " + System.getProperty("os.name")); // display window