Compare commits
39 Commits
72b075bf7b
...
beta-4
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f286b5c91 | |||
| 2735c311ad | |||
| a9f0fc3f4c | |||
| f8146fd493 | |||
| d57f183785 | |||
| 9a267e4f8d | |||
| f6b8eeb29e | |||
| 679b4bc68e | |||
| b7d6ddd701 | |||
| 29dec51c2e | |||
| d79b360553 | |||
| bf0421552c | |||
| c7f2a84c3a | |||
| addd23b760 | |||
| 8cc7fca35c | |||
| 6078cb3bec | |||
| a7d261597e | |||
| 5d683bb893 | |||
| fcb71d4600 | |||
| 8ebec68caf | |||
| 002d995c05 | |||
| 9780c3cc4f | |||
| 8107aaa5d5 | |||
| 6d772f0949 | |||
| d8902af148 | |||
| 2e1fe95670 | |||
| 45fbe80f9f | |||
| 886ef3089d | |||
| 28d710a815 | |||
| a1f41584a4 | |||
| e2229afe70 | |||
| b9743ee456 | |||
| fcda7b8cf4 | |||
| 433bc685dc | |||
| 5ab96366a6 | |||
| e4497afaa3 | |||
| 5a004b6744 | |||
| 7f5b0b85ae | |||
| f582cdb052 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -26,4 +26,5 @@ bin/
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
/firestar.zip
|
||||
|
||||
19
.idea/artifacts/firestar.xml
generated
Normal file
19
.idea/artifacts/firestar.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jpackage" name="firestar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/firestar</output-path>
|
||||
<properties id="jpackage-properties">
|
||||
<options>
|
||||
<option name="version" value="natasha" />
|
||||
<option name="copyright" value="(C) 2024 bonkmaykr" />
|
||||
<option name="description" value="" />
|
||||
<option name="vendor" value="Anti-Gravity Racing Federation" />
|
||||
<option name="mainClass" value="Main" />
|
||||
</options>
|
||||
</properties>
|
||||
<root id="root">
|
||||
<element id="archive" name="firestar.jar">
|
||||
<element id="module-output" name="firestar" />
|
||||
</element>
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
24
README.md
24
README.md
@@ -1,8 +1,17 @@
|
||||

|
||||
|
||||
# about 60% complete (config I/O in progress, basic systems functional)
|
||||
|
||||
Firestar is a mod manager for WipEout 2048 which automatically handles sorting mods by priority and repacking game assets based on selected add-on packs. It runs on a desktop/laptop computer and aims to allow easy installation of mods for users who have only a surface level understanding of hacking the PSVita.
|
||||
|
||||
# about 95% complete
|
||||
**What works:**
|
||||
- Managing mods (install, add, delete, toggle on/off)
|
||||
- Cross-platform support
|
||||
|
||||
**What doesn't work yet:**
|
||||
- settings screen
|
||||
- misc. tools (pack creator, soundtrack mod generator...)
|
||||
- initial setup screen can still be a bit arduous for vita newbies
|
||||
|
||||

