From cd05d82dfcd961a397670e0750d64f15d3ccb6ba Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Fri, 12 Jul 2024 05:22:26 -0500 Subject: [PATCH] Kermit rewrite (New setup screen) --- firestar/src/main/java/Bert.java | 12 ++ firestar/src/main/java/Main.java | 5 +- firestar/src/main/java/Waldorf.java | 2 +- firestar/src/main/java/WilkinsCoffee.form | 77 +++++++++- firestar/src/main/java/WilkinsCoffee.java | 167 +++++++++++++++++++++- 5 files changed, 253 insertions(+), 10 deletions(-) diff --git a/firestar/src/main/java/Bert.java b/firestar/src/main/java/Bert.java index 9a8c92c..eb2b36c 100644 --- a/firestar/src/main/java/Bert.java +++ b/firestar/src/main/java/Bert.java @@ -40,6 +40,8 @@ public class Bert implements ActionListener { private JFrame invoker; + private boolean wilkinsDownloadFinished = false; + public Bert(JFrame parent) { parent.setEnabled(false); this.invoker = parent; @@ -86,6 +88,15 @@ public class Bert implements ActionListener { } } + public boolean reportWhenDownloaded(WilkinsCoffee setup) { + while (frame.isActive() || !wilkinsDownloadFinished) {} + if (wilkinsDownloadFinished) { // intellij please shut the everloving FUCK up DON'T do this again or i will skin you alive + return true; + } else { + return false; + } + } + @Override public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == cancelbtn) { @@ -251,6 +262,7 @@ public class Bert implements ActionListener { invoker.setVisible(true); invoker.toFront(); invoker.repaint(); + wilkinsDownloadFinished = true; } }); downloaderPopupThread.start(); diff --git a/firestar/src/main/java/Main.java b/firestar/src/main/java/Main.java index 2788d13..2fd4847 100644 --- a/firestar/src/main/java/Main.java +++ b/firestar/src/main/java/Main.java @@ -119,13 +119,11 @@ public class Main { fExo2 = new Font("Arial", Font.PLAIN, 12); } - new WilkinsCoffee().setup(); // move to below if statement after completion - // check and load configs File fConf = new File(System.getProperty("user.home") + "/.firestar/firestar.conf"); if (!fConf.isFile()) { System.out.println("No configuration was found. Starting the initial setup"); - new Kermit().setup(fConf); // this is a fresh install, run the OOBE. + new WilkinsCoffee().setup(); } else { new MissPiggy().Action(); // Quick! Start singing Firework by Katy Perry! (or open the main window i guess...) } @@ -159,7 +157,6 @@ public class Main { System.out.println("ERROR: Failed to load firestar.conf"); System.out.println(e.getMessage()); } - return; } public static void loadConf(MissPiggy w){ diff --git a/firestar/src/main/java/Waldorf.java b/firestar/src/main/java/Waldorf.java index 5b3afa5..a36a8bd 100644 --- a/firestar/src/main/java/Waldorf.java +++ b/firestar/src/main/java/Waldorf.java @@ -95,7 +95,7 @@ public class Waldorf implements ActionListener { invoker.frame.setEnabled(true); frame.dispose(); } else - if (actionEvent.getSource() == resetbtn) { // todo: delete firesdk + if (actionEvent.getSource() == resetbtn) { // todo: delete firesdk // you sure? int result = JOptionPane.showConfirmDialog(frame,"Are you sure you want to redo the initial setup?", "Restore Default Settings", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (result == JOptionPane.YES_OPTION) { new File(System.getProperty("user.home") + "/.firestar/firestar.conf").delete(); diff --git a/firestar/src/main/java/WilkinsCoffee.form b/firestar/src/main/java/WilkinsCoffee.form index 0904d65..ad93762 100644 --- a/firestar/src/main/java/WilkinsCoffee.form +++ b/firestar/src/main/java/WilkinsCoffee.form @@ -1,6 +1,6 @@
- + @@ -43,16 +43,87 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/firestar/src/main/java/WilkinsCoffee.java b/firestar/src/main/java/WilkinsCoffee.java index 46b21c2..e494cd6 100644 --- a/firestar/src/main/java/WilkinsCoffee.java +++ b/firestar/src/main/java/WilkinsCoffee.java @@ -18,24 +18,62 @@ import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.text.html.HTMLDocument; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; +import java.nio.file.Files; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; -public class WilkinsCoffee { +public class WilkinsCoffee implements ActionListener { BufferedImage windowIcon; + Image logo; + public Pages page; public JFrame frame = new JFrame(); private JPanel frameContainer; private JLabel picLabel; private JEditorPane instructions; private JButton contBtn; + private JPanel inputContainer; + private JButton PSARC_downBtn; + private JButton PSARC_impBtn; + private JPanel inputContainer2; + private JButton EXPORT_openFolderBtn; + private JLabel pathDisplay; - Image logo; + public enum Pages { + INTRO(0), + PSARC(1), + EXPORT_LOCATION(2), + DONE(3); + + public final int value; + + private Pages(int i) { + this.value = i; + } + } + + private String outPathTemp = System.getProperty("user.home") + "/Documents/"; public void setup() { + page = Pages.INTRO; + inputContainer.setVisible(false); + inputContainer2.setVisible(false); + + // check if this is windows or not + if(System.getProperty("os.name").contains("Windows")) {Main.windows = true;System.out.println("Assuming we should NOT use WINE based on known system variables.");} + else {Main.windows = false;System.out.println("Assuming we should use WINE based on known system variables.");} + + // reformat path slightly for windows + if (Main.windows) {outPathTemp.replace("/", "\\");} + try { windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); frame.setIconImage(windowIcon); @@ -54,9 +92,17 @@ public class WilkinsCoffee { ((HTMLDocument)instructions.getDocument()).getStyleSheet().addRule(bodyRule); instructions.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); // makes text smaller than joe biden's windmill if font set manually. wtf?? contBtn.setFont(Main.fExo2.deriveFont(Font.BOLD).deriveFont(12f)); + PSARC_downBtn.setFont(Main.fExo2.deriveFont(Font.BOLD).deriveFont(12f)); + PSARC_impBtn.setFont(Main.fExo2.deriveFont(Font.BOLD).deriveFont(12f)); + EXPORT_openFolderBtn.setFont(Main.fExo2.deriveFont(Font.BOLD).deriveFont(12f)); frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA + contBtn.addActionListener(this); + PSARC_downBtn.addActionListener(this); + PSARC_impBtn.addActionListener(this); + EXPORT_openFolderBtn.addActionListener(this); + frame.setSize(400, 400); frame.setTitle("Firestar Setup"); frame.setResizable(false); @@ -65,4 +111,121 @@ public class WilkinsCoffee { frame.setLocationRelativeTo(null); frame.setVisible(true); } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + WilkinsCoffee threadParent = this; + if (actionEvent.getSource() == PSARC_downBtn) { + Thread waiterThread = new Thread(new Runnable() {@Override + public void run() { + if (new Bert(frame).reportWhenDownloaded(threadParent)) { + contBtn.setEnabled(true); + contBtn.setBackground(new Color(221, 88, 11)); //orange + } + }}); + waiterThread.start(); + } else + if (actionEvent.getSource() == PSARC_impBtn) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileFilter fileChooserFilter = new FileNameExtensionFilter("Sony Playstation Archive File", "psarc"); + fileChooser.setFileFilter(fileChooserFilter); + int result = fileChooser.showOpenDialog(frame); + if (result == JFileChooser.APPROVE_OPTION) { + try { + Files.copy(fileChooser.getSelectedFile().toPath(), new File(Main.inpath + fileChooser.getSelectedFile().getName()).toPath()); + contBtn.setEnabled(true); + contBtn.setBackground(new Color(221, 88, 11)); //orange + } catch (IOException e) { + System.out.println(e.getMessage()); + JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + } else + if (actionEvent.getSource() == EXPORT_openFolderBtn) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int result = fileChooser.showOpenDialog(frame); + if (result == JFileChooser.APPROVE_OPTION) { + if (fileChooser.getSelectedFile().isDirectory()) { + outPathTemp = fileChooser.getSelectedFile().getAbsolutePath(); + pathDisplay.setText("Export path: " + outPathTemp); + } + } + } else + if (actionEvent.getSource() == contBtn) { + switch (page) { + case INTRO: + page = Pages.PSARC; + //contBtn.setEnabled(false); + contBtn.setBackground(new Color(102, 74, 58)); //brown + inputContainer.setVisible(true); + + instructions.setText("\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "

\n" + + " You must dump the original assets from WipEout 2048 so that Firestar can patch them.

If you would like, you can choose to have these downloaded and extracted for you, or you can provide your own decrypted dumps.

To decrypt your own dumps, please see \"Decrypting Original PSARC Files\" in the manual.\n" + + "

\n" + + "

\n" + + " Press "Continue" when you are done.\n" + + "

\n" + + " \n" + + "\n"); + + break; + case PSARC: + page = Pages.EXPORT_LOCATION; + contBtn.setEnabled(true); + contBtn.setBackground(new Color(221, 88, 11)); //orange + inputContainer.setVisible(false); + inputContainer2.setVisible(true); + + instructions.setText("\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "

\n" + + " Almost done!

Select the folder you would like to export your compiled mods to.

When you select \"Deploy\" in the mod list, Firestar will place a PSARC file into this folder which you can install onto your Vita.\n" + + "

\n" + + "

\n" + + " Press "Continue" when you are done.\n" + + "

\n" + + " \n" + + "\n"); + + pathDisplay.setText("Export path: " + outPathTemp); + + break; + case EXPORT_LOCATION: + page = Pages.DONE; + inputContainer2.setVisible(false); + Main.outpath = outPathTemp + "/"; + Main.repatch = true; + Main.writeConf(); + + instructions.setText("\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "

\n" + + " Setup complete!\n" + + "

\n" + + " \n" + + "\n"); + + break; + case DONE: + frame.dispose(); + new MissPiggy().Action(); + break; + default: + throw new UnsupportedOperationException("ERROR: Setup page-flip event listener didn't drink any Wilkins Coffee. Get a programmer!"); + } + } + } }