From d8902af148f62f377fca32745b35fe1b10eae327 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Sat, 29 Jun 2024 05:29:38 -0500 Subject: [PATCH] going to throw this out because nuking index is easier --- src/MissPiggy.java | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/MissPiggy.java b/src/MissPiggy.java index 1efa710..c6ac765 100644 --- a/src/MissPiggy.java +++ b/src/MissPiggy.java @@ -67,7 +67,7 @@ public class MissPiggy implements ActionListener { private JButton deployButton; private JTextPane descriptionField; - private int selectedItem; + //private int selectedItem; public String priorityList; @@ -281,7 +281,7 @@ public class MissPiggy implements ActionListener { if (actionEvent.getSource() == moveUpButton) {throwUnimplemented();} else // todo if (actionEvent.getSource() == moveDownButton) {throwUnimplemented();} else // todo if (actionEvent.getSource() == toggleButton) {throwUnimplemented();} else // todo - if (actionEvent.getSource() == deleteButton1) {throwUnimplemented();} else // todo + if (actionEvent.getSource() == deleteButton1) {deleteSelected();} else // todo if (actionEvent.getSource() == helpMenu.getItem(0)) {new Rowlf().displayAboutScreen();} } @@ -363,6 +363,34 @@ public class MissPiggy implements ActionListener { throwUnimplemented(); } + public void deleteSelected() { + File file = new File(System.getProperty("user.home") + "/.firestar/mods/" + Main.Mods.get(modList.getSelectedIndex()).path); //new File(Main.Mods.get(modList.getSelectedIndex()).path); + //String filename = Paths.get(Main.Mods.get(modList.getSelectedIndex()).path).getFileName().toString(); //redundant since Mod path is relative to /.firestar/mods + + //JOptionPane.showMessageDialog(frame, filename, "Unimplemented", JOptionPane.INFORMATION_MESSAGE); //debug + + file.delete(); System.out.println("Deleted " + Main.Mods.get(modList.getSelectedIndex()).friendlyName); //debug + try { + priorityList = new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/mods/index"))); + String[] pListArray = priorityList.split("\n"); + Arrays.sort(pListArray); + System.out.println("Searching modlist to remove " + Main.Mods.get(modList.getSelectedIndex()).friendlyName); //debug + + int i = 0; + for (String s : pListArray) { + if (file.getName().equals(s.substring(s.indexOf("=") + 1))) { + pListArray[i] = ""; + } + i++; + } + + + } catch (IOException e) { + System.out.println(e.getMessage()); + JOptionPane.showMessageDialog(frame, "An error has occured.\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + } + public void generatorGUI() { // todo mod packer throwUnimplemented();