|
||||
|
||||
# System Requirements
|
||||
@@ -27,11 +36,9 @@ Typical mod metadata will look something like this:
|
||||
```
|
||||
|
||||
# FAQ
|
||||
## What is the difference between Compatibility Mode and Fast Mode?
|
||||
Fast Mode is the most intuitive solution. It simply unpacks all of the assets into a folder for the game to read. This makes it trivial to go back and modify it later without repacking anything and it means you don't need stolen Sony-confidential equipment. However, PSVita and PSTV memory cards use the exFAT filesystem which really does not play nice with WipEout assets and causes all sorts of glitches, so using a genuine PSARC is an absolute necessity when playing on a real console. Compatibility mode uses a real PSARC tool to try and create mod files as similar to the original game files as possible and create minimal friction with the game engine.
|
||||
|
||||
## (Non-Windows) Do I need WINE? And why?
|
||||
Only if you use Compatibility Mode. psp2psarc.exe is a Windows-only tool so we call WINE internally when needed, but Firestar itself will run on any desktop platform with a compliant Java runtime.
|
||||
Yes. psp2psarc.exe is a Windows-only tool. Firestar can run natively on the system but it needs WINE in order to pack the game assets.
|
||||
**If you are on Mac OS X you will need an older OS version that is still compatible with 32-bit applications.**
|
||||
|
||||
## Why do I need a leaked Playstation SDK?
|
||||
Because many third-party programs for opening PSARC files either have no ability to create new ones or are prone to corruption bugs. Using the one made by the developers of the file format is the best option as it's what the game developers would have used. Obviously this creates all kinds of legal grey areas so I can't distribute Sony's proprietary software next to my code. It's downloaded separately.
|
||||
@@ -40,4 +47,7 @@ Because many third-party programs for opening PSARC files either have no ability
|
||||
Cross-platform support with no hassle, a built-in UI framework, and I don't need to sell my soul like every Electron or React 'Native' developer is doing these days.
|
||||
|
||||
## Why the name "Firestar"?
|
||||
Firestar was a secret track in the original WipEout which you unlocked after beating the game at least once, the mod manager is just named after that. Major versions are named after pilots or tracks. Internal class names are named after Muppets characters as this is the same naming convention that Sony used to codename parts inside the PSVita's SOC.
|
||||
Firestar was a secret track in the original WipEout which you unlocked after beating the game at least once, the mod manager is just named after that. Major versions are named after pilots or tracks. Internal class names are named after Muppets characters as this is the same naming convention that Sony used to codename parts inside the PSVita's SOC.
|
||||
|
||||
## Fast Mode vs. Compatibility Mode
|
||||
"Fast Mode" was a legacy option that was scrapped before it could be developed. It skipped the creation of a PSARC file and simply dumped the final game assets to their destination folder. This works great for emulators, and doesn't require proprietary stolen SDKs from SCE. However the filesystem on the Playstation Vita really hated this method and would glitch out when this was done, causing textures to be corrupted once placed on the memory card. The WipEout engine has no fault tolerance for malformed or missing assets, so it just crashes instantly when it encounters one. This is where Compatibility mode comes from, which is the default setting for 2048.
|
||||
108
src/Gonzo.java
108
src/Gonzo.java
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.util.FileUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
@@ -86,7 +87,7 @@ public class Gonzo {
|
||||
final Thread managerThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Main.repatch) {
|
||||
if (/*Main.repatch*/true) { //todo implement fast mode correctly or remove
|
||||
CompatibilityRoutine();
|
||||
} else {
|
||||
FastRoutine();
|
||||
@@ -128,7 +129,7 @@ public class Gonzo {
|
||||
System.out.println(line);
|
||||
consoleDisplay.append(line + "\n");
|
||||
try {scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());}
|
||||
catch (Exception e) {System.out.println("WARNING: Swing failed to paint window due to race condition.\n" + e.getMessage());}
|
||||
catch (Exception e) {System.out.println("WARNING: Swing failed to paint window due to race condition. You can safely ignore this.\n" + e.getMessage());}
|
||||
}
|
||||
reader.close();
|
||||
} catch (final Exception e) {
|
||||
@@ -141,6 +142,7 @@ public class Gonzo {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
System.out.println(e.getMessage());
|
||||
consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage());
|
||||
JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
@@ -150,48 +152,51 @@ public class Gonzo {
|
||||
// overwrite assets with custom ones from each mod and/or perform operations as specified in mod's delete list
|
||||
// todo: implement RegEx functions after delete.txt
|
||||
for (Main.Mod m : Main.Mods) {
|
||||
try {
|
||||
System.out.println("Firestar is extracting " + m.friendlyName + " by " + m.author);
|
||||
consoleDisplay.append("Firestar is extracting " + m.friendlyName + " by " + m.author + "\n");
|
||||
new ZipFile(System.getProperty("user.home") + "/.firestar/mods/" + m.path).extractAll(System.getProperty("user.home") + "/.firestar/temp/");
|
||||
if (m.enabled) {
|
||||
try {
|
||||
System.out.println("Firestar is extracting " + m.friendlyName + " by " + m.author);
|
||||
consoleDisplay.append("Firestar is extracting " + m.friendlyName + " by " + m.author + "\n");
|
||||
new ZipFile(System.getProperty("user.home") + "/.firestar/mods/" + m.path).extractAll(System.getProperty("user.home") + "/.firestar/temp/");
|
||||
|
||||
if (new File(System.getProperty("user.home") + "/.firestar/temp/delete.txt").isFile()) {
|
||||
System.out.println("Firestar is deleting files that conflict with " + m.friendlyName + " by " + m.author);
|
||||
consoleDisplay.append("Firestar is deleting files that conflict with " + m.friendlyName + " by " + m.author + "\n");
|
||||
if (new File(System.getProperty("user.home") + "/.firestar/temp/delete.txt").isFile()) {
|
||||
System.out.println("Firestar is deleting files that conflict with " + m.friendlyName + " by " + m.author);
|
||||
consoleDisplay.append("Firestar is deleting files that conflict with " + m.friendlyName + " by " + m.author + "\n");
|
||||
|
||||
String deleteQueue = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/temp/delete.txt")));
|
||||
if (Main.windows) {deleteQueue = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "\\.firestar\\temp\\delete.txt")));} // might be unnecessary
|
||||
String[] dQarray = deleteQueue.split("\n");
|
||||
Arrays.sort(dQarray);
|
||||
System.out.println("The deletion queue is " + dQarray.length + " files long!"); //debug
|
||||
String deleteQueue = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/temp/delete.txt")));
|
||||
if (Main.windows) {deleteQueue = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "\\.firestar\\temp\\delete.txt")));} // might be unnecessary
|
||||
String[] dQarray = deleteQueue.split("\n");
|
||||
Arrays.sort(dQarray);
|
||||
System.out.println("The deletion queue is " + dQarray.length + " files long!"); //debug
|
||||
|
||||
for (String file : dQarray) {
|
||||
if(file.contains("..")) { //todo: find all possible hazardous paths and blacklist them with regex
|
||||
System.out.println("WARNING: Firestar skipped a potentially dangerous delete command. Please ensure the mod you're installing is from someone you trust!");
|
||||
consoleDisplay.append("WARNING: Firestar skipped a potentially dangerous delete command. Please ensure the mod you're installing is from someone you trust!\n");
|
||||
} else {
|
||||
if (!Main.windows) {
|
||||
System.out.println("Deleting " + System.getProperty("user.home") + "/.firestar/temp/data/" + file);
|
||||
consoleDisplay.append("Deleting " + System.getProperty("user.home") + "/.firestar/temp/data/" + file + "\n");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data" + file).delete();}
|
||||
else {
|
||||
System.out.println("Deleting " + new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\"));
|
||||
consoleDisplay.append("Deleting " + new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\") + "\n");
|
||||
new File(new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\")).delete();
|
||||
for (String file : dQarray) {
|
||||
if(file.contains("..")) { //todo: find all possible hazardous paths and blacklist them with regex
|
||||
System.out.println("WARNING: Firestar skipped a potentially dangerous delete command. Please ensure the mod you're installing is from someone you trust!");
|
||||
consoleDisplay.append("WARNING: Firestar skipped a potentially dangerous delete command. Please ensure the mod you're installing is from someone you trust!\n");
|
||||
} else {
|
||||
if (!Main.windows) {
|
||||
System.out.println("Deleting " + System.getProperty("user.home") + "/.firestar/temp/data/" + file);
|
||||
consoleDisplay.append("Deleting " + System.getProperty("user.home") + "/.firestar/temp/data/" + file + "\n");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data" + file).delete();}
|
||||
else {
|
||||
System.out.println("Deleting " + new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\"));
|
||||
consoleDisplay.append("Deleting " + new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\") + "\n");
|
||||
new File(new String(System.getProperty("user.home") + "\\.firestar\\temp\\data" + file).replace("/", "\\")).delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup so we don't run it again for the next mod unless needed
|
||||
// this is not necessary but good practice
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/delete.txt").delete();
|
||||
// cleanup so we don't run it again for the next mod unless needed
|
||||
// this is not necessary but good practice
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/delete.txt").delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage());
|
||||
JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage());
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,6 +228,7 @@ public class Gonzo {
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage());
|
||||
JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
@@ -259,21 +265,32 @@ public class Gonzo {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
System.out.println(e.getMessage());
|
||||
consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage());
|
||||
JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
new File(Main.outpath).mkdirs();
|
||||
if (!Main.windows) {new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
|
||||
else {new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
|
||||
boolean one = new File(Main.outpath).mkdirs();
|
||||
boolean two;
|
||||
System.out.println("created export folder: " + one);
|
||||
if (new File(Main.outpath + oArcTarget).exists()) {System.out.println("deleting existing file: " + Main.outpath + oArcTarget); new File(Main.outpath + oArcTarget).delete();} //hackjob
|
||||
if (!Main.windows) {two = new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
|
||||
else {two = new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
|
||||
System.out.println("moved file to destination: " + two);
|
||||
if (two) {System.out.println("file should be located at " + Main.outpath + oArcTarget);} else {
|
||||
System.out.println("CRITICAL FAILURE: Please check that your output path is correct and that you have write permissions!");
|
||||
consoleDisplay.append("CRITICAL FAILURE: Please check that your output path is correct and that you have write permissions!");
|
||||
JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: Please check that your output path is correct and that you have write permissions!", "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
AllowExit();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Process p;
|
||||
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","rm -rf " + System.getProperty("user.home") + "/.firestar/temp/"});} // Scary!
|
||||
else {p = Runtime.getRuntime().exec(new String[]{"rmdir", new String(System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\").replace("\\", "\\\\"), "/s", "/q"});}
|
||||
//new File(System.getProperty("user.home") + "/.firestar/temp/").delete();
|
||||
} catch (IOException e) {
|
||||
File tmp = new File(System.getProperty("user.home") + "/.firestar/temp/");
|
||||
Main.deleteDir(tmp);
|
||||
} catch (Exception e) {
|
||||
System.out.println("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage());
|
||||
consoleDisplay.append("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage());
|
||||
}
|
||||
@@ -302,6 +319,7 @@ public class Gonzo {
|
||||
public void AllowExit() {
|
||||
System.out.println("\n\nYou may now close the pop-up window.");
|
||||
consoleDisplay.append("\n\n\nYou may now close the pop-up window.");
|
||||
try {TimeUnit.MILLISECONDS.sleep(200);} catch (InterruptedException e) {} //ignore
|
||||
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
|
||||
frame.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Kermit implements ActionListener {
|
||||
button.setVisible(false);frame.remove(button);
|
||||
button2.setVisible(false);frame.remove(button2);
|
||||
dialogText.setVisible(false);frame.remove(dialogText);
|
||||
changePage(Pages.EXPORT_MODE);
|
||||
changePage(Pages.SDK_INSTALL); // EXPORT_MODE
|
||||
break;
|
||||
case EXPORT_MODE:
|
||||
button.setVisible(false);frame.remove(button);
|
||||
@@ -341,8 +341,8 @@ public class Kermit implements ActionListener {
|
||||
dialogText.setVisible(false);frame.remove(dialogText);
|
||||
|
||||
//check if this is windows or not
|
||||
if(System.getProperty("os.name").contains("Windows")) {Main.windows = false;System.out.println("Assuming we should NOT use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);}
|
||||
else {Main.windows = true;System.out.println("Assuming we should use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);}
|
||||
if(System.getProperty("os.name").contains("Windows")) {Main.windows = true;System.out.println("Assuming we should NOT use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);}
|
||||
else {Main.windows = false;System.out.println("Assuming we should use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);}
|
||||
|
||||
case EXPORT_LOCATION:
|
||||
page = Pages.EXPORT_LOCATION;
|
||||
|
||||
@@ -21,10 +21,11 @@ import org.json.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class Main {
|
||||
// Build Information
|
||||
public static final String vstr = "PREALPHA";
|
||||
public static final String vstr = "Beta 4";
|
||||
public static final String vcode = "Natasha";
|
||||
public static final int vint = 0;
|
||||
|
||||
@@ -47,6 +48,7 @@ public class Main {
|
||||
public String game; //TODO for multi game support
|
||||
public int loaderversion = 0; //minimum required vint or feature level from Firestar
|
||||
public String author; // if null, "Author is unknown."
|
||||
public boolean enabled = true;
|
||||
}
|
||||
|
||||
// Mods
|
||||
@@ -98,6 +100,44 @@ public class Main {
|
||||
}
|
||||
|
||||
public static void loadConf(){
|
||||
try {
|
||||
JSONObject container = new JSONObject(new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/firestar.conf"))));
|
||||
System.out.println(container.toString()); // debug
|
||||
int confvint = (int) container.get("version"); // used for converting configs between program versions later down the line
|
||||
outpath = container.get("2048path").toString();
|
||||
repatch = (boolean) container.get("safemode");
|
||||
windows = (boolean) container.get("isWin32");
|
||||
} catch (IOException e) {
|
||||
System.out.println("ERROR: Failed to load firestar.conf");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public static void loadConf(MissPiggy w){
|
||||
try {
|
||||
JSONObject container = new JSONObject(new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/firestar.conf"))));
|
||||
System.out.println(container.toString()); // debug
|
||||
int confvint = (int) container.get("version"); // used for converting configs between program versions later down the line
|
||||
outpath = container.get("2048path").toString();
|
||||
repatch = (boolean) container.get("safemode");
|
||||
windows = (boolean) container.get("isWin32");
|
||||
} catch (Exception e) {
|
||||
JOptionPane.showMessageDialog(w.frame, "Firestar couldn't load your config file. Tread lightly.\n\n" + e.getMessage(), "Critical Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.out.println("ERROR: Failed to load firestar.conf");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDir(File file) { // https://stackoverflow.com/a/29175213/9259829
|
||||
File[] contents = file.listFiles();
|
||||
if (contents != null) {
|
||||
for (File f : contents) {
|
||||
if (! Files.isSymbolicLink(f.toPath())) {
|
||||
deleteDir(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
@@ -19,21 +19,30 @@
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.lingala.zip4j.*;
|
||||
import net.lingala.zip4j.exception.ZipException;
|
||||
import org.json.JSONObject;
|
||||
import static java.nio.file.StandardCopyOption.*;
|
||||
|
||||
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
|
||||
|
||||
@@ -62,13 +71,18 @@ public class MissPiggy implements ActionListener {
|
||||
private JButton deployButton;
|
||||
private JTextPane descriptionField;
|
||||
|
||||
private int selectedItem;
|
||||
//private int selectedItem;
|
||||
|
||||
public String priorityList;
|
||||
public String blackList;
|
||||
|
||||
public boolean listenersAlreadySet = false; // was written to troubleshoot a bug but this wasn't actually the cause
|
||||
|
||||
// Initialize the main window
|
||||
public void Action(/*Main entryPoint*/) {
|
||||
System.out.println("Main window created");
|
||||
System.out.println("Loading program configuration");
|
||||
Main.loadConf(this);
|
||||
|
||||
// populate menu bar
|
||||
menuBar = new JMenuBar();
|
||||
@@ -76,9 +90,10 @@ public class MissPiggy implements ActionListener {
|
||||
toolsMenu = new JMenu("Tools");
|
||||
helpMenu = new JMenu("Help");
|
||||
|
||||
fileMenu.add(new JMenuItem("Deploy All Mods"));
|
||||
fileMenu.add(new JMenuItem("Import Mod..."));
|
||||
fileMenu.add(new JMenuItem("Remove All"));
|
||||
fileMenu.add(new JMenuItem("Deploy Mods"));
|
||||
fileMenu.add(new JMenuItem("Import Mod from File"));
|
||||
//fileMenu.add(new JSeparator());
|
||||
fileMenu.add(new JMenuItem("Delete All"));
|
||||
fileMenu.add(new JSeparator());
|
||||
fileMenu.add(new JMenuItem("Options"));
|
||||
fileMenu.add(new JMenuItem("Quit"));
|
||||
@@ -88,6 +103,9 @@ public class MissPiggy implements ActionListener {
|
||||
toolsMenu.add(new JMenuItem("Create Soundtrack Mod..."));
|
||||
//toolsMenu.add(new JMenuItem("Download Mod from URL")); // TODO: implement. move option to File menu. should be ez
|
||||
|
||||
helpMenu.add(new JMenuItem("Source Code")); //replace with Website 'screwgravity.net' and 'Issue Tracker' gitea later
|
||||
helpMenu.add(new JMenuItem("License"));
|
||||
helpMenu.add(new JSeparator());
|
||||
helpMenu.add(new JMenuItem("About Firestar"));
|
||||
|
||||
menuBar.add(fileMenu);
|
||||
@@ -108,41 +126,20 @@ public class MissPiggy implements ActionListener {
|
||||
fileMenu.getItem(5).addActionListener(this);
|
||||
toolsMenu.getItem(0).addActionListener(this);
|
||||
toolsMenu.getItem(1).addActionListener(this);
|
||||
toolsMenu.getItem(2).addActionListener(this);
|
||||
helpMenu.getItem(0).addActionListener(this);
|
||||
helpMenu.getItem(1).addActionListener(this);
|
||||
helpMenu.getItem(3).addActionListener(this);
|
||||
|
||||
deployButton.addActionListener(this);
|
||||
importButton.addActionListener(this);
|
||||
deleteButton1.addActionListener(this);
|
||||
optionsButton.addActionListener(this);
|
||||
moveUpButton.addActionListener(this);
|
||||
moveDownButton.addActionListener(this);
|
||||
toggleButton.addActionListener(this);
|
||||
|
||||
descriptionField.getDocument().putProperty("filterNewlines", Boolean.FALSE);
|
||||
modList.addListSelectionListener(e -> {
|
||||
String authorDisplay;
|
||||
File pathReference = new File(System.getProperty("user.home") + "/.firestar/mods/" + Main.Mods.get(modList.getSelectedIndex()).path);
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.UP);
|
||||
float modFileSize = pathReference.length(); //precise units
|
||||
String modFileSizeStr = String.valueOf(modFileSize);
|
||||
String modFileSizeUnits = "bytes"; //todo: don't show decimals for bytes
|
||||
if (pathReference.length() >= 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / 1024));
|
||||
modFileSizeUnits = "Kilobytes";
|
||||
}
|
||||
if (pathReference.length() >= 1024 * 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024)));
|
||||
modFileSizeUnits = "Megabytes";
|
||||
}
|
||||
if (pathReference.length() >= 1024 * 1024 * 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024 * 1024)));
|
||||
modFileSizeUnits = "Gigabytes";
|
||||
}
|
||||
if (Main.Mods.get(modList.getSelectedIndex()).author == null) {
|
||||
authorDisplay = "an Unknown Author";
|
||||
} else {
|
||||
authorDisplay = Main.Mods.get(modList.getSelectedIndex()).author;
|
||||
}
|
||||
descriptionField.setText(
|
||||
"\"" + Main.Mods.get(modList.getSelectedIndex()).friendlyName + "\"\n" +
|
||||
"by " + authorDisplay + "\n\n" +
|
||||
"Version " + Main.Mods.get(modList.getSelectedIndex()).version + "\n" +
|
||||
modFileSizeStr + " " + modFileSizeUnits + " in size" +
|
||||
"\n\n" + Main.Mods.get(modList.getSelectedIndex()).description
|
||||
);});
|
||||
|
||||
// display window
|
||||
try {
|
||||
@@ -191,35 +188,72 @@ public class MissPiggy implements ActionListener {
|
||||
Do nothing if the index number is not valid.
|
||||
there probably is not a practical reason to do this, but I want to eliminate any undefined behaviors while we're here.
|
||||
we'll also eliminate any syntax errors caused by the lack of a = sign
|
||||
|
||||
06/29/24 - also skip files that were manually removed but remain in the list
|
||||
*/
|
||||
if (s.split("=")[0].matches("[0-9]+=*")) {
|
||||
|
||||
File mod = new File(System.getProperty("user.home") + "/.firestar/mods/" + s.substring(s.indexOf("=") + 1).trim());
|
||||
|
||||
if (s.split("=")[0].matches("[0-9]+=*") &&
|
||||
mod.exists()) {
|
||||
//append mod to list from substring
|
||||
Main.Mod m = new Main().new Mod();
|
||||
m.path = s.substring(s.indexOf("=") + 1);
|
||||
m.path = s.substring(s.indexOf("=") + 1).trim();
|
||||
System.out.println("found file " + m.path);
|
||||
|
||||
//get json metadata from zip comment
|
||||
JSONObject metadata;
|
||||
try {
|
||||
metadata = new JSONObject(new ZipFile(System.getProperty("user.home") + "/.firestar/mods/" + m.path).getComment());
|
||||
} catch (ZipException e) {
|
||||
throw new RuntimeException(e); //todo: fault tolerance
|
||||
}
|
||||
if (metadata.has("friendlyName")) {m.friendlyName = metadata.get("friendlyName").toString();} else {m.friendlyName = m.path;}
|
||||
if (metadata.has("description")) {m.description = metadata.get("description").toString();}
|
||||
if (metadata.has("version")) {m.version = Integer.parseInt(metadata.get("version").toString());}
|
||||
if (metadata.has("author")) {m.author = metadata.get("author").toString();}
|
||||
if (metadata.has("loaderversion")) {m.loaderversion = Integer.parseInt(metadata.get("loaderversion").toString());}
|
||||
if (metadata.has("game")) {m.game = metadata.get("game").toString();}
|
||||
if (metadata.has("friendlyName")) {m.friendlyName = metadata.get("friendlyName").toString();} else {m.friendlyName = m.path;}
|
||||
if (metadata.has("description")) {m.description = metadata.get("description").toString();}
|
||||
if (metadata.has("version")) {m.version = Integer.parseInt(metadata.get("version").toString());}
|
||||
if (metadata.has("author")) {m.author = metadata.get("author").toString();}
|
||||
if (metadata.has("loaderversion")) {m.loaderversion = Integer.parseInt(metadata.get("loaderversion").toString());}
|
||||
if (metadata.has("game")) {m.game = metadata.get("game").toString();}
|
||||
|
||||
//send to list
|
||||
Main.Mods.add(m);
|
||||
//send to list
|
||||
Main.Mods.add(m);
|
||||
} catch (Exception e) {
|
||||
System.out.println("WARNING: mod entry for " + s + " was found but does not contain valid JSON metadata. skipping");
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
if (!s.isEmpty()) {System.out.println("WARNING: mod entry for " + s + " doesn't actually exist. skipping");}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
blackList = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/mods/blacklist")));
|
||||
} catch (IOException e) {
|
||||
File blackListFileHandle = new File(System.getProperty("user.home") + "/.firestar/mods/blacklist");
|
||||
new File(System.getProperty("user.home") + "/.firestar/mods/").mkdirs();
|
||||
if(!blackListFileHandle.isFile()){
|
||||
try {
|
||||
blackListFileHandle.createNewFile();
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
blackList = "";
|
||||
}
|
||||
|
||||
// initialize data structures from each list entry
|
||||
String[] bListArray = blackList.split("\n");
|
||||
//Arrays.sort(bListArray);
|
||||
System.out.println("Initializing blacklist from file with length of " + bListArray.length + " units"); //debug
|
||||
for (String s : bListArray) {
|
||||
for (Main.Mod m : Main.Mods) {
|
||||
if (s.trim().equals(m.path)) {
|
||||
m.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeModListInGUI() { // i really wanted this to be "lights, camera, action" but the code organizing kept getting stupider and stupider so i gave up
|
||||
public void InitializeModListInGUI() {
|
||||
// cleanup
|
||||
if (listenersAlreadySet) {modList.removeListSelectionListener(modList.getListSelectionListeners()[0]);} // was written to troubleshoot a bug but this wasn't actually the cause
|
||||
descriptionField.setText("Select a mod from the list on the right to view more details, or to make changes to your installation.");
|
||||
modList.clearSelection();
|
||||
modList.removeAll();
|
||||
@@ -231,7 +265,8 @@ public class MissPiggy implements ActionListener {
|
||||
/*JLabel[]*/String[] contents = new String[Main.Mods.size()];
|
||||
System.out.println("Initializing modList to GUI with length of " + Main.Mods.size() + " units"); //debug
|
||||
while (i < Main.Mods.size()) {
|
||||
contents[i] = Main.Mods.get(i).friendlyName;
|
||||
if (Main.Mods.get(i).enabled) {contents[i] = Main.Mods.get(i).friendlyName;}
|
||||
else {contents[i] = Main.Mods.get(i).friendlyName + " (Disabled)";}
|
||||
|
||||
//debug
|
||||
String authorDisplay;
|
||||
@@ -241,6 +276,7 @@ public class MissPiggy implements ActionListener {
|
||||
i++;
|
||||
}
|
||||
modList.setListData(contents);
|
||||
createSelectionEventListener();
|
||||
}
|
||||
|
||||
private ListSelectionListener whenItemSelected() {
|
||||
@@ -251,21 +287,63 @@ public class MissPiggy implements ActionListener {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (actionEvent.getSource() == fileMenu.getItem(5)) {System.exit(0);} else
|
||||
if (actionEvent.getSource() == fileMenu.getItem(0)) {deployModGUI();} else
|
||||
if (actionEvent.getSource() == deployButton) {deployModGUI();} else
|
||||
if (actionEvent.getSource() == importButton) {importModGUI();} else
|
||||
if (actionEvent.getSource() == fileMenu.getItem(1)) {importModGUI();} else
|
||||
if (actionEvent.getSource() == fileMenu.getItem(2)) {removeAllGUI();} else
|
||||
if (actionEvent.getSource() == optionsButton) {optionsGUI();} else
|
||||
if (actionEvent.getSource() == fileMenu.getItem(4)) {optionsGUI();} else
|
||||
if (actionEvent.getSource() == helpMenu.getItem(0)) {new Rowlf().displayAboutScreen();}
|
||||
|
||||
if (actionEvent.getSource() == moveUpButton) {moveUp(modList.getSelectedIndex());} else
|
||||
if (actionEvent.getSource() == moveDownButton) {moveDown(modList.getSelectedIndex());} else
|
||||
|
||||
if (actionEvent.getSource() == toggleButton) {toggleSelected(modList.getSelectedIndex());} else
|
||||
if (actionEvent.getSource() == deleteButton1) {deleteSelected();} else
|
||||
|
||||
if (actionEvent.getSource() == toolsMenu.getItem(0)) {throwUnimplemented();} else
|
||||
if (actionEvent.getSource() == toolsMenu.getItem(1)) {throwUnimplemented();} else
|
||||
if (actionEvent.getSource() == toolsMenu.getItem(2)) {throwUnimplemented();} else
|
||||
|
||||
if (actionEvent.getSource() == helpMenu.getItem(0)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://git.worlio.com/bonkmaykr/firestar"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
JOptionPane.showMessageDialog(frame, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else
|
||||
if (actionEvent.getSource() == helpMenu.getItem(1)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.gnu.org/licenses/gpl-3.0.en.html"));
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
JOptionPane.showMessageDialog(frame, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else
|
||||
if (actionEvent.getSource() == helpMenu.getItem(3)) {new Rowlf().displayAboutScreen();}
|
||||
}
|
||||
|
||||
// Will likely split the below functions into separate classes to work with intellij GUI designer.
|
||||
|
||||
public void deployModGUI() {
|
||||
// prevent interruptions
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
frame.setEnabled(false);
|
||||
int i = 0;
|
||||
for (Main.Mod m : Main.Mods) {
|
||||
if (m.enabled) {i++;}
|
||||
}
|
||||
|
||||
// start
|
||||
new Gonzo().DeployMods(this);
|
||||
if (i > 0) {
|
||||
int result = JOptionPane.showConfirmDialog(frame, "A new PSARC will be generated. This can take several minutes.\nDuring this time, your computer may be very busy or slow.\n\nAre you sure you want to continue?", "Deploy Mods", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
// prevent interruptions
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
frame.setEnabled(false);
|
||||
|
||||
// start
|
||||
new Gonzo().DeployMods(this);
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(frame, "Please add at least one mod file to continue.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void wrapUpDeployment() {
|
||||
@@ -275,26 +353,227 @@ public class MissPiggy implements ActionListener {
|
||||
}
|
||||
|
||||
public void importModGUI() {
|
||||
// todo call system shell to request file picker
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
|
||||
//fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("All", "zip", "agr", "agrc", "agrf", "fstar"));
|
||||
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("ZIP Archive", "zip"));
|
||||
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Firestar Mod Package", "agr", "agrc", "agrf", "fstar")); //what about fstar?
|
||||
|
||||
int result = fileChooser.showOpenDialog(frame);
|
||||
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = fileChooser.getSelectedFile();
|
||||
System.out.println("Importing selected mod file \"" + selectedFile.getName() + "\"");
|
||||
|
||||
ZipFile zipImporterHandler = new ZipFile(selectedFile.getPath());
|
||||
if (zipImporterHandler.isValidZipFile()) {
|
||||
try {
|
||||
Path importDestination = Paths.get(System.getProperty("user.home") + "/.firestar/mods/"
|
||||
+ selectedFile.getName() + "_" + Main.Mods.size() + ".zip");
|
||||
Files.copy(Paths.get(selectedFile.getPath()), importDestination, StandardCopyOption.REPLACE_EXISTING);
|
||||
String importDestinationName = importDestination.toFile().getName();
|
||||
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(System.getProperty("user.home") + "/.firestar/mods/index", true));
|
||||
bw.write(Main.Mods.size() + "=" + importDestinationName);
|
||||
bw.newLine();
|
||||
bw.close();
|
||||
|
||||
InitializeModListStructure();
|
||||
InitializeModListInGUI();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else {
|
||||
System.out.println("ERROR: File is not a valid ZIP archive. Aborting.");
|
||||
JOptionPane.showMessageDialog(frame, "Whoops, that's not a valid ZIP archive.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAllGUI() {
|
||||
// todo warning dialog that nukes list when Yes is clicked
|
||||
int result = JOptionPane.showConfirmDialog(frame, "Do you really want to delete all mods?", "Remove All", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
Main.deleteDir(new File(System.getProperty("user.home") + "/.firestar/mods/"));
|
||||
Main.Mods.clear();
|
||||
|
||||
InitializeModListStructure();
|
||||
InitializeModListInGUI();
|
||||
}
|
||||
}
|
||||
|
||||
public void optionsGUI() {
|
||||
// todo settings page w/ reset switch
|
||||
throwUnimplemented();
|
||||
}
|
||||
|
||||
public void deleteSelected() {
|
||||
if (modList.getSelectedIndex() >= 0) {
|
||||
File file = new File(System.getProperty("user.home") + "/.firestar/mods/" + Main.Mods.get(modList.getSelectedIndex()).path);
|
||||
file.delete();
|
||||
System.out.println("Deleted " + Main.Mods.get(modList.getSelectedIndex()).friendlyName); //debug
|
||||
Main.Mods.remove(modList.getSelectedIndex());
|
||||
regenerateModIndex(true);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(frame, "Please select a mod to delete first.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void generatorGUI() {
|
||||
// todo mod packer
|
||||
throwUnimplemented();
|
||||
}
|
||||
|
||||
public void metaEditorGUI() {
|
||||
// todo tag editor
|
||||
throwUnimplemented();
|
||||
}
|
||||
|
||||
public void aboutGUI() {
|
||||
// todo about page
|
||||
private void moveUp(int index) {
|
||||
if (index > 0) {
|
||||
Collections.swap(Main.Mods, index, index - 1);
|
||||
System.out.println("Items moved, redeploying list");
|
||||
InitializeModListInGUI();
|
||||
regenerateModIndex(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveDown(int index) {
|
||||
if (index < (Main.Mods.size() - 1)) {
|
||||
Collections.swap(Main.Mods, index, index + 1);
|
||||
System.out.println("Items moved, redeploying list");
|
||||
InitializeModListInGUI();
|
||||
regenerateModIndex(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleSelected(int index) {
|
||||
if (index >= 0) {
|
||||
Main.Mods.get(index).enabled = !Main.Mods.get(index).enabled;
|
||||
regenerateModBlacklist(true);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(frame, "Please select a mod to toggle first.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void throwUnimplemented() {
|
||||
JOptionPane.showMessageDialog(frame, "This feature is unimplemented and will be coming soon.\nSee README at https://git.worlio.com/bonkmaykr/firestar", "Unimplemented", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public void createSelectionEventListener() { // moved incase needs to be removed and re-added
|
||||
listenersAlreadySet = true; // was written to troubleshoot a bug but this wasn't actually the cause
|
||||
modList.addListSelectionListener(e -> {
|
||||
if (modList.getSelectedIndex() >= 0 && modList.getModel().getSize() >= 1) { // avoid race OOB when reinitializing mod list
|
||||
String authorDisplay;
|
||||
|
||||
try { //debug
|
||||
|
||||
File pathReference = new File(System.getProperty("user.home") + "/.firestar/mods/" + Main.Mods.get(modList.getSelectedIndex()).path);
|
||||
DecimalFormat df = new DecimalFormat("##.##");
|
||||
df.setRoundingMode(RoundingMode.UP);
|
||||
float modFileSize = pathReference.length(); //precise units
|
||||
String modFileSizeStr = String.valueOf(modFileSize);
|
||||
String modFileSizeUnits = "bytes"; //todo: don't show decimals for bytes
|
||||
if (pathReference.length() >= 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / 1024));
|
||||
modFileSizeUnits = "Kilobytes";
|
||||
}
|
||||
if (pathReference.length() >= 1024 * 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024)));
|
||||
modFileSizeUnits = "Megabytes";
|
||||
}
|
||||
if (pathReference.length() >= 1024 * 1024 * 1024) {
|
||||
modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024 * 1024)));
|
||||
modFileSizeUnits = "Gigabytes";
|
||||
}
|
||||
if (Main.Mods.get(modList.getSelectedIndex()).author == null) {
|
||||
authorDisplay = "an Unknown Author";
|
||||
} else {
|
||||
authorDisplay = Main.Mods.get(modList.getSelectedIndex()).author;
|
||||
}
|
||||
descriptionField.setText(
|
||||
"\"" + Main.Mods.get(modList.getSelectedIndex()).friendlyName + "\"\n" +
|
||||
"by " + authorDisplay + "\n\n" +
|
||||
"Version " + Main.Mods.get(modList.getSelectedIndex()).version + "\n" +
|
||||
modFileSizeStr + " " + modFileSizeUnits + " in size" +
|
||||
"\n\n" + Main.Mods.get(modList.getSelectedIndex()).description
|
||||
);}
|
||||
|
||||
catch (IndexOutOfBoundsException ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
System.out.println("mods " + Main.Mods.size());
|
||||
System.out.println("mod display " + modList.getModel().getSize());
|
||||
System.out.println("selection index " + modList.getSelectedIndex());
|
||||
|
||||
int result = JOptionPane.showConfirmDialog(frame, "Firestar encountered an internal error.\n" + ex.getMessage(), "Fatal Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
|
||||
if (result == JOptionPane.OK_OPTION) {System.exit(1);} //user safety
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void regenerateModIndex(boolean reload) {
|
||||
try {
|
||||
System.out.println("Regenerating index..."); //debug
|
||||
|
||||
new File(System.getProperty("user.home") + "/.firestar/mods/index").delete();
|
||||
File priorityListFileHandle = new File(System.getProperty("user.home") + "/.firestar/mods/index");
|
||||
priorityListFileHandle.createNewFile();
|
||||
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(System.getProperty("user.home") + "/.firestar/mods/index", true));
|
||||
int i = 0;
|
||||
for (Main.Mod m : Main.Mods) {
|
||||
bw.write(i + "=" + m.path);
|
||||
bw.newLine();
|
||||
i++;
|
||||
}
|
||||
bw.close();
|
||||
System.out.println("Mod index file regenerated.");
|
||||
|
||||
if(reload) {
|
||||
Main.Mods.clear(); //cleanup
|
||||
priorityList = "";
|
||||
InitializeModListStructure();
|
||||
InitializeModListInGUI();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public void regenerateModBlacklist(boolean reload) {
|
||||
try {
|
||||
System.out.println("Regenerating blacklist..."); //debug
|
||||
|
||||
new File(System.getProperty("user.home") + "/.firestar/mods/blacklist").delete();
|
||||
File blackListFileHandle = new File(System.getProperty("user.home") + "/.firestar/mods/blacklist");
|
||||
blackListFileHandle.createNewFile();
|
||||
|
||||
BufferedWriter bw2 = new BufferedWriter(new FileWriter(System.getProperty("user.home") + "/.firestar/mods/blacklist", true));
|
||||
int i2 = 0;
|
||||
for (Main.Mod m : Main.Mods) {
|
||||
if (!m.enabled) {
|
||||
bw2.write(m.path);
|
||||
bw2.newLine();
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
bw2.close();
|
||||
System.out.println("Mod blacklist file regenerated.");
|
||||
|
||||
if(reload) {
|
||||
Main.Mods.clear(); //cleanup
|
||||
blackList = "";
|
||||
InitializeModListStructure();
|
||||
InitializeModListInGUI();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,13 @@ public class Rowlf {
|
||||
picLabel.setIcon(new ImageIcon(logo));picLabel.setText("");
|
||||
|
||||
informationText.getDocument().putProperty("filterNewlines", Boolean.FALSE);
|
||||
informationText.setText("Created by bonkmaykr\n" +
|
||||
"a.k.a. \"Downforce Agent\"\n" +
|
||||
informationText.setHorizontalAlignment(JTextField.CENTER);
|
||||
informationText.setText("Created by bonkmaykr, a.k.a. \"Downforce Agent\"\n" +
|
||||
"\n" +
|
||||
"Special thanks to:\n" +
|
||||
"ThatOneBonk, for almost beating me to it\n" +
|
||||
"Wirlaburla, for web hosting and code help\n" +
|
||||
"ThatOneBonk, for Thallium and for modding help\n" +
|
||||
"Wirlaburla, for web hosting and being awesome\n" +
|
||||
"Psygnosis, for making our favorite game ever\n" +
|
||||
"and to all the PSVita hackers who made this possible");
|
||||
informationText.setHighlighter(null);
|
||||
informationText.getCaret().setVisible(false);
|
||||
|
||||
Reference in New Issue
Block a user