64 Commits

Author SHA1 Message Date
3f286b5c91 update version string 2024-06-30 07:16:33 -05:00
2735c311ad more reliable Remove All 2024-06-30 07:15:48 -05:00
a9f0fc3f4c better handling of files post-deploy 2024-06-30 07:12:27 -05:00
f8146fd493 move .trim() for less redundancy 2024-06-30 06:58:15 -05:00
d57f183785 windows compatibility fixes v3 2024-06-30 06:55:29 -05:00
9a267e4f8d backslashes are fine 2024-06-30 06:49:49 -05:00
f6b8eeb29e fix ghost files on windows 2024-06-30 06:49:00 -05:00
679b4bc68e exclude build files 2024-06-30 03:07:08 -05:00
b7d6ddd701 fix initial setup soft lock 2024-06-29 17:10:26 -05:00
29dec51c2e readme 2024-06-29 14:24:20 -05:00
d79b360553 implement toggles 2024-06-29 14:23:21 -05:00
bf0421552c un-shit (menu options) 2024-06-29 13:41:56 -05:00
c7f2a84c3a shit 2024-06-29 13:34:30 -05:00
addd23b760 confirm dialogs, fix index wipe bug 2024-06-29 13:30:01 -05:00
8cc7fca35c fault tolerance for delete 2024-06-29 13:20:23 -05:00
6078cb3bec i'm retarded too apparently. we all are. it's so over 2024-06-29 13:02:01 -05:00
a7d261597e Okay so jpackage is insanely retarded and intellij is too so we're just not going to touch that with a 100 ft pole 2024-06-29 12:54:23 -05:00
5d683bb893 going to push out a release 2024-06-29 12:14:26 -05:00
fcb71d4600 fault tolerance 2024-06-29 12:10:01 -05:00
8ebec68caf Doy! 2024-06-29 12:04:21 -05:00
002d995c05 okay i have no fucking idea what is wrong 2024-06-29 11:56:35 -05:00
9780c3cc4f refactoring. regen routine to be reused 2024-06-29 09:46:02 -05:00
8107aaa5d5 shit 2024-06-29 05:56:46 -05:00
6d772f0949 delete selection implemented. fixed OOB bug 2024-06-29 05:54:04 -05:00
d8902af148 going to throw this out because nuking index is easier 2024-06-29 05:29:38 -05:00
2e1fe95670 implement Remove All 2024-06-29 04:47:55 -05:00
45fbe80f9f remove mention of fast mode 2024-06-29 04:47:47 -05:00
886ef3089d stuff 2024-06-29 01:09:38 -05:00
28d710a815 update version string 2024-06-29 01:09:38 -05:00
a1f41584a4 Update README.md 2024-06-29 01:58:10 -04:00
e2229afe70 Update README.md 2024-06-29 01:57:43 -04:00
b9743ee456 less redundancy 2024-06-29 00:55:16 -05:00
fcda7b8cf4 added importing 2024-06-29 00:54:00 -05:00
433bc685dc DUH - don't err when asset folder already exists, it should! 2024-06-28 16:11:38 -05:00
5ab96366a6 FAQ was outdated 2024-06-28 16:52:05 -04:00
e4497afaa3 Update README.md 2024-06-28 16:50:52 -04:00
5a004b6744 to avoid more dumdums 2024-05-08 14:15:00 -05:00
7f5b0b85ae i forgot my own linux username :/ 2024-05-08 14:10:00 -05:00
f582cdb052 Update readme 2024-05-08 07:26:50 -05:00
72b075bf7b cleanup residual file ahead of time 2024-05-08 07:21:53 -05:00
020ec4b5d9 Windows compatibility 2024-05-08 07:17:26 -05:00
81069fbb5d build changes + windows compatibility 2024-05-08 04:51:25 -05:00
7a0f224505 Why are the bools inverted? Both of them? kill me 2024-05-07 13:22:24 -05:00
b31275012a Update readme 2024-05-07 13:11:11 -05:00
21724bc04c Fix game crash caused by psarc not including root "data" folder and only it's contents. 2024-05-07 13:08:12 -05:00
cd1d9eab3c Deploy function completed - mostly 2024-05-07 12:21:22 -05:00
16337680a8 TIL there's a muppet named rizz rat... gen z has ruined me 2024-05-07 08:44:26 -05:00
0175293a0a refactor; switch library to maven remote 2024-05-07 08:21:46 -05:00
3573e23cf5 hopping off for a bit 2024-05-07 05:41:53 -05:00
89b32977e5 Functional mod list 2024-05-07 05:26:54 -05:00
21653702c3 the c, the h, the e, the m 2024-05-07 04:26:40 -05:00
4086dfd319 implement mod list load 2024-05-07 00:47:43 -05:00
0b6e6fd276 how did i forget mod descriptions...? 2024-05-06 23:36:41 -05:00
cb24d94355 i should probably finish what im doing before i push changes to the readme 2024-04-21 13:41:00 -05:00
3b0c737d39 next step is to implement our first i/o 2024-04-21 13:37:17 -05:00
82fc9773a6 next step is to implement our first i/o 2024-04-19 18:06:52 -05:00
cc2c143ff2 i'm living a lie 2024-04-19 17:00:20 -05:00
10b4a91515 about screen 2024-04-13 10:04:35 -05:00
fb7620bcff menu bar 2024-04-12 10:31:38 -05:00
37900e8f2e menu bar 2024-04-12 10:21:51 -05:00
767fd8fd0f begin main GUI groundwork 2024-04-11 23:26:26 -05:00
a74ce96920 begin basic object structure and configuration i/o 2024-04-10 03:49:21 -05:00
0aae30f60e OOBE completed 2024-04-10 02:35:27 -05:00
184d101a13 h 2024-04-10 02:15:36 -05:00
22 changed files with 1686 additions and 62 deletions

