9 Commits

3 changed files with 136 additions and 44 deletions

View File

@@ -4,13 +4,13 @@ Firestar is a mod manager for WipEout 2048 which automatically handles sorting m
# about 85% complete # about 85% complete
**What works:** **What works:**
- Importing mods - Importing & deleting mods
- Repacking (installing) mods - Repacking (installing) mods
- config loading - config loading
- Cross-platform support - Cross-platform support
**What doesn't work yet:** **What doesn't work yet:**
- managing mods within the program (delete, change priority, toggle) - change load order, toggle
- settings screen - settings screen
- misc. tools (pack creator, soundtrack mod generator...) - misc. tools (pack creator, soundtrack mod generator...)

View File

@@ -95,7 +95,7 @@ public class Kermit implements ActionListener {
button.setVisible(false);frame.remove(button); button.setVisible(false);frame.remove(button);
button2.setVisible(false);frame.remove(button2); button2.setVisible(false);frame.remove(button2);
dialogText.setVisible(false);frame.remove(dialogText); dialogText.setVisible(false);frame.remove(dialogText);
changePage(Pages.EXPORT_MODE); changePage(Pages.SDK_INSTALL); // EXPORT_MODE
break; break;
case EXPORT_MODE: case EXPORT_MODE:
button.setVisible(false);frame.remove(button); button.setVisible(false);frame.remove(button);

View File

@@ -31,7 +31,10 @@ import java.io.IOException;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.nio.file.*; import java.nio.file.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.lingala.zip4j.*; import net.lingala.zip4j.*;
@@ -66,10 +69,12 @@ public class MissPiggy implements ActionListener {
private JButton deployButton; private JButton deployButton;
private JTextPane descriptionField; private JTextPane descriptionField;
private int selectedItem; //private int selectedItem;
public String priorityList; public String priorityList;
public boolean listenersAlreadySet = false; // was written to troubleshoot a bug but this wasn't actually the cause
// Initialize the main window // Initialize the main window
public void Action(/*Main entryPoint*/) { public void Action(/*Main entryPoint*/) {
System.out.println("Main window created"); System.out.println("Main window created");
@@ -125,38 +130,6 @@ public class MissPiggy implements ActionListener {
toggleButton.addActionListener(this); toggleButton.addActionListener(this);
descriptionField.getDocument().putProperty("filterNewlines", Boolean.FALSE); 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 // display window
try { try {
@@ -237,8 +210,9 @@ public class MissPiggy implements ActionListener {
} }
} }
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 // 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."); 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.clearSelection();
modList.removeAll(); modList.removeAll();
@@ -260,6 +234,7 @@ public class MissPiggy implements ActionListener {
i++; i++;
} }
modList.setListData(contents); modList.setListData(contents);
createSelectionEventListener();
} }
private ListSelectionListener whenItemSelected() { private ListSelectionListener whenItemSelected() {
@@ -277,10 +252,11 @@ public class MissPiggy implements ActionListener {
if (actionEvent.getSource() == optionsButton) {optionsGUI();} else if (actionEvent.getSource() == optionsButton) {optionsGUI();} else
if (actionEvent.getSource() == fileMenu.getItem(4)) {optionsGUI();} else if (actionEvent.getSource() == fileMenu.getItem(4)) {optionsGUI();} else
if (actionEvent.getSource() == moveUpButton) {throwUnimplemented();} else // todo if (actionEvent.getSource() == moveUpButton) {moveUp(modList.getSelectedIndex());} else
if (actionEvent.getSource() == moveDownButton) {throwUnimplemented();} else // todo if (actionEvent.getSource() == moveDownButton) {moveDown(modList.getSelectedIndex());} else
if (actionEvent.getSource() == toggleButton) {throwUnimplemented();} else // todo if (actionEvent.getSource() == toggleButton) {throwUnimplemented();} else // todo
if (actionEvent.getSource() == deleteButton1) {throwUnimplemented();} else // todo if (actionEvent.getSource() == deleteButton1) {deleteSelected();} else
if (actionEvent.getSource() == helpMenu.getItem(0)) {new Rowlf().displayAboutScreen();} if (actionEvent.getSource() == helpMenu.getItem(0)) {new Rowlf().displayAboutScreen();}
} }
@@ -343,7 +319,18 @@ public class MissPiggy implements ActionListener {
public void removeAllGUI() { public void removeAllGUI() {
// todo warning dialog that nukes list when Yes is clicked // todo warning dialog that nukes list when Yes is clicked
throwUnimplemented(); 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) {
for (Main.Mod entry : Main.Mods) {
new File(System.getProperty("user.home") + "/.firestar/mods/" + entry.path).delete();
}
}
new File(System.getProperty("user.home") + "/.firestar/mods/index").delete();
Main.Mods.clear();
InitializeModListStructure();
InitializeModListInGUI();
} }
public void optionsGUI() { public void optionsGUI() {
@@ -351,6 +338,14 @@ public class MissPiggy implements ActionListener {
throwUnimplemented(); throwUnimplemented();
} }
public void deleteSelected() {
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);
}
public void generatorGUI() { public void generatorGUI() {
// todo mod packer // todo mod packer
throwUnimplemented(); throwUnimplemented();
@@ -361,12 +356,109 @@ public class MissPiggy implements ActionListener {
throwUnimplemented(); throwUnimplemented();
} }
public void aboutGUI() { private void moveUp(int index) {
// todo about page if (index > 0) {
throwUnimplemented(); 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);
}
} }
public void throwUnimplemented() { public void throwUnimplemented() {
JOptionPane.showMessageDialog(frame, "Unimplemented.\nSee README at https://git.worlio.com/bonkmaykr/firestar", "Unimplemented", JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(frame, "Unimplemented.\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();
if(reload) {
Main.Mods.clear(); //cleanup
priorityList = "";
InitializeModListStructure();
InitializeModListInGUI();
}
System.out.println("Mod index file regenerated.");
} catch (Exception e) {
System.out.println(e.getMessage());
JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
} }