Kermit rewrite (New setup screen)

This commit is contained in:
Downforce Agent 2024-07-12 05:22:26 -05:00
parent 9cba7fcdb3
commit cd05d82dfc
5 changed files with 253 additions and 10 deletions

View File

@ -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();

View File

@ -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){

View File

@ -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();

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="WilkinsCoffee">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="20" y="20" width="416" height="455"/>
@ -43,16 +43,87 @@
</component>
<component id="c3ec3" class="javax.swing.JButton" binding="contBtn">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
<borderPainted value="false"/>
<focusPainted value="false"/>
<foreground color="-5180417"/>
<foreground color="-526337"/>
<text value="Continue"/>
</properties>
</component>
<grid id="ee2dd" binding="inputContainer" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="3" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-15128227"/>
<focusable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="1c41b" class="javax.swing.JButton" binding="PSARC_downBtn">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
<borderPainted value="false"/>
<focusPainted value="false"/>
<foreground color="-592129"/>
<text value="Auto-Download"/>
</properties>
</component>
<component id="30c84" class="javax.swing.JButton" binding="PSARC_impBtn">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
<borderPainted value="false"/>
<focusPainted value="false"/>
<foreground color="-592129"/>
<text value="Import My Own"/>
</properties>
</component>
</children>
</grid>
<grid id="8468" binding="inputContainer2" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="3" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-15128227"/>
</properties>
<border type="none"/>
<children>
<component id="2cef5" class="javax.swing.JButton" binding="EXPORT_openFolderBtn">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-2271221"/>
<borderPainted value="false"/>
<focusPainted value="false"/>
<foreground color="-592129"/>
<text value="Select Folder"/>
</properties>
</component>
<component id="31a4b" class="javax.swing.JLabel" binding="pathDisplay">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Exo 2" size="12"/>
<foreground color="-592129"/>
<text value="Your Documents folder is selected by default."/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@ -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("<html>\n" +
" <head>\n" +
" \n" +
" </head>\n" +
" <body>\n" +
" <p id=\"first-p\">\n" +
" You must dump the original assets from WipEout 2048 so that Firestar can patch them.<br><br>If you would like, you can choose to have these downloaded and extracted for you, or you can provide your own decrypted dumps.</p><p>To decrypt your own dumps, please see \"Decrypting Original PSARC Files\" in the manual.\n" +
" </p>\n" +
" <p>\n" +
" Press &quot;Continue&quot; when you are done.\n" +
" </p>\n" +
" </body>\n" +
"</html>\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("<html>\n" +
" <head>\n" +
" \n" +
" </head>\n" +
" <body>\n" +
" <p id=\"first-p\">\n" +
" Almost done!<br><br>Select the folder you would like to export your compiled mods to.<br><br>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" +
" </p>\n" +
" <p>\n" +
" Press &quot;Continue&quot; when you are done.\n" +
" </p>\n" +
" </body>\n" +
"</html>\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("<html>\n" +
" <head>\n" +
" \n" +
" </head>\n" +
" <body>\n" +
" <p id=\"first-p\">\n" +
" Setup complete!\n" +
" </p>\n" +
" </body>\n" +
"</html>\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!");
}
}
}
}