1
.gitignore vendored
View File

@@ -27,3 +27,4 @@ bin/
### Mac OS ###
.DS_Store
/firestar.zip

19
.idea/artifacts/firestar.xml generated Normal file
View 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>

13
.idea/artifacts/firestar_jar.xml generated Normal file
View File

@@ -0,0 +1,13 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="firestar:jar">
<output-path>$PROJECT_DIR$/out/artifacts/firestar_jar</output-path>
<root id="archive" name="firestar.jar">
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/bin/META-INF/MANIFEST.MF" />
</element>
<element id="module-output" name="firestar" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/lingala/zip4j/zip4j/2.11.5/zip4j-2.11.5.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/json/json/20240303/json-20240303.jar" path-in-jar="/" />
</root>
</artifact>
</component>

View File

@@ -0,0 +1,8 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="StringOperationCanBeSimplified" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreStringConstructor" value="true" />
</inspection_tool>
</profile>
</component>

10
.idea/libraries/json.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="json" type="repository">
<properties maven-id="org.json:json:20240303" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/json/json/20240303/json-20240303.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

10
.idea/libraries/net_lingala_zip4j.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<component name="libraryTable">
<library name="net.lingala.zip4j" type="repository">
<properties maven-id="net.lingala.zip4j:zip4j:2.11.5" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/lingala/zip4j/zip4j/2.11.5/zip4j-2.11.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="org.json-1.6-20240205">
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/org.json-1.6-20240205.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

