From 785b101245cee2c93949a7f3c59f332162fcb19b Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Tue, 16 Jul 2024 01:22:40 -0500 Subject: [PATCH] unfuck code, kill robin, erase evidence --- firestar/src/main/java/Clifford.java | 45 +++++++++++++++++++++------ firestar/src/main/java/MissPiggy.java | 6 ++-- firestar/src/main/java/Robin.java | 23 -------------- firestar/src/main/java/Suggs.java | 4 +-- 4 files changed, 40 insertions(+), 38 deletions(-) delete mode 100644 firestar/src/main/java/Robin.java diff --git a/firestar/src/main/java/Clifford.java b/firestar/src/main/java/Clifford.java index e9d6b6a..68e9a1d 100644 --- a/firestar/src/main/java/Clifford.java +++ b/firestar/src/main/java/Clifford.java @@ -45,14 +45,39 @@ public class Clifford implements ActionListener { private JButton savebtn; private JButton cancelbtn; - Robin invoker; + JFrame invoker; + MissPiggy invokerPig; + boolean isPig = false; Main.Mod mod; int index; File directory; boolean creating; - public void Action(Robin inv, int modindex) { // Editor + public void Action(MissPiggy inv, int modindex) { + invokerPig = inv; + invoker = invokerPig.frame; + mod = Main.Mods.get(modindex); + index = modindex; + creating = false; + + isPig = true; + + Action(invoker, modindex); + } + + public void Action(MissPiggy inv, File dir) { + invokerPig = inv; + invoker = invokerPig.frame; + directory = dir; + creating = true; + + isPig = true; + + Action(invoker, dir); + } + + public void Action(JFrame inv, int modindex) { // Editor invoker = inv; mod = Main.Mods.get(modindex); index = modindex; @@ -71,7 +96,7 @@ public class Clifford implements ActionListener { frame.setResizable(false); frame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); frame.setLayout(new GridLayout()); - frame.setLocationRelativeTo(inv.frame); + frame.setLocationRelativeTo(inv); frame.setAlwaysOnTop(true); fName.setText(mod.friendlyName); @@ -87,13 +112,13 @@ public class Clifford implements ActionListener { @Override public void windowClosing(WindowEvent e) { - invoker.frame.setEnabled(true); + invoker.setEnabled(true); e.getWindow().dispose(); } }); } - public void Action(Robin inv, File dir) { // Generator + public void Action(JFrame inv, File dir) { // Generator invoker = inv; directory = dir; creating = true; @@ -116,7 +141,7 @@ public class Clifford implements ActionListener { @Override public void windowClosing(WindowEvent e) { - invoker.frame.setEnabled(true); + invoker.setEnabled(true); e.getWindow().dispose(); } }); @@ -125,7 +150,7 @@ public class Clifford implements ActionListener { @Override public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == cancelbtn) { - invoker.frame.setEnabled(true); + invoker.setEnabled(true); frame.dispose(); } else if (actionEvent.getSource() == savebtn && !creating) { try { @@ -158,8 +183,8 @@ public class Clifford implements ActionListener { } Main.Mods.set(index, mod); - invoker.frame.setEnabled(true); - if (invoker instanceof MissPiggy) ((MissPiggy)invoker).InitializeModListInGUI(); + invoker.setEnabled(true); + if (isPig) {invokerPig.InitializeModListInGUI();} frame.dispose(); } else if (actionEvent.getSource() == savebtn && creating) { if (fName.getText().isEmpty()) { @@ -203,7 +228,7 @@ public class Clifford implements ActionListener { return; } JOptionPane.showMessageDialog(frame, "Mod file created", "Success", JOptionPane.INFORMATION_MESSAGE); - invoker.frame.setEnabled(true); + invoker.setEnabled(true); frame.dispose(); } } diff --git a/firestar/src/main/java/MissPiggy.java b/firestar/src/main/java/MissPiggy.java index 66d7e56..7a3af02 100644 --- a/firestar/src/main/java/MissPiggy.java +++ b/firestar/src/main/java/MissPiggy.java @@ -48,7 +48,7 @@ import static java.nio.file.StandardCopyOption.*; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; -public class MissPiggy implements Robin, ActionListener { +public class MissPiggy implements ActionListener { BufferedImage windowIcon; JFrame frame = new JFrame(); JPanel frameContainer; @@ -107,7 +107,7 @@ public class MissPiggy implements Robin, ActionListener { 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("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("Manual")); @@ -136,7 +136,7 @@ public class MissPiggy implements Robin, ActionListener { fileMenu.getItem(5).addActionListener(this); toolsMenu.getItem(0).addActionListener(this); toolsMenu.getItem(1).addActionListener(this); - //toolsMenu.getItem(2).addActionListener(this); + toolsMenu.getItem(2).addActionListener(this); helpMenu.getItem(0).addActionListener(this); helpMenu.getItem(2).addActionListener(this); helpMenu.getItem(3).addActionListener(this); diff --git a/firestar/src/main/java/Robin.java b/firestar/src/main/java/Robin.java deleted file mode 100644 index 4995cce..0000000 --- a/firestar/src/main/java/Robin.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.swing.JFrame; - -public interface Robin { - public JFrame frame = new JFrame(); -} \ No newline at end of file diff --git a/firestar/src/main/java/Suggs.java b/firestar/src/main/java/Suggs.java index be1ef3a..f806ac6 100644 --- a/firestar/src/main/java/Suggs.java +++ b/firestar/src/main/java/Suggs.java @@ -47,7 +47,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -public class Suggs implements Robin, ActionListener, ListSelectionListener { +public class Suggs implements ActionListener, ListSelectionListener { public JFrame frame = new JFrame(); private JPanel frameContainer; private JList dSongList; @@ -331,7 +331,7 @@ public class Suggs implements Robin, ActionListener, ListSelectionListener { progressDialog.destroyDialog(); frame.dispose(); - new Clifford().Action(this, new File(System.getProperty("user.home") + "/.firestar/temp/")); + new Clifford().Action(frame, new File(System.getProperty("user.home") + "/.firestar/temp/")); System.out.println("Post Clifford"); parent.setEnabled(true); }).start();