From 317eeedb294215b0a7d481c06167bc282830ac0f Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Sat, 13 Jul 2024 17:25:27 -0500 Subject: [PATCH] prepare downloader for diff system --- firestar/src/main/java/Bert.form | 67 ++-- firestar/src/main/java/Bert.java | 285 ++++++++++-------- firestar/src/main/java/WilkinsCoffee.form | 111 +++++-- firestar/src/main/java/WilkinsCoffee.java | 33 ++ firestar/src/main/resources/lightNegative.png | Bin 0 -> 823 bytes firestar/src/main/resources/lightPositive.png | Bin 0 -> 851 bytes 6 files changed, 311 insertions(+), 185 deletions(-) create mode 100644 firestar/src/main/resources/lightNegative.png create mode 100644 firestar/src/main/resources/lightPositive.png diff --git a/firestar/src/main/java/Bert.form b/firestar/src/main/java/Bert.form index b21139d..7499e47 100644 --- a/firestar/src/main/java/Bert.form +++ b/firestar/src/main/java/Bert.form @@ -108,7 +108,7 @@ - + @@ -120,54 +120,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + diff --git a/firestar/src/main/java/Bert.java b/firestar/src/main/java/Bert.java index 6ccc765..ec5c203 100644 --- a/firestar/src/main/java/Bert.java +++ b/firestar/src/main/java/Bert.java @@ -25,6 +25,7 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.io.*; +import java.util.ArrayList; public class Bert implements ActionListener { BufferedImage windowIcon; @@ -32,10 +33,10 @@ public class Bert implements ActionListener { private JPanel frameContainer; private JButton cancelbtn; private JButton downloadbtn; - private JRadioButton baseRad; - private JRadioButton patchRad; - private JRadioButton hdRad; - private JRadioButton furyRad; + private JCheckBox patchCheck; + private JCheckBox baseCheck; + private JCheckBox hdCheck; + private JCheckBox furyCheck; private ButtonGroup radios = new ButtonGroup(); private JFrame invoker; @@ -56,11 +57,6 @@ public class Bert implements ActionListener { frame.setLocationRelativeTo(parent); frame.setAlwaysOnTop(true); - radios.add(baseRad); - radios.add(patchRad); - radios.add(hdRad); - radios.add(furyRad); - cancelbtn.addActionListener(this); downloadbtn.addActionListener(this); @@ -112,29 +108,31 @@ public class Bert implements ActionListener { new File(Main.inpath + "dlc1.psarc").delete(); new File(Main.inpath + "dlc2.psarc").delete(); - Main.ArcTarget type; - Main.ArcKey key; - if (baseRad.isSelected()) { - type = Main.ArcTarget.BASE; - key = Main.ArcKey.BASE; + ArrayList arcs = new ArrayList(); + ArrayList keys = new ArrayList(); + if (baseCheck.isSelected()) { + arcs.add(Main.ArcTarget.BASE); + keys.add(Main.ArcKey.BASE); System.out.println("Begin download of data (Game version 1.0)"); - } else - if (patchRad.isSelected()) { - type = Main.ArcTarget.LATEST; - key = Main.ArcKey.LATEST; + } + if (patchCheck.isSelected()) { + arcs.add(Main.ArcTarget.LATEST); + keys.add(Main.ArcKey.LATEST); System.out.println("Begin download of data2 (Game version 1.04)"); - } else - if (hdRad.isSelected()) { - type = Main.ArcTarget.ADDON_HD; - key = Main.ArcKey.ADDON_HD; + } + if (hdCheck.isSelected()) { + arcs.add(Main.ArcTarget.ADDON_HD); + keys.add(Main.ArcKey.ADDON_HD); System.out.println("Begin download of dlc1 (HD DLC)"); - } else - if (furyRad.isSelected()) { - type = Main.ArcTarget.ADDON_HD_FURY; - key = Main.ArcKey.ADDON_HD_FURY; + } + if (furyCheck.isSelected()) { + arcs.add(Main.ArcTarget.ADDON_HD_FURY); + keys.add(Main.ArcKey.ADDON_HD_FURY); System.out.println("Begin download of dlc2 (Fury DLC)"); - } else { - return; // fire hydrant + } + if (arcs.isEmpty()) { + JOptionPane.showMessageDialog(invoker, "Select one or more asset packs.", "Error", JOptionPane.ERROR_MESSAGE); + return; } frame.dispose(); @@ -143,119 +141,140 @@ public class Bert implements ActionListener { Thread downloaderPopupThread = new Thread(new Runnable() { // run on separate thread to prevent GUI freezing @Override public void run() { - // download file - boolean downloader = new Fozzie().DownloadFile(type.toString(), Main.inpath, "asset.pkg"); - if (!downloader) { - // cleanup - new File(Main.inpath + "asset.pkg").delete(); - - // restore controls - invoker.setEnabled(true); - invoker.setVisible(true); - invoker.toFront(); - invoker.repaint(); - return; - } - - // dump contents - System.out.println("Extracting asset.pkg"); - Fozzie popup = new Fozzie(); - popup.displayTextOnly("Extracting PKG...", "Extracting"); - Process p; - try { - if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","cd " + Main.inpath + ";wine pkg2zip.exe -x asset.pkg " + key.toString()});} - else {p = Runtime.getRuntime().exec(new String[]{Main.inpath + "pkg2zip.exe", "-x", "asset.pkg", key.toString()}, null, new File(Main.inpath));} //inpath cannot change here - InputStream debugin = new BufferedInputStream(p.getInputStream()); - OutputStream debugout = new BufferedOutputStream(System.out); - int c; - while ((c = debugin.read()) != -1) { - debugout.write(c); + for (Main.ArcTarget type : arcs) { + String key = ""; + switch (type) { + case BASE -> key = Main.ArcKey.BASE.toString(); + case LATEST -> key = Main.ArcKey.LATEST.toString(); + case ADDON_HD -> key = Main.ArcKey.ADDON_HD.toString(); + case ADDON_HD_FURY -> key = Main.ArcKey.ADDON_HD_FURY.toString(); + } + if (key.isEmpty()) { + System.out.println("Internal Error: Bert got dementia. Get a programmer!"); + JOptionPane.showMessageDialog(invoker, "Internal Error: Bert got dementia. Get a programmer!", "Fatal Error", JOptionPane.ERROR_MESSAGE); + return; } - debugin.close(); - debugout.close(); - p.waitFor(); - } catch (Exception e) { - System.out.println(e.getMessage()); - JOptionPane.showMessageDialog(invoker, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); - new File(Main.inpath + "asset.pkg").delete(); - invoker.setEnabled(true); - invoker.setVisible(true); - invoker.toFront(); - invoker.repaint(); - return; - } - // decrypt - System.out.println("Decrypting asset.pkg"); - String extracted; - String name; - if (type == Main.ArcTarget.BASE) { - extracted = "app/PCSA00015"; - name = "data.psarc"; - } else if (type == Main.ArcTarget.LATEST) { - extracted = "patch/PCSA00015"; - name = "data2.psarc"; - } else if (type == Main.ArcTarget.ADDON_HD) { - extracted = "addcont/PCSA00015/DLC1W2048PACKAGE"; - name = "dlc1.psarc"; - } else if (type == Main.ArcTarget.ADDON_HD_FURY) { // this is not "always true" - intellij is actually very dumj - extracted = "addcont/PCSA00015/DLC2W2048PACKAGE"; - name = "dlc2.psarc"; - } else { - System.out.println("Internal Error: Bert got dementia. Get a programmer!"); - JOptionPane.showMessageDialog(invoker, "Internal Error: Bert got dementia. Get a programmer!", "Fatal Error", JOptionPane.ERROR_MESSAGE); + // download file + boolean downloader = new Fozzie().DownloadFile(type.toString(), Main.inpath, "asset.pkg"); + if (!downloader) { + // cleanup + new File(Main.inpath + "asset.pkg").delete(); + + // restore controls + invoker.setEnabled(true); + invoker.setVisible(true); + invoker.toFront(); + invoker.repaint(); + return; + } + + // dump contents + System.out.println("Extracting asset.pkg"); + Fozzie popup = new Fozzie(); + popup.displayTextOnly("Extracting PKG...", "Extracting"); + Process p; + try { + if (!Main.windows) { + p = Runtime.getRuntime().exec(new String[]{"bash", "-c", "cd " + Main.inpath + ";wine pkg2zip.exe -x asset.pkg " + key.toString()}); + } else { + p = Runtime.getRuntime().exec(new String[]{Main.inpath + "pkg2zip.exe", "-x", "asset.pkg", key.toString()}, null, new File(Main.inpath)); + } //inpath cannot change here + InputStream debugin = new BufferedInputStream(p.getInputStream()); + OutputStream debugout = new BufferedOutputStream(System.out); + int c; + while ((c = debugin.read()) != -1) { + debugout.write(c); + } + debugin.close(); + debugout.close(); + p.waitFor(); + } catch (Exception e) { + System.out.println(e.getMessage()); + JOptionPane.showMessageDialog(invoker, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); + new File(Main.inpath + "asset.pkg").delete(); + invoker.setEnabled(true); + invoker.setVisible(true); + invoker.toFront(); + invoker.repaint(); + return; + } + + // decrypt + System.out.println("Decrypting asset.pkg"); + String extracted; + String name; + if (type == Main.ArcTarget.BASE) { + extracted = "app/PCSA00015"; + name = "data.psarc"; + } else if (type == Main.ArcTarget.LATEST) { + extracted = "patch/PCSA00015"; + name = "data2.psarc"; + } else if (type == Main.ArcTarget.ADDON_HD) { + extracted = "addcont/PCSA00015/DLC1W2048PACKAGE"; + name = "dlc1.psarc"; + } else if (type == Main.ArcTarget.ADDON_HD_FURY) { // this is not "always true" - intellij is actually very dumj + extracted = "addcont/PCSA00015/DLC2W2048PACKAGE"; + name = "dlc2.psarc"; + } else { + System.out.println("Internal Error: Bert got dementia. Get a programmer!"); + JOptionPane.showMessageDialog(invoker, "Internal Error: Bert got dementia. Get a programmer!", "Fatal Error", JOptionPane.ERROR_MESSAGE); + new File(Main.inpath + "asset.pkg").delete(); + Main.deleteDir(new File(Main.inpath + "app/")); + Main.deleteDir(new File(Main.inpath + "patch/")); + Main.deleteDir(new File(Main.inpath + "addcont/")); + invoker.setEnabled(true); + invoker.setVisible(true); + invoker.toFront(); + invoker.repaint(); + return; + } + + popup.setText("Decrypting protected PFS:
" + extracted + "", "Decrypting"); + + try { + if (!Main.windows) { + p = Runtime.getRuntime().exec(new String[]{"bash", "-c", "cd " + Main.inpath + ";wine psvpfsparser.exe -i " + extracted + " -o ./temp/ -z " + key.toString() + " -f cma.henkaku.xyz"}); + } else { + p = Runtime.getRuntime().exec(new String[]{Main.inpath + "psvpfsparser.exe", "-i", extracted, "-o", "./temp/", "-z", key.toString(), "-f", "cma.henkaku.xyz"}, null, new File(Main.inpath)); + } + InputStream debugin = new BufferedInputStream(p.getInputStream()); + OutputStream debugout = new BufferedOutputStream(System.out); + int c; + while ((c = debugin.read()) != -1) { + debugout.write(c); + } + debugin.close(); + debugout.close(); + p.waitFor(); + } catch (Exception e) { + System.out.println(e.getMessage()); + JOptionPane.showMessageDialog(invoker, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); + new File(Main.inpath + "asset.pkg").delete(); + Main.deleteDir(new File(Main.inpath + "app/")); + Main.deleteDir(new File(Main.inpath + "patch/")); + Main.deleteDir(new File(Main.inpath + "addcont/")); + invoker.setEnabled(true); + invoker.setVisible(true); + invoker.toFront(); + invoker.repaint(); + return; + } + + popup.setText("Deleting temporary files...", "Cleaning Up"); + + // stage & cleanup + System.out.println("Cleaning up"); new File(Main.inpath + "asset.pkg").delete(); + new File(Main.inpath + "temp/PSP2/" + name).renameTo(new File(Main.inpath + name)); Main.deleteDir(new File(Main.inpath + "app/")); Main.deleteDir(new File(Main.inpath + "patch/")); Main.deleteDir(new File(Main.inpath + "addcont/")); - invoker.setEnabled(true); - invoker.setVisible(true); - invoker.toFront(); - invoker.repaint(); - return; + Main.deleteDir(new File(Main.inpath + "temp/")); + + popup.destroyDialog(); } - popup.setText("Decrypting protected PFS:
" + extracted + "", "Decrypting"); - - try { - if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","cd " + Main.inpath + ";wine psvpfsparser.exe -i " + extracted + " -o ./temp/ -z " + key.toString() + " -f cma.henkaku.xyz"});} - else {p = Runtime.getRuntime().exec(new String[]{Main.inpath + "psvpfsparser.exe", "-i", extracted, "-o", "./temp/", "-z", key.toString(), "-f", "cma.henkaku.xyz"}, null, new File(Main.inpath));} - InputStream debugin = new BufferedInputStream(p.getInputStream()); - OutputStream debugout = new BufferedOutputStream(System.out); - int c; - while ((c = debugin.read()) != -1) { - debugout.write(c); - } - debugin.close(); - debugout.close(); - p.waitFor(); - } catch (Exception e) { - System.out.println(e.getMessage()); - JOptionPane.showMessageDialog(invoker, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); - new File(Main.inpath + "asset.pkg").delete(); - Main.deleteDir(new File(Main.inpath + "app/")); - Main.deleteDir(new File(Main.inpath + "patch/")); - Main.deleteDir(new File(Main.inpath + "addcont/")); - invoker.setEnabled(true); - invoker.setVisible(true); - invoker.toFront(); - invoker.repaint(); - return; - } - - popup.setText("Deleting temporary files...", "Cleaning Up"); - - // stage & cleanup - System.out.println("Cleaning up"); - new File(Main.inpath + "asset.pkg").delete(); - new File(Main.inpath + "temp/PSP2/" + name).renameTo(new File(Main.inpath + name)); - Main.deleteDir(new File(Main.inpath + "app/")); - Main.deleteDir(new File(Main.inpath + "patch/")); - Main.deleteDir(new File(Main.inpath + "addcont/")); - Main.deleteDir(new File(Main.inpath + "temp/")); - - popup.destroyDialog(); - // restore controls JOptionPane.showMessageDialog(frame, "Assets downloaded successfully.", "Download Complete", JOptionPane.INFORMATION_MESSAGE); invoker.setEnabled(true); diff --git a/firestar/src/main/java/WilkinsCoffee.form b/firestar/src/main/java/WilkinsCoffee.form index 5c57386..d0fed0e 100644 --- a/firestar/src/main/java/WilkinsCoffee.form +++ b/firestar/src/main/java/WilkinsCoffee.form @@ -1,6 +1,6 @@
- + @@ -25,7 +25,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -66,21 +66,9 @@ - - - - - - - - - - - - - + @@ -90,12 +78,24 @@ + + + + + + + + + + + + - + @@ -126,6 +126,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/firestar/src/main/java/WilkinsCoffee.java b/firestar/src/main/java/WilkinsCoffee.java index 6e5e6f8..5d53936 100644 --- a/firestar/src/main/java/WilkinsCoffee.java +++ b/firestar/src/main/java/WilkinsCoffee.java @@ -46,6 +46,12 @@ public class WilkinsCoffee implements ActionListener { private JPanel inputContainer2; private JButton EXPORT_openFolderBtn; private JLabel pathDisplay; + private JPanel checklistContainer; + private JLabel checklistFury; + private JLabel checklistHD; + private JLabel checklistPatch2; + private JLabel checklistPatch1; + private JLabel checklistBase; public enum Pages { INTRO(0), @@ -66,6 +72,7 @@ public class WilkinsCoffee implements ActionListener { public void setup() { page = Pages.INTRO; inputContainer.setVisible(false); + checklistContainer.setVisible(false); inputContainer2.setVisible(false); // check if this is windows or not @@ -110,6 +117,7 @@ public class WilkinsCoffee implements ActionListener { frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setLayout(new GridLayout()); frame.setLocationRelativeTo(null); + refreshChecklist(); frame.setVisible(true); } @@ -122,6 +130,8 @@ public class WilkinsCoffee implements ActionListener { if (new Bert(frame).reportWhenDownloaded(threadParent)) { contBtn.setEnabled(true); contBtn.setBackground(new Color(221, 88, 11)); //orange + + refreshChecklist(); } }}); waiterThread.start(); @@ -189,6 +199,7 @@ public class WilkinsCoffee implements ActionListener { contBtn.setEnabled(false); contBtn.setBackground(new Color(102, 74, 58)); //brown inputContainer.setVisible(true); + checklistContainer.setVisible(true); if (!sdkInstalled) { PSARC_downBtn.setEnabled(false); PSARC_downBtn.setBackground(new Color(102, 74, 58)); //brown @@ -221,6 +232,7 @@ public class WilkinsCoffee implements ActionListener { contBtn.setEnabled(true); contBtn.setBackground(new Color(221, 88, 11)); //orange inputContainer.setVisible(false); + checklistContainer.setVisible(false); inputContainer2.setVisible(true); instructions.setText("\n" + @@ -275,4 +287,25 @@ public class WilkinsCoffee implements ActionListener { } } } + + private void refreshChecklist() { + ImageIcon positive = new ImageIcon(Main.class.getResource("/lightPositive.png")); + ImageIcon negative = new ImageIcon(Main.class.getResource("/lightNegative.png")); + + if(new File(Main.inpath + "data.psarc").exists()) { + checklistBase.setIcon(positive); + } else {checklistBase.setIcon(negative);} + if(new File(Main.inpath + "data1.psarc").exists()) { + checklistPatch1.setIcon(positive); + } else {checklistPatch1.setIcon(negative);} + if(new File(Main.inpath + "data2.psarc").exists()) { + checklistPatch2.setIcon(positive); + } else {checklistPatch2.setIcon(negative);} + if(new File(Main.inpath + "dlc1.psarc").exists()) { + checklistHD.setIcon(positive); + } else {checklistHD.setIcon(negative);} + if(new File(Main.inpath + "dlc2.psarc").exists()) { + checklistFury.setIcon(positive); + } else {checklistFury.setIcon(negative);} + } } diff --git a/firestar/src/main/resources/lightNegative.png b/firestar/src/main/resources/lightNegative.png new file mode 100644 index 0000000000000000000000000000000000000000..2950d2e14ce300c21b6ba536fcf2ddb56a9e879e GIT binary patch literal 823 zcmV-71IYY|P)EX>4Tx04R}tkv&MmKpe$iQ>7v;4ptCR$WWc^q9Tr3g(6f4wL+^7CYOFelZGV4 z#ZhoAIQX$xb#QUk)xlK|1V2EW9h?+hq{ROvg%&X$9QWhhy~o`jaOLWp1hBZ$e&GUg;H1>f;?j{slq;yla$+@B+&<}C&UMB-Uym^SeS@${x` zaNZ}5vXZP4pA(OpbV1@rt}7nDaW1+n@XV;0NzW5UiN#_ED;>;ArbawP98)!&@`bF& zD(5ZETBXKX_v9}O=k=9kuG1Vw5{p=Z1Q7~qD5C-!aawg!ETm~a;o~22{Svtpa+Sfz zv4AQx$gUs!4}N!R6(%RVq;LZ0esP?SQ6RJnH0zG@ee5{R6Cn5uTH00%Xo4wMdDfNoI-!eH0}_U2qhMquQhNaK7*Exflo%*<276`CYYfh8~pQedJ- zN1z7wK^d2e45b!z_ohq7EN*TVTwiGIjN6i2l(fJj^M2OFlMeQw24bcn2& zi%zH&sdUEQf{9>^=;E^CD7qD`s6|(<6?*|nLxWN@ED8hh!ue3QU9{5$H5LceL;y62 zwz_JEa?;?b&IW3d1FL~1ZQ$hp6PZs5{jq;regRgvU_31002ovPDHLkV1nkO BS?&M; literal 0 HcmV?d00001 diff --git a/firestar/src/main/resources/lightPositive.png b/firestar/src/main/resources/lightPositive.png new file mode 100644 index 0000000000000000000000000000000000000000..c9b8f672b2eb6725c2da41bb79849e1bd2ae8499 GIT binary patch literal 851 zcmV-Z1FZasP)EX>4Tx04R}tkv&MmKpe$iQ>7v;4ptCR$WWc^q9Tr3g(6f4wL+^7CYOFelZGV4 z#ZhoAIQX$xb#QUk)xlK|1V2EW9h?+hq{ROvg%&X$9QWhhy~o`jaOLWp1hBZ$e&GUg;H1>f;?j{slq;yla$+@B+&<}C&UMB-Uym^SeS@${x` zaNZ}5vXZP4pA(OpbV1@rt}7nDaW1+n@XV;0NzW5UiN#_ED;>;ArbawP98)!&@`bF& zD(5ZETBXKX_v9}O=k=9kuG1Vw5{p=Z1Q7~qD5C-!aawg!ETm~a;o~22{Svtpa+Sfz zv4AQx$gUs!4}N!R6(%RVq;LZ0esP?SQ6RJnH0zG@ee5{R6Cn5uT8Lz##`2YX_8FWQhbVF}#ZDnqB07G(RVRU6= zAa`kWXdp*PO;A^X4i^9b0W3*GK~zY`#g@TsgFp~P->%$4B&P(9DZnLIG(ZEoJg3)B$}YOAm) zBZ!yYRL!}I_S)xj(Mt1U*(r&3K$t;1D0q(F@<2(nxzQv5n{KMvUY|b$?#gntfRn~Q dhW^~YE$?MDZjR*fCiVaT002ovPDHLkV1mdjZVvze literal 0 HcmV?d00001