12
.idea/material_theme_project_new.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-52a30455:18ecc46f11f:-7ffe" />
</MTProjectMetadataState>
</option>
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@@ -1,16 +1,44 @@
![](https://files.worlio.com/users/bonkmaykr/http/git/embed/firestar.png)
# about 10% complete (basic frontend in progress, nonfunctional)
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.
TODO: modlist window screenshot
# 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
![](https://files.worlio.com/users/bonkmaykr/http/git/embed/firestar_window.png)
# System Requirements
- You will need a computer running Microsoft Windows, or any POSIX-compliant desktop operating system such as Mac OS X, Linux, BSD, or MINIX (Firestar does not run directly on the PSVita). ***Wayland support has not been tested.***
- You will also need the Java Runtime Environment installed, at least version 17 or newer. Non-Windows systems will require WINE to be installed for some functionality.
- Please run Firestar on an EXT or NTFS partition as some of the larger file operations it performs may cause glitches in certain filesystems used on memory cards. Do NOT install Firestar directly to your PSVita's storage.
# Mod File Structure
Mod files are contained inside of ZIP archives with the metadata being stored inside of the archive's embedded comments. The "data" folder inside contains the actual game assets for repacking.
Next to it at root level a pack.png will be supplied for displaying your mod's icon in later versions of Firestar. This feature is currently unimplemented.
Later versions of Firestar will have a built-in tool to handle these for you, since some archive programs don't make it easy enough to do by hand.
Typical mod metadata will look something like this:
```json
{
"version": 1,
"friendlyName": "Custom soundtrack",
"loaderversion": 0,
"author": "bonkmaykr",
"description": "I need sugar"
}
```
# 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.
## (Linux Users) Do I need WINE?
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.
## (Non-Windows) Do I need WINE? And why?
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.
@@ -20,3 +48,6 @@ Cross-platform support with no hassle, a built-in UI framework, and I don't need
## 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.
## 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.

View File

@@ -7,6 +7,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="org.json-1.6-20240205" level="project" />
<orderEntry type="library" name="net.lingala.zip4j" level="project" />
<orderEntry type="library" name="json" level="project" />
</component>
</module>

BIN
resources/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
resources/logo_about.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
resources/titleIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

28
src/Gonzo.form Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Gonzo">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="6830c" binding="scrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="line" title="Please wait a few minutes. Progress is shown above." title-justification="2" title-position="5"/>
<children>
<component id="491c1" class="javax.swing.JTextArea" binding="consoleDisplay">
<constraints/>
<properties>
<text value=""/>
</properties>
</component>
</children>
</scrollpane>
</children>
</grid>
</form>

348
src/Gonzo.java Normal file
View File

@@ -0,0 +1,348 @@
/*
* Firestar Mod Manager
* Copyright (C) 2024 bonkmaykr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.util.FileUtils;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class Gonzo {
JFrame frame = new JFrame();
private JPanel frameContainer;
private JTextArea consoleDisplay;
private JScrollPane scrollPane;
public boolean data0;
public boolean data1;
public boolean data2;
public boolean dlc1;
public boolean dlc2;
private MissPiggy invoker;
public String oArcTarget = "dlc2.psarc"; // which psarc to rebuild the assets in
public void DeployMods(MissPiggy inv) {
invoker = inv;
System.out.println("\n\nStarting mod deployment\n\n");
frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA
try {
BufferedImage windowIcon = ImageIO.read(new File(System.getProperty("user.dir") + "/resources/titleIcon.png"));
frame.setIconImage(windowIcon);
} catch (IOException e) {
System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon.");
}
frame.setSize(800, 400);
frame.setMinimumSize(new Dimension(600,400));
frame.setTitle("Mod Installation");
frame.setResizable(false);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.setLayout(new GridLayout());
frame.setLocationRelativeTo(null);
frame.setAlwaysOnTop(true);
frame.setVisible(true);
File psarcHandle = new File(Main.inpath + "data.psarc");
data0 = psarcHandle.isFile();
psarcHandle = new File(Main.inpath + "data1.psarc");
data1 = psarcHandle.isFile();
psarcHandle = new File(Main.inpath + "data2.psarc");
data2 = psarcHandle.isFile();
psarcHandle = new File(Main.inpath + "dlc1.psarc");
dlc1 = psarcHandle.isFile();
psarcHandle = new File(Main.inpath + "dlc2.psarc");
dlc2 = psarcHandle.isFile();
System.out.println("Source files discovered: data " + data0 + ", data1 " + data1 + ", data2 " + data2 + ", dlc1 " + dlc1 + ", dlc2 " + dlc2);
final Thread managerThread = new Thread() {
@Override
public void run() {
if (/*Main.repatch*/true) { //todo implement fast mode correctly or remove
CompatibilityRoutine();
} else {
FastRoutine();
}
}
};
managerThread.start();
}
private void CompatibilityRoutine() {
// create temporary working area for asset dump
new File(System.getProperty("user.home") + "/.firestar/temp/").mkdirs();
// decide which files to dump
List<String> dumpThese = new ArrayList<String>();
if (data0) {dumpThese.add("data.psarc");oArcTarget = "data.psarc";}
if (data1) {dumpThese.add("data1.psarc");oArcTarget = "data1.psarc";}
if (data2) {dumpThese.add("data2.psarc");oArcTarget = "data2.psarc";}
if (dlc1) {dumpThese.add("dlc1.psarc");oArcTarget = "dlc1.psarc";}
if (dlc2) {dumpThese.add("dlc2.psarc");oArcTarget = "dlc2.psarc";}
// dump all assets to working area
for (String s : dumpThese) {
try {
System.out.println("Firestar is extracting " + s);
consoleDisplay.append("Firestar is extracting " + s + "\n");
//Process p = Runtime.getRuntime().exec(new String[]{"bash","-c","aplay /home/bonkyboo/kittens_loop.wav"}); // DEBUG
Process p;
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","cd " + System.getProperty("user.home") + "/.firestar/temp/" + ";wine ../psp2psarc.exe extract -y ../" + s});}
else {p = Runtime.getRuntime().exec(new String[]{new String(System.getProperty("user.home") + "\\.firestar\\psp2psarc.exe"), "extract", "-y", "..\\" + s}, null, new File(new String(System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\")));}
final Thread ioThread = new Thread() {
@Override
public void run() {
try {
final BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
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. You can safely ignore this.\n" + e.getMessage());}
}
reader.close();
} catch (final Exception e) {
e.printStackTrace(); // will probably definitely absolutely for sure hang firestar unless we do something. Too bad!
}
}
};
ioThread.start();
p.waitFor();
} 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;
}
}
// 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) {
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");
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();
}
}
}
// 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;
}
}
}
// create a list of the contents of data/ for psp2psarc.exe to read from
List<String> oFilesList = new ArrayList<String>();
List<String> oFilesList2 = new ArrayList<String>();
try {
listAllFiles(Paths.get(System.getProperty("user.home") + "/.firestar/temp/data/"), oFilesList);
for (String p : oFilesList) {
// We need to clean up the path here on Linux to avoid psp2psarc getting confused about where the hell "/" is.
// In WINE it should see it as Z: by default, but if it's somewhere else then I don't have an elegant way of knowing what drive letter it's on, so
// relative paths are kind of the only choice here. This can be extended to Windows too as it works there, though completely unnecessary.
if (!Main.windows) {oFilesList2.add(p.replace("\\", "/").split(new String(System.getProperty("user.home") + "/.firestar/temp/"))[1]);}
else {oFilesList2.add(p.split(new String(System.getProperty("user.home") + "\\.firestar\\temp\\").replace("\\", "\\\\"))[1]);} // path wont match regex unless adjusted for windows here
}
//oFilesList2.forEach(System.out::println); //debug
File oFilesListO = new File(System.getProperty("user.home") + "/.firestar/temp/list.txt");
if (oFilesListO.isFile()) {oFilesListO.delete();}
FileWriter oFilesListWr = new FileWriter(oFilesListO, true);
int i = 0;
for (String p : oFilesList2) {
oFilesListWr.append(p);
if (i != oFilesList2.size()) {
oFilesListWr.append("\n");
}
i++;
}
oFilesListWr.close();
} 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;
}
// invoke psp2psarc.exe one final time to reconstruct the assets
try {
System.out.println("Firestar is compiling the final build");
consoleDisplay.append("Firestar is compiling the final build" + "\n");
Process p;
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","cd " + System.getProperty("user.home") + "/.firestar/temp" + ";wine ../psp2psarc.exe create --skip-missing-files -j12 -a -i --input-file=list.txt -o " + oArcTarget});}
else {p = Runtime.getRuntime().exec(new String[]{new String(System.getProperty("user.home") + "\\.firestar\\psp2psarc.exe"), "create", "--skip-missing-files", "-j12", "-a", "-i", "--input-file=list.txt", "-o" + oArcTarget}, null, new File(new String(System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\")));}
final Thread ioThread = new Thread() {
@Override
public void run() {
try {
final BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
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());}
}
reader.close();
} catch (final Exception e) {
e.printStackTrace(); // will probably definitely absolutely for sure hang firestar unless we do something. Too bad!
}
}
};
ioThread.start();
p.waitFor();
} 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
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 {
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());
}
// done!
try {
TimeUnit.SECONDS.sleep(1); // avoid race condition when logging
} catch (InterruptedException e) {
//ignore
}
TitledBorder titledBorder = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK), "DONE! Close this pop-up to continue.");
titledBorder.setTitlePosition(TitledBorder.BOTTOM);
titledBorder.setTitleJustification(TitledBorder.CENTER);
scrollPane.setBorder(titledBorder);
scrollPane.repaint();
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
AllowExit();
}
private void FastRoutine() {
}
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
public void windowClosing(WindowEvent e)
{
invoker.wrapUpDeployment();
e.getWindow().dispose();
}
});
}
private static void listAllFiles(Path currentPath, List<String> allFiles)
throws IOException
{
try (DirectoryStream<Path> stream = Files.newDirectoryStream(currentPath))
{
for (Path entry : stream) {
if (Files.isDirectory(entry)) {
listAllFiles(entry, allFiles);
} else {
allFiles.add(entry.toString());
}
}
}
}
}

View File

@@ -26,10 +26,6 @@ import java.math.BigInteger;
import java.net.URL;
import java.nio.file.*;
import java.security.*;
import java.util.concurrent.TimeUnit;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
// handles setup window
public class Kermit implements ActionListener {
@@ -50,7 +46,7 @@ public class Kermit implements ActionListener {
}
}
JDialog frame = new JDialog();;
JDialog frame = new JDialog();
JButton button = new JButton("Next");
JButton button2 = new JButton("Quit");
JButton button3 = new JButton("Cancel");
@@ -62,13 +58,13 @@ public class Kermit implements ActionListener {
JRadioButton buttonNoWine = new JRadioButton("No, I use Microsoft Windows");
JRadioButton buttonHaveWine = new JRadioButton("Yes, I have a POSIX system with WINE.");
ButtonGroup radg2 = new ButtonGroup();
JTextField pathInput = new JTextField();
JButton openconfigfolderbutton = new JButton("Open Firestar Folder");
Pages page = Pages.AGREEMENT;
javax.swing.text.StyledDocument document = dialogText.getStyledDocument();
javax.swing.text.SimpleAttributeSet align= new javax.swing.text.SimpleAttributeSet();
public void setup(File fConf) { //File variable is redundant. unused
// todo Disable MissPiggy
frame.getContentPane().setBackground(Color.WHITE);
radg1.add(buttonCompat);
radg1.add(buttonFast);
@@ -83,6 +79,7 @@ public class Kermit implements ActionListener {
buttonFast.addActionListener(this);
buttonNoWine.addActionListener(this);
buttonHaveWine.addActionListener(this);
openconfigfolderbutton.addActionListener(this);
changePage(Pages.AGREEMENT);
}
@@ -98,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);
@@ -120,13 +117,22 @@ public class Kermit implements ActionListener {
dialogText.setVisible(false);frame.remove(dialogText);
break;
case EXPORT_LOCATION:
button.setVisible(false);frame.remove(button);
button3.setVisible(false);frame.remove(button3);
dialogText.setVisible(false);frame.remove(dialogText);
buttonNoWine.setVisible(false);frame.remove(buttonNoWine);
buttonHaveWine.setVisible(false);frame.remove(buttonHaveWine);
changePage(Pages.IMPORT_LOCATION);
break;
case IMPORT_LOCATION:
Main.outpath = pathInput.getText();
pathInput.setText("");
dialogText.setVisible(false);frame.remove(dialogText);
pathInput.setVisible(false);frame.remove(pathInput);
changePage(Pages.DONE);
break;
case DONE:
// todo Enable MissPiggy
new MissPiggy().Action();
page = Pages.AGREEMENT; //set it here since we're disposing of the entire thing
frame.dispose();
@@ -166,11 +172,17 @@ public class Kermit implements ActionListener {
Main.repatch = false;
button.setEnabled(true);
} else if (actionEvent.getSource() == buttonHaveWine) {
Main.wine = true;
Main.windows = true;
button.setEnabled(true);
} else if (actionEvent.getSource() == buttonNoWine) {
Main.wine = false;
Main.windows = false;
button.setEnabled(true);
}else if (actionEvent.getSource() == openconfigfolderbutton) {
try {
Desktop.getDesktop().open(new File(Main.inpath));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@@ -250,6 +262,7 @@ public class Kermit implements ActionListener {
frame.setDefaultCloseOperation(0);
frame.setResizable(false);
frame.setLayout(null);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
break;
case SDK_INSTALL:
@@ -297,7 +310,7 @@ public class Kermit implements ActionListener {
}
if(checksum.equals("4ef707b2dba6944a726d46950aaddfd2")) {changePage(Pages.WHAT_OS);} else {
System.out.println("Failed to download PSARC tool because the connection stalled.");
System.out.println("ERROR: Failed to download PSARC tool. Check connection and ensure the file is not corrupt or infected.");
dialogText.setText("Firestar tried to download important files needed for operation, but they were either corrupted or did not finish.\n" + "\n\nYou will need to manually install psp2psarc.exe into your Firestar config folder after setup is complete! Or, you can retry the download later.");
//frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@@ -327,13 +340,14 @@ public class Kermit implements ActionListener {
button3.setVisible(false);frame.remove(button3);
dialogText.setVisible(false);frame.remove(dialogText);
//see if we can safely assume the user's choice for them before we bother asking
if(System.getProperty("os.name").equals("Linux")) {Main.wine = true;changePage(Pages.EXPORT_LOCATION);} else
if(System.getProperty("os.name").contains("Windows")) {Main.wine = false;changePage(Pages.EXPORT_LOCATION);} else {
//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.");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;
// real stuff now
button.setVisible(true);
button.setEnabled(false);
button.setBounds(292, 343, 300, 30);
frame.add(button);
@@ -345,20 +359,19 @@ public class Kermit implements ActionListener {
dialogText.setHighlighter(null);
dialogText.getCaret().setVisible(false);
dialogText.setFocusable(false);
dialogText.setBounds(0, 40, 592, 150);
dialogText.setBounds(30, 40, 542, 150);
StyleConstants.setAlignment(align, StyleConstants.ALIGN_CENTER);
document.setParagraphAttributes(0, document.getLength(), align, false);
dialogText.setText("Firestar was unable to detect your native operating system. Do you use WINE?");
dialogText.setText("Now enter the location of your game's asset folder.\n" +
"This can be your install directory on your emulator, your repatch folder on your Vita memory card, or a temporary directory you'd like to copy over yourself.\n\n" +
"PLEASE DO NOT POINT THIS DIRECTLY TO WHERE THE GAME IS INSTALLED ON A REAL VITA\n" +
"(ux0:/app, ux0:/patch or ux0:/addcont)\n" +
"AS THIS WILL CORRUPT YOUR GAME AND YOU WILL NEED TO REINSTALL IT.\nDoing this on an emulator is fine.");
frame.add(dialogText);
buttonNoWine.setBounds(40, 200, 300, 25);
buttonHaveWine.setBounds(40, 230, 300, 25);
buttonNoWine.setBackground(Color.WHITE);
buttonHaveWine.setBackground(Color.WHITE);
buttonCompat.setVisible(true);
buttonHaveWine.setVisible(true);
frame.add(buttonNoWine);
frame.add(buttonHaveWine);
pathInput.setVisible(true);
pathInput.setBounds(30,200,542,30);
frame.add(pathInput);
frame.setSize(600, 400);
frame.setTitle("Initial Setup");
@@ -367,16 +380,90 @@ public class Kermit implements ActionListener {
frame.setResizable(false);
frame.setLayout(null);
frame.setVisible(true);
}
break;
case EXPORT_LOCATION:
page = Pages.EXPORT_LOCATION;
break;
case IMPORT_LOCATION:
// I think for Fast Mode this step may be unnecessary? look into alternatives perhaps
page = Pages.IMPORT_LOCATION;
pathInput.setVisible(false); //GET OUT OF MY HEAD
button.setVisible(true);
button.setBounds(292, 343, 300, 30);
frame.add(button);
button3.setVisible(true);
button3.setBounds(0, 343, 292, 30);
frame.add(button3);
dialogText.setVisible(true);
dialogText.setHighlighter(null);
dialogText.getCaret().setVisible(false);
dialogText.setFocusable(false);
dialogText.setBounds(30, 40, 542, 200);
StyleConstants.setAlignment(align, StyleConstants.ALIGN_CENTER);
document.setParagraphAttributes(0, document.getLength(), align, false);
dialogText.setText("You're almost done!\n\n" +
"Please move all of your original PSARC files for WipEout (base game, patches, and HD Fury DLC) to the config folder and press Next when you are done.\n" +
"Firestar will use these to generate new PSARCs in place of the old ones.\n\n" +
"If you play on a real console, you will need to use VitaShell (remember to \"Open Decrypted\"). Check /app, /patch, and /addcont. Getting all of them is important since WipEout always loads them in a specific order and which ones you have determines where Firestar can compress the modified files to.");
frame.add(dialogText);
//pathInput.setVisible(true);
//pathInput.setBounds(30,200,542,30);
//frame.add(pathInput);
openconfigfolderbutton.setVisible(true);
openconfigfolderbutton.setBounds(30,250,542,30);
frame.add(openconfigfolderbutton);
frame.setSize(600, 400);
frame.setTitle("Initial Setup");
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(0);
frame.setResizable(false);
frame.setLayout(null);
frame.setVisible(true);
break;
case DONE:
page = Pages.DONE;
Main.writeConf(); // save changes
//SERIOUS!!!!!!!!!!!!!! cleanup
button.setVisible(false);frame.remove(button);
button2.setVisible(false);frame.remove(button2);
button3.setVisible(false);frame.remove(button3);
button4.setVisible(false);frame.remove(button4);
openconfigfolderbutton.setVisible(false);frame.remove(openconfigfolderbutton);
pathInput.setVisible(false);frame.remove(pathInput);
buttonFast.setVisible(false);frame.remove(buttonFast);
buttonCompat.setVisible(false);frame.remove(buttonCompat);
buttonHaveWine.setVisible(false);frame.remove(buttonHaveWine);
buttonNoWine.setVisible(false);frame.remove(buttonNoWine);
//congrations, your did it (party time)
dialogText.setVisible(true);
dialogText.setHighlighter(null);
dialogText.getCaret().setVisible(false);
dialogText.setFocusable(false);
dialogText.setBounds(30, 40, 542, 200);
StyleConstants.setAlignment(align, StyleConstants.ALIGN_CENTER);
document.setParagraphAttributes(0, document.getLength(), align, false);
dialogText.setText("Firestar is ready!\n\n" +
"For technical support, email\nbonkmaykr@screwgravity.net.");
frame.add(dialogText);
button.setVisible(true);
button.setBounds(292, 343, 300, 30);
button.setText("OK");
frame.add(button);
frame.setSize(600, 400);
frame.setTitle("Initial Setup");
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(0);
frame.setResizable(false);
frame.setLayout(null);
frame.setVisible(true);
break;
default:
throw new UnsupportedOperationException("ERROR: Undefined behavior in Kermit.changePage(). Get a programmer!");

View File

@@ -18,25 +18,47 @@
import org.json.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.*;
import java.nio.file.*;
import java.util.*;
import javax.swing.JOptionPane;
public class Main {
public static String vstr = "debug";
public static String vcode = "Natasha";
public static int vint = 0;
// Build Information
public static final String vstr = "Beta 4";
public static final String vcode = "Natasha";
public static final int vint = 0;
public static String path; //game assets location
// User Settings
// TODO: replace with user preference when config i/o is done
// also please double check that outpath is actually valid
public static String outpath = System.getProperty("user.home") + "/.firestar/out/"; //game assets location
public static String inpath = System.getProperty("user.home") + "/.firestar/"; //game assets location
public static boolean repatch; //are we in compat mode?
public static boolean wine; //are we on Linux, MINIX, BSD?
public static boolean windows; //True = windows
//public static String psarc; //sdk location
public class Mod {
public String path; // file name
public int version = 1;
//public int gameversion; //TODO detect a game version and compatibility? // no
public int priority = 0; //unused
public String friendlyName;
public String description = "";
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
public static List<Mod> Mods = new ArrayList<Mod>();
public static void main(String[] args) {
// license string
System.out.printf("FIRESTAR MOD MANAGER for WipEout 2048\nversion " + vstr + " (codename " + vcode + ")\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" +
"it under the terms of the GNU General Public License as published by\n" +
"the Free Software Foundation, either version 3 of the License, or\n" +
@@ -51,14 +73,71 @@ public class Main {
"along with this program. If not, see https://www.gnu.org/licenses/.\n\n\n\n");
//begin
// todo create main window
// 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.
} else {
new MissPiggy().Action(); // Quick! Start singing Firework by Katy Perry! (or open the main window i guess...)
}
}
// todo load modlist and send to MissPiggy
public static void writeConf(){
JSONObject container = new JSONObject();
container.put("version", vint);
container.put("2048path", outpath);
container.put("HDpath", "TODO"); // proposed hd/fury support for ps3, will use very simplified Fast Mode due to less difficulty installing
container.put("safemode", repatch);
container.put("isWin32", windows);
container.put("currentPlaylist", "TODO"); // proposed feature: store separate mod lists in lists/ to load/save later?
try {
Files.write(Paths.get(System.getProperty("user.home") + "/.firestar/firestar.conf"), container.toString().getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
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();
}
}

151
src/MasterWindowLayout.form Normal file
View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MissPiggy">
<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">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="6cdb1" binding="descriptionContainer" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="8" fill="2" indent="0" use-parent-layout="false">
<minimum-size width="300" height="-1"/>
<preferred-size width="300" height="262"/>
<maximum-size width="300" height="-1"/>
</grid>
</constraints>
<properties/>
<border type="line" title="Description"/>
<children>
<component id="a9cee" class="javax.swing.JTextPane" binding="descriptionField">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
</constraints>
<properties>
<editable value="false"/>
<focusable value="false"/>
<text value="Select a mod from the list on the right to view more details, or to make changes to your installation."/>
</properties>
</component>
</children>
</grid>
<scrollpane id="ecc63" binding="modListScrollContainer">
<constraints>
<grid row="0" column="1" row-span="2" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="line" title="Mods List" title-justification="1" title-position="2">
<font/>
</border>
<children>
<component id="d80ff" class="javax.swing.JList" binding="modList">
<constraints/>
<properties>
<foreground color="-16777216"/>
<valueIsAdjusting value="false"/>
</properties>
<clientProperties>
<html.disable class="java.lang.Boolean" value="true"/>
</clientProperties>
</component>
</children>
</scrollpane>
<grid id="e1585" binding="actionsContainer" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="10" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="10" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="300" height="200"/>
<preferred-size width="300" height="200"/>
<maximum-size width="300" height="200"/>
</grid>
</constraints>
<properties/>
<border type="line" title="Actions"/>
<children>
<component id="3cd60" class="javax.swing.JButton" binding="toggleButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="30"/>
<maximum-size width="-1" height="30"/>
</grid>
</constraints>
<properties>
<text value="Toggle"/>
</properties>
</component>
<component id="ee722" class="javax.swing.JButton" binding="moveUpButton" default-binding="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="30"/>
<maximum-size width="-1" height="30"/>
</grid>
</constraints>
<properties>
<text value="Move Up"/>
</properties>
</component>
<component id="bad92" class="javax.swing.JButton" binding="deleteButton1" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="30"/>
<preferred-size width="98" height="56"/>
<maximum-size width="-1" height="30"/>
</grid>
</constraints>
<properties>
<text value="Delete"/>
</properties>
</component>
<component id="29574" class="javax.swing.JButton" binding="moveDownButton" default-binding="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="30"/>
<preferred-size width="115" height="56"/>
<maximum-size width="-1" height="30"/>
</grid>
</constraints>
<properties>
<text value="Move Down"/>
</properties>
</component>
<component id="3c3bc" class="javax.swing.JButton" binding="optionsButton" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="4" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<maximum-size width="-1" height="75"/>
</grid>
</constraints>
<properties>
<text value="Options"/>
</properties>
</component>
<component id="b34d5" class="javax.swing.JButton" binding="importButton" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="4" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<maximum-size width="-1" height="75"/>
</grid>
</constraints>
<properties>
<text value="Import"/>
</properties>
</component>
<component id="dd9e7" class="javax.swing.JButton" binding="deployButton" default-binding="true">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="4" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="79" height="28"/>
<maximum-size width="-1" height="75"/>
</grid>
</constraints>
<properties>
<text value="Deploy"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

579
src/MissPiggy.java Normal file
View File

@@ -0,0 +1,579 @@
/*
* Firestar Mod Manager
* Copyright (C) 2024 bonkmaykr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
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;
public class MissPiggy implements ActionListener {
BufferedImage windowIcon;
JFrame frame = new JFrame();
JPanel frameContainer;
JPanel actionsContainer;
JPanel descriptionContainer;
//JPanel menuBarContainerPanel = new JPanel();
public JMenuBar menuBar;
public JMenu fileMenu;
public JMenu toolsMenu;
public JMenu helpMenu;
//JMenuItem menuItem;
JScrollPane modListScrollContainer;
public JList<String> modList;
private JButton toggleButton;
private JButton moveUpButton;
private JButton deleteButton1;
private JButton moveDownButton;
private JButton optionsButton;
private JButton importButton;
private JButton deployButton;
private JTextPane descriptionField;
//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();
fileMenu = new JMenu("File");
toolsMenu = new JMenu("Tools");
helpMenu = new JMenu("Help");
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"));
toolsMenu.add(new JMenuItem("Edit Metadata")); // disabled if a mod is not selected from the list
toolsMenu.add(new JMenuItem("Generate New Mod from Folder..."));
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);
menuBar.add(toolsMenu);
menuBar.add(helpMenu);
menuBar.setVisible(true);
frame.setJMenuBar(menuBar);
frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA
InitializeModListStructure();
InitializeModListInGUI(); // present mod list
fileMenu.getItem(0).addActionListener(this);
fileMenu.getItem(1).addActionListener(this);
fileMenu.getItem(2).addActionListener(this);
fileMenu.getItem(4).addActionListener(this);
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);
// display window
try {
windowIcon = ImageIO.read(new File(System.getProperty("user.dir") + "/resources/titleIcon.png"));
frame.setIconImage(windowIcon);
} catch (IOException e) {
System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon.");
}
frame.setSize(800, 600); // 1280 800
frame.setMinimumSize(new Dimension(640,480));
frame.setTitle("Firestar Mod Manager");
frame.setResizable(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setLayout(new GridLayout());
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public void InitializeModListStructure() {
// cleanup
Main.Mods.clear();
// get current list of mods from file
// todo: rewrite when modpacks/playlists are added
try {
priorityList = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/mods/index")));
} catch (IOException e) {
File priorityListFileHandle = new File(System.getProperty("user.home") + "/.firestar/mods/index");
new File(System.getProperty("user.home") + "/.firestar/mods/").mkdirs();
if(!priorityListFileHandle.isFile()){
try {
priorityListFileHandle.createNewFile();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
priorityList = "";
}
// initialize data structures from each list entry
String[] pListArray = priorityList.split("\n");
Arrays.sort(pListArray);
System.out.println("Initializing modList from file with length of " + pListArray.length + " units"); //debug
for (String s : pListArray) {
/*
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
*/
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).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());
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);
} 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() {
// 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();
modList.setVisibleRowCount(Main.Mods.size());
modList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// add text entry for each
int i = 0;
/*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()) {
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;
if (Main.Mods.get(i).author == null) {authorDisplay = "Anonymous";} else {authorDisplay = "\"" + Main.Mods.get(i).author + "\"";}
System.out.println("Added " + Main.Mods.get(i).friendlyName + " by " + authorDisplay);
i++;
}
modList.setListData(contents);
createSelectionEventListener();
}
private ListSelectionListener whenItemSelected() {
return null;
}
@Override
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() == 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() {
int i = 0;
for (Main.Mod m : Main.Mods) {
if (m.enabled) {i++;}
}
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() {
// restore functionality to main window
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setEnabled(true);
}
public void importModGUI() {
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();
}
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);
}
}
}

57
src/Rowlf.form Normal file
View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Rowlf">
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<xy x="20" y="20" width="1464" height="573"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="a5cc7" class="javax.swing.JLabel" binding="picLabel">
<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">
<maximum-size width="-1" height="100"/>
</grid>
</constraints>
<properties>
<text value="Aww fiddlesticks, what now?"/>
</properties>
</component>
<component id="acd2f" class="javax.swing.JTextField" binding="informationText">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="4" hsize-policy="6" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="350" height="-1"/>
<maximum-size width="380" height="200"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<text value="Do you think we should appeal to the alien authorities?"/>
</properties>
</component>
<component id="f7110" class="javax.swing.JLabel" binding="versionLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
<maximum-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<text value="Version Unknown"/>
</properties>
</component>
<component id="4a55c" class="javax.swing.JLabel" binding="environmentLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="-1" height="20"/>
<maximum-size width="-1" height="20"/>
</grid>
</constraints>
<properties>
<text value="Platform Unknown"/>
</properties>
</component>
</children>
</grid>
</form>

75
src/Rowlf.java Normal file
View File

@@ -0,0 +1,75 @@
/*
* Firestar Mod Manager
* Copyright (C) 2024 bonkmaykr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
import javax.imageio.*;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
import java.io.File;
import java.io.IOException;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
public class Rowlf {
JFrame frame = new JFrame();
JPanel frameContainer;
BufferedImage logo;
JLabel picLabel;
private JTextField informationText;
private JLabel versionLabel;
private JLabel environmentLabel;
public void displayAboutScreen() {
try {
logo = ImageIO.read(new File(System.getProperty("user.dir") + "/resources/logo_about.png"));
} catch (IOException e) {
System.out.println("ERROR: Failed to open About screen because we couldn't find an image needed to display the page.");
throw new RuntimeException(e);
}
//frame.add(picLabel);
frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA
picLabel.setIcon(new ImageIcon(logo));picLabel.setText("");
informationText.getDocument().putProperty("filterNewlines", Boolean.FALSE);
informationText.setHorizontalAlignment(JTextField.CENTER);
informationText.setText("Created by bonkmaykr, a.k.a. \"Downforce Agent\"\n" +
"\n" +
"Special thanks to:\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);
informationText.setFocusable(false);
versionLabel.setText("Version " + Main.vstr + " (" + Main.vcode + ")");
environmentLabel.setText("Running on Java " + System.getProperty("java.version") + " for " + System.getProperty("os.name"));
// display window
frame.setSize(400, 320);
frame.setTitle("About Firestar");
frame.setResizable(false);
frame.setAlwaysOnTop(true);
frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
frame.setLayout(new GridLayout());
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}