From 2e1fe95670261dceb3f456112eec0caf0f8efef3 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Sat, 29 Jun 2024 04:47:55 -0500 Subject: [PATCH] implement Remove All --- src/MissPiggy.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/MissPiggy.java b/src/MissPiggy.java index 9ec1ab6..1efa710 100644 --- a/src/MissPiggy.java +++ b/src/MissPiggy.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.math.RoundingMode; import java.nio.file.*; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import java.util.regex.Pattern; @@ -343,7 +344,18 @@ public class MissPiggy implements ActionListener { public void removeAllGUI() { // 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() { @@ -361,11 +373,6 @@ public class MissPiggy implements ActionListener { throwUnimplemented(); } - public void aboutGUI() { - // todo about page - throwUnimplemented(); - } - public void throwUnimplemented() { JOptionPane.showMessageDialog(frame, "Unimplemented.\nSee README at https://git.worlio.com/bonkmaykr/firestar", "Unimplemented", JOptionPane.INFORMATION_MESSAGE); }