diff --git a/firestar/src/main/java/Bert.java b/firestar/src/main/java/Bert.java index 15817e5..888b70d 100644 --- a/firestar/src/main/java/Bert.java +++ b/firestar/src/main/java/Bert.java @@ -23,12 +23,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; import java.io.*; import java.util.ArrayList; public class Bert implements ActionListener { - BufferedImage windowIcon; public JFrame frame = new JFrame(); private JPanel frameContainer; private JButton cancelbtn; @@ -60,12 +58,7 @@ public class Bert implements ActionListener { cancelbtn.addActionListener(this); downloadbtn.addActionListener(this); - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { diff --git a/firestar/src/main/java/Clifford.java b/firestar/src/main/java/Clifford.java index 31b6ced..f7ab3ca 100644 --- a/firestar/src/main/java/Clifford.java +++ b/firestar/src/main/java/Clifford.java @@ -84,12 +84,7 @@ public class Clifford implements ActionListener { creating = false; frame.add(frameContainer); - try { - BufferedImage windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find resource titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); frame.setSize(600, 300); // 1280 800 frame.setMinimumSize(new Dimension(200,100)); frame.setTitle("Options"); diff --git a/firestar/src/main/java/Ernie.java b/firestar/src/main/java/Ernie.java index bfd83bb..8be8a5d 100644 --- a/firestar/src/main/java/Ernie.java +++ b/firestar/src/main/java/Ernie.java @@ -61,18 +61,12 @@ public class Ernie implements ActionListener { private JButton surebtn; public boolean backgroundDone = false; - private BufferedImage windowIcon; private JFrame parent; public Ernie(JFrame parent) { this.parent = parent; - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); byte[] urlraw = getFile(gitapi+"/releases?draft=false&pre-release=false"); if (urlraw.length <= 0) { JOptionPane.showMessageDialog(frame, "Internal Error: Couldn't check for updates.", "Fatal Error", JOptionPane.ERROR_MESSAGE); diff --git a/firestar/src/main/java/Fozzie.java b/firestar/src/main/java/Fozzie.java index 3239e4c..4a90f74 100644 --- a/firestar/src/main/java/Fozzie.java +++ b/firestar/src/main/java/Fozzie.java @@ -55,12 +55,7 @@ public class Fozzie { frame.setLayout(new GridLayout()); frame.setLocationRelativeTo(null); frame.setAlwaysOnTop(true); - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); frame.setVisible(true); label.setText("Downloading \"" + dname + "\""); diff --git a/firestar/src/main/java/Gonzo.java b/firestar/src/main/java/Gonzo.java index 87e33c4..d43cdb9 100644 --- a/firestar/src/main/java/Gonzo.java +++ b/firestar/src/main/java/Gonzo.java @@ -60,12 +60,7 @@ public class Gonzo { frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA - try { - BufferedImage windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); frame.setSize(800, 400); frame.setMinimumSize(new Dimension(600,400)); frame.setTitle("Mod Installation"); diff --git a/firestar/src/main/java/MissPiggy.java b/firestar/src/main/java/MissPiggy.java index 7a3af02..970daf4 100644 --- a/firestar/src/main/java/MissPiggy.java +++ b/firestar/src/main/java/MissPiggy.java @@ -49,7 +49,6 @@ import static java.nio.file.StandardCopyOption.*; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; public class MissPiggy implements ActionListener { - BufferedImage windowIcon; JFrame frame = new JFrame(); JPanel frameContainer; JPanel actionsContainer; @@ -154,12 +153,7 @@ public class MissPiggy implements ActionListener { descriptionField.getDocument().putProperty("filterNewlines", Boolean.FALSE); // display window - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); menuBar.setBackground(new Color(25, 41, 93)); fileMenu.setForeground(new Color(255, 255, 255)); diff --git a/firestar/src/main/java/Rizzo.java b/firestar/src/main/java/Rizzo.java new file mode 100644 index 0000000..9bc4f47 --- /dev/null +++ b/firestar/src/main/java/Rizzo.java @@ -0,0 +1,87 @@ +/* + * 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 java.io.File; +import java.util.ArrayList; +import java.util.StringTokenizer; + +public class Rizzo { + + public void Rizzo(File infile) { + + } + + public static String[] translateCommandline(String toProcess) { + if (toProcess == null || toProcess.length() == 0) { + return new String[0]; + } + + final int normal = 0; + final int inQuote = 1; + final int inDoubleQuote = 2; + int state = normal; + final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true); + final ArrayList result = new ArrayList(); + final StringBuilder current = new StringBuilder(); + boolean lastTokenHasBeenQuoted = false; + + while (tok.hasMoreTokens()) { + String nextTok = tok.nextToken(); + switch (state) { + case inQuote: + if ("\'".equals(nextTok)) { + lastTokenHasBeenQuoted = true; + state = normal; + } else { + current.append(nextTok); + } + break; + case inDoubleQuote: + if ("\"".equals(nextTok)) { + lastTokenHasBeenQuoted = true; + state = normal; + } else { + current.append(nextTok); + } + break; + default: + if ("\'".equals(nextTok)) { + state = inQuote; + } else if ("\"".equals(nextTok)) { + state = inDoubleQuote; + } else if (" ".equals(nextTok)) { + if (lastTokenHasBeenQuoted || current.length() != 0) { + result.add(current.toString()); + current.setLength(0); + } + } else { + current.append(nextTok); + } + lastTokenHasBeenQuoted = false; + break; + } + } + if (lastTokenHasBeenQuoted || current.length() != 0) { + result.add(current.toString()); + } + if (state == inQuote || state == inDoubleQuote) { + throw new RuntimeException("unbalanced quotes in " + toProcess); + } + return result.toArray(new String[result.size()]); + } +} diff --git a/firestar/src/main/java/Rowlf.java b/firestar/src/main/java/Rowlf.java index eef0ee5..881fee8 100644 --- a/firestar/src/main/java/Rowlf.java +++ b/firestar/src/main/java/Rowlf.java @@ -26,7 +26,6 @@ import java.io.IOException; import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; public class Rowlf { - private BufferedImage windowIcon; JFrame frame = new JFrame(); JPanel frameContainer; Image logo; @@ -42,12 +41,7 @@ public class Rowlf { System.out.println("ERROR: Failed to open About screen because we couldn't find an image needed to display the page."); throw new RuntimeException(e); } - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); //frame.add(picLabel); frame.add(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA diff --git a/firestar/src/main/java/Waldorf.java b/firestar/src/main/java/Waldorf.java index 2d46401..1a30db4 100644 --- a/firestar/src/main/java/Waldorf.java +++ b/firestar/src/main/java/Waldorf.java @@ -50,12 +50,7 @@ public class Waldorf implements ActionListener { invoker = inv; frame.add(frameContainer); - try { - BufferedImage windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); frame.setSize(600, 300); // 1280 800 frame.setMinimumSize(new Dimension(200,100)); frame.setTitle("Options"); diff --git a/firestar/src/main/java/WilkinsCoffee.java b/firestar/src/main/java/WilkinsCoffee.java index f869fe4..175032c 100644 --- a/firestar/src/main/java/WilkinsCoffee.java +++ b/firestar/src/main/java/WilkinsCoffee.java @@ -32,7 +32,6 @@ import java.nio.file.Files; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; public class WilkinsCoffee implements ActionListener { - BufferedImage windowIcon; Image logo; public Pages page; public JFrame frame = new JFrame(); @@ -82,12 +81,7 @@ public class WilkinsCoffee implements ActionListener { // reformat path slightly for windows if (Main.windows) {outPathTemp.replace("/", "\\");} - try { - windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png")); - frame.setIconImage(windowIcon); - } catch (IOException e) { - System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); - } + frame.setIconImage(Main.windowIcon); try { logo = ImageIO.read(Main.class.getResourceAsStream("/programIcon.png")).getScaledInstance(96, 96, Image.SCALE_SMOOTH); picLabel.setIcon(new ImageIcon(logo));picLabel.setText("");