Fix invisible mod entries (#1)

This commit is contained in:
Downforce Agent 2024-07-03 16:46:21 -05:00
parent 727563e665
commit 2dd6e0b0ff
2 changed files with 12 additions and 2 deletions

View File

@ -139,6 +139,10 @@ public class Clifford implements ActionListener {
mod.description = fDescription.getText(); mod.description = fDescription.getText();
JSONObject container = new JSONObject(); JSONObject container = new JSONObject();
if (mod.friendlyName.isEmpty()) {
JOptionPane.showMessageDialog(frame, "Mod name cannot be empty.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
container.put("version", mod.version); container.put("version", mod.version);
container.put("friendlyName", mod.friendlyName); container.put("friendlyName", mod.friendlyName);
container.put("author", mod.author); container.put("author", mod.author);
@ -158,6 +162,10 @@ public class Clifford implements ActionListener {
invoker.InitializeModListInGUI(); invoker.InitializeModListInGUI();
frame.dispose(); frame.dispose();
} else if (actionEvent.getSource() == savebtn && creating) { } else if (actionEvent.getSource() == savebtn && creating) {
if (fName.getText().isEmpty()) {
JOptionPane.showMessageDialog(frame, "Mod name cannot be empty.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try { try {
Integer.parseInt(fVersion.getText()); Integer.parseInt(fVersion.getText());
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -286,12 +286,14 @@ public class MissPiggy implements ActionListener {
/*JLabel[]*/String[] contents = new String[Main.Mods.size()]; /*JLabel[]*/String[] contents = new String[Main.Mods.size()];
System.out.println("Initializing modList to GUI with length of " + Main.Mods.size() + " units"); //debug System.out.println("Initializing modList to GUI with length of " + Main.Mods.size() + " units"); //debug
while (i < Main.Mods.size()) { while (i < Main.Mods.size()) {
if (Main.Mods.get(i).friendlyName == null || Main.Mods.get(i).friendlyName.isEmpty())
{Main.Mods.get(i).friendlyName = Main.Mods.get(i).path;}
if (Main.Mods.get(i).enabled) {contents[i] = Main.Mods.get(i).friendlyName;} if (Main.Mods.get(i).enabled) {contents[i] = Main.Mods.get(i).friendlyName;}
else {contents[i] = Main.Mods.get(i).friendlyName + " (Disabled)";} else {contents[i] = Main.Mods.get(i).friendlyName + " (Disabled)";}
//debug //debug
String authorDisplay; String authorDisplay;
if (Main.Mods.get(i).author == null) {authorDisplay = "Anonymous";} else {authorDisplay = "\"" + Main.Mods.get(i).author + "\"";} if (Main.Mods.get(i).author == null || Main.Mods.get(i).author.isEmpty()) {authorDisplay = "Anonymous";} else {authorDisplay = "\"" + Main.Mods.get(i).author + "\"";}
System.out.println("Added " + Main.Mods.get(i).friendlyName + " by " + authorDisplay); System.out.println("Added " + Main.Mods.get(i).friendlyName + " by " + authorDisplay);
i++; i++;
@ -546,7 +548,7 @@ public class MissPiggy implements ActionListener {
modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024 * 1024))); modFileSizeStr = String.valueOf(df.format(modFileSize / (1024 * 1024 * 1024)));
modFileSizeUnits = "Gigabytes"; modFileSizeUnits = "Gigabytes";
} }
if (Main.Mods.get(modList.getSelectedIndex()).author == null) { if (Main.Mods.get(modList.getSelectedIndex()).author == null || Main.Mods.get(modList.getSelectedIndex()).author.isEmpty()) {
authorDisplay = "an Unknown Author"; authorDisplay = "an Unknown Author";
} else { } else {
authorDisplay = Main.Mods.get(modList.getSelectedIndex()).author; authorDisplay = Main.Mods.get(modList.getSelectedIndex()).author;