From 7f5b0b85ae93c69b5f6d661f5665b9b92945de29 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Wed, 8 May 2024 14:10:00 -0500 Subject: [PATCH] i forgot my own linux username :/ --- src/Gonzo.java | 16 +++++++++++----- src/Kermit.java | 4 ++-- src/Main.java | 27 +++++++++++++++++++++++++++ src/MissPiggy.java | 4 ++++ 4 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/Gonzo.java b/src/Gonzo.java index 947e54f..c8ee28a 100644 --- a/src/Gonzo.java +++ b/src/Gonzo.java @@ -86,7 +86,7 @@ public class Gonzo { final Thread managerThread = new Thread() { @Override public void run() { - if (!Main.repatch) { + if (Main.repatch) { CompatibilityRoutine(); } else { FastRoutine(); @@ -128,7 +128,7 @@ public class Gonzo { System.out.println(line); consoleDisplay.append(line + "\n"); try {scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());} - catch (Exception e) {System.out.println("WARNING: Swing failed to paint window due to race condition.\n" + e.getMessage());} + catch (Exception e) {System.out.println("WARNING: Swing failed to paint window due to race condition. You can safely ignore this.\n" + e.getMessage());} } reader.close(); } catch (final Exception e) { @@ -141,6 +141,7 @@ public class Gonzo { } catch (IOException | InterruptedException e) { System.out.println(e.getMessage()); consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage()); + JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); AllowExit(); return; @@ -189,6 +190,7 @@ public class Gonzo { } catch (Exception e) { System.out.println(e.getMessage()); consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage()); + JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); AllowExit(); return; @@ -223,6 +225,7 @@ public class Gonzo { } catch (Exception e) { System.out.println(e.getMessage()); consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage()); + JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); AllowExit(); return; @@ -259,15 +262,17 @@ public class Gonzo { } catch (IOException | InterruptedException e) { System.out.println(e.getMessage()); consoleDisplay.append("CRITICAL FAILURE: " + e.getMessage()); + JOptionPane.showMessageDialog(this.frame, "CRITICAL FAILURE: " + e.getMessage(), "Fatal Error", JOptionPane.ERROR_MESSAGE); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); AllowExit(); return; } // cleanup - new File(Main.outpath).mkdirs(); - if (!Main.windows) {new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));} - else {new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));} + System.out.println("created export folder: " + new File(Main.outpath).mkdirs()); + if (!Main.windows) {System.out.println("moved file to destination: " + new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget)));} + else {System.out.println("moved file to destination: " + new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget)));} System.out.println("file should be located at " + Main.outpath + oArcTarget); + //try {TimeUnit.SECONDS.sleep(2);} catch (InterruptedException e) {} try { Process p; if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","rm -rf " + System.getProperty("user.home") + "/.firestar/temp/"});} // Scary! @@ -302,6 +307,7 @@ public class Gonzo { public void AllowExit() { System.out.println("\n\nYou may now close the pop-up window."); consoleDisplay.append("\n\n\nYou may now close the pop-up window."); + try {TimeUnit.MILLISECONDS.sleep(200);} catch (InterruptedException e) {} //ignore scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); frame.addWindowListener(new WindowAdapter() { @Override diff --git a/src/Kermit.java b/src/Kermit.java index 2e1fcc7..3ef85c9 100644 --- a/src/Kermit.java +++ b/src/Kermit.java @@ -341,8 +341,8 @@ public class Kermit implements ActionListener { dialogText.setVisible(false);frame.remove(dialogText); //check if this is windows or not - if(System.getProperty("os.name").contains("Windows")) {Main.windows = false;System.out.println("Assuming we should NOT use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);} - else {Main.windows = true;System.out.println("Assuming we should use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);} + if(System.getProperty("os.name").contains("Windows")) {Main.windows = true;System.out.println("Assuming we should NOT use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);} + else {Main.windows = false;System.out.println("Assuming we should use WINE based on known system variables.");changePage(Pages.EXPORT_LOCATION);} case EXPORT_LOCATION: page = Pages.EXPORT_LOCATION; diff --git a/src/Main.java b/src/Main.java index 72d692b..8b92e8d 100644 --- a/src/Main.java +++ b/src/Main.java @@ -21,6 +21,7 @@ import org.json.*; import java.io.*; import java.nio.file.*; import java.util.*; +import javax.swing.JOptionPane; public class Main { // Build Information @@ -98,6 +99,32 @@ public class Main { } public static void loadConf(){ + try { + JSONObject container = new JSONObject(new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/firestar.conf")))); + System.out.println(container.toString()); // debug + int confvint = (int) container.get("version"); // used for converting configs between program versions later down the line + outpath = container.get("2048path").toString(); + repatch = (boolean) container.get("safemode"); + windows = (boolean) container.get("isWin32"); + } catch (IOException e) { + System.out.println("ERROR: Failed to load firestar.conf"); + System.out.println(e.getMessage()); + } + return; + } + public static void loadConf(MissPiggy w){ + try { + JSONObject container = new JSONObject(new String(Files.readAllBytes(Paths.get(System.getProperty("user.home") + "/.firestar/firestar.conf")))); + System.out.println(container.toString()); // debug + int confvint = (int) container.get("version"); // used for converting configs between program versions later down the line + outpath = container.get("2048path").toString(); + repatch = (boolean) container.get("safemode"); + windows = (boolean) container.get("isWin32"); + } catch (Exception e) { + JOptionPane.showMessageDialog(w.frame, "Firestar couldn't load your config file. Tread lightly.\n\n" + e.getMessage(), "Critical Error", JOptionPane.ERROR_MESSAGE); + System.out.println("ERROR: Failed to load firestar.conf"); + System.out.println(e.getMessage()); + } } } \ No newline at end of file diff --git a/src/MissPiggy.java b/src/MissPiggy.java index 17dfc48..ff678b7 100644 --- a/src/MissPiggy.java +++ b/src/MissPiggy.java @@ -69,6 +69,8 @@ public class MissPiggy implements ActionListener { // Initialize the main window public void Action(/*Main entryPoint*/) { System.out.println("Main window created"); + System.out.println("Loading program configuration"); + Main.loadConf(this); // populate menu bar menuBar = new JMenuBar(); @@ -109,6 +111,7 @@ public class MissPiggy implements ActionListener { toolsMenu.getItem(0).addActionListener(this); toolsMenu.getItem(1).addActionListener(this); helpMenu.getItem(0).addActionListener(this); + deployButton.addActionListener(this); descriptionField.getDocument().putProperty("filterNewlines", Boolean.FALSE); modList.addListSelectionListener(e -> { @@ -251,6 +254,7 @@ public class MissPiggy implements ActionListener { public void actionPerformed(ActionEvent actionEvent) { if (actionEvent.getSource() == fileMenu.getItem(5)) {System.exit(0);} else if (actionEvent.getSource() == fileMenu.getItem(0)) {deployModGUI();} else + if (actionEvent.getSource() == deployButton) {deployModGUI();} else if (actionEvent.getSource() == fileMenu.getItem(1)) {importModGUI();} else if (actionEvent.getSource() == fileMenu.getItem(2)) {removeAllGUI();} else if (actionEvent.getSource() == fileMenu.getItem(4)) {optionsGUI();} else