tried to add a feature, fucked up. here, I fucked up other bits of code too.
This commit is contained in:
parent
de0f951ce2
commit
13513987c8
|
@ -45,14 +45,14 @@ public class Clifford implements ActionListener {
|
|||
private JButton savebtn;
|
||||
private JButton cancelbtn;
|
||||
|
||||
MissPiggy invoker;
|
||||
Robin invoker;
|
||||
Main.Mod mod;
|
||||
int index;
|
||||
File directory;
|
||||
|
||||
boolean creating;
|
||||
|
||||
public void Action(MissPiggy inv, int modindex) { // Editor
|
||||
public void Action(Robin inv, int modindex) { // Editor
|
||||
invoker = inv;
|
||||
mod = Main.Mods.get(modindex);
|
||||
index = modindex;
|
||||
|
@ -93,7 +93,7 @@ public class Clifford implements ActionListener {
|
|||
});
|
||||
}
|
||||
|
||||
public void Action(MissPiggy inv, File dir) { // Generator
|
||||
public void Action(Robin inv, File dir) { // Generator
|
||||
invoker = inv;
|
||||
directory = dir;
|
||||
creating = true;
|
||||
|
@ -159,7 +159,7 @@ public class Clifford implements ActionListener {
|
|||
|
||||
Main.Mods.set(index, mod);
|
||||
invoker.frame.setEnabled(true);
|
||||
invoker.InitializeModListInGUI();
|
||||
if (invoker instanceof MissPiggy) ((MissPiggy)invoker).InitializeModListInGUI();
|
||||
frame.dispose();
|
||||
} else if (actionEvent.getSource() == savebtn && creating) {
|
||||
if (fName.getText().isEmpty()) {
|
||||
|
|
|
@ -21,10 +21,12 @@ import net.lingala.zip4j.exception.ZipException;
|
|||
import org.json.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
|
@ -92,6 +94,7 @@ public class Main {
|
|||
|
||||
// UI Global Assets
|
||||
public static Font fExo2;
|
||||
public static BufferedImage windowIcon;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// license string
|
||||
|
@ -120,6 +123,13 @@ public class Main {
|
|||
fExo2 = new Font("Arial", Font.PLAIN, 12);
|
||||
}
|
||||
|
||||
// load global window icon
|
||||
try {
|
||||
windowIcon = ImageIO.read(Main.class.getResourceAsStream("/titleIcon.png"));
|
||||
} catch (IOException e) {
|
||||
System.out.println("ERROR: Failed to find titleIcon.png. Window will not have an icon.");
|
||||
}
|
||||
|
||||
// check and load configs
|
||||
File fConf = new File(System.getProperty("user.home") + "/.firestar/firestar.conf");
|
||||
if (!fConf.isFile()) {
|
||||
|
@ -226,4 +236,18 @@ public class Main {
|
|||
public static boolean callDownloaderStatically (String url, String folder, String name) {
|
||||
return new Fozzie().DownloadFile(url, folder, name);
|
||||
}
|
||||
|
||||
public static Process exec(String[] cmd, String cwd) throws IOException {
|
||||
Process p;
|
||||
String[] pcmd;
|
||||
if (!Main.windows) {
|
||||
pcmd = new String[cmd.length + 1];
|
||||
pcmd[0] = "wine";
|
||||
System.arraycopy(cmd, 0, pcmd, 1, cmd.length);
|
||||
p = Runtime.getRuntime().exec(pcmd, null, new File(cwd));
|
||||
} else {
|
||||
p = Runtime.getRuntime().exec(cmd, null, new File(cwd.replace("/", "\\")));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ import static java.nio.file.StandardCopyOption.*;
|
|||
|
||||
import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
|
||||
|
||||
public class MissPiggy implements ActionListener {
|
||||
public class MissPiggy implements Robin, ActionListener {
|
||||
BufferedImage windowIcon;
|
||||
JFrame frame = new JFrame();
|
||||
JPanel frameContainer;
|
||||
|
@ -107,7 +107,7 @@ public class MissPiggy implements 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 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);
|
||||
|
|
23
firestar/src/main/java/Robin.java
Normal file
23
firestar/src/main/java/Robin.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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();
|
||||
}
|
44
firestar/src/main/java/Scooter.form
Normal file
44
firestar/src/main/java/Scooter.form
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Scooter">
|
||||
<grid id="27dc6" binding="frameContainer" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-15128227"/>
|
||||
<font name="Exo 2"/>
|
||||
<foreground color="-1"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4913b" class="javax.swing.JProgressBar" binding="progressBar">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
<maximum-size width="200" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-1"/>
|
||||
<borderPainted value="false"/>
|
||||
<foreground color="-2271221"/>
|
||||
<indeterminate value="false"/>
|
||||
<stringPainted value="true"/>
|
||||
<value value="0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="46ede" class="javax.swing.JLabel" binding="label">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-15128227"/>
|
||||
<font name="Exo 2"/>
|
||||
<foreground color="-1"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
79
firestar/src/main/java/Scooter.java
Normal file
79
firestar/src/main/java/Scooter.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
|
||||
public class Scooter {
|
||||
private JFrame frame = new JFrame();
|
||||
public JProgressBar progressBar;
|
||||
private JPanel frameContainer;
|
||||
private JLabel label;
|
||||
|
||||
public void showDialog(String title) {
|
||||
frame.add(frameContainer);
|
||||
frame.setSize(300, 100);
|
||||
frame.setTitle(title);
|
||||
frame.setResizable(false);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
frame.setLayout(new GridLayout());
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setAlwaysOnTop(true);
|
||||
frame.setIconImage(Main.windowIcon);
|
||||
|
||||
progressBar.setStringPainted(true);
|
||||
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void setProgressMin(int i) {
|
||||
progressBar.setMinimum(i);
|
||||
}
|
||||
|
||||
public void setProgressValue(int i) {
|
||||
progressBar.setValue(i);
|
||||
}
|
||||
|
||||
public void setProgressMax(int i) {
|
||||
progressBar.setMaximum(i);
|
||||
}
|
||||
|
||||
public int getProgressMin() {
|
||||
return progressBar.getMinimum();
|
||||
}
|
||||
|
||||
public int getProgressValue() {
|
||||
return progressBar.getValue();
|
||||
}
|
||||
|
||||
public int getProgressMax() {
|
||||
return progressBar.getMaximum();
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
label.setText(text);
|
||||
}
|
||||
|
||||
public void destroyDialog() {
|
||||
frame.setVisible(false);
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
|
@ -16,6 +16,12 @@
|
|||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
|
@ -28,15 +34,20 @@ import java.awt.event.WindowEvent;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
public class Suggs implements ActionListener, ListSelectionListener {
|
||||
private BufferedImage windowIcon;
|
||||
public class Suggs implements Robin, ActionListener, ListSelectionListener {
|
||||
public JFrame frame = new JFrame();
|
||||
private JPanel frameContainer;
|
||||
private JList dSongList;
|
||||
|
@ -57,6 +68,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
private JLabel dSTitle;
|
||||
private JLabel dMTitle;
|
||||
private JCheckBox checkAdditive;
|
||||
private Scooter progressDialog;
|
||||
|
||||
JFrame parent;
|
||||
int curIndex = -1;
|
||||
|
@ -77,16 +89,11 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
this.parent = parent;
|
||||
parent.setEnabled(false);
|
||||
|
||||
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(frameContainer); // initialize window contents -- will be handled by IntelliJ IDEA
|
||||
|
||||
frame.setSize(700, 400);
|
||||
frame.setMinimumSize(new Dimension(700,400));
|
||||
frame.setMinimumSize(new Dimension(650,280));
|
||||
frame.setTitle("Soundtrack Mod Generator");
|
||||
frame.setResizable(true);
|
||||
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
|
@ -249,61 +256,84 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
}
|
||||
}
|
||||
|
||||
private JFrame progressFrame = new JFrame();
|
||||
public JProgressBar progressBar;
|
||||
private JPanel progressFrameContainer;
|
||||
private JLabel progressLabel;
|
||||
|
||||
private void save() {
|
||||
progressFrameContainer = new JPanel();
|
||||
frame.setEnabled(false);
|
||||
frame.setAlwaysOnTop(false);
|
||||
Main.deleteDir(new File(System.getProperty("user.home") + "/.firestar/temp/")); // starts with clean temp
|
||||
new Thread(() -> {
|
||||
int progressSize = tracklist.size()+(sptrack != null?1:0)+(mptrack != null?1:0)+2; // Accounting for processes
|
||||
|
||||
progressLabel = new JLabel("Generating audio files...");
|
||||
progressBar = new JProgressBar();
|
||||
progressBar.setMaximum(tracklist.size());
|
||||
progressDialog = new Scooter();
|
||||
progressDialog.showDialog("Soundtrack Mod Generator");
|
||||
progressDialog.setText("Generating audio files...");
|
||||
progressDialog.setProgressMax(progressSize);
|
||||
|
||||
progressFrameContainer.add(progressLabel);
|
||||
progressFrameContainer.add(progressBar);
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data/audio/music").mkdirs();
|
||||
|
||||
progressFrame.add(progressFrameContainer);
|
||||
progressFrame.setSize(300, 100);
|
||||
progressFrame.setTitle("Soundtrack Mod Generator");
|
||||
progressFrame.setResizable(false);
|
||||
progressFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
progressFrame.setLayout(new GridLayout());
|
||||
progressFrame.setLocationRelativeTo(null);
|
||||
progressFrame.setAlwaysOnTop(true);
|
||||
progressFrame.setIconImage(windowIcon);
|
||||
|
||||
// Lord, forgive me for this style hell
|
||||
progressFrameContainer.setBackground(new Color(-15128227));
|
||||
progressFrameContainer.setForeground(new Color(-1));
|
||||
progressBar.setBackground(new Color(-1));
|
||||
progressBar.setForeground(new Color(-2271221));
|
||||
progressLabel.setBackground(new Color(-15128227));
|
||||
progressLabel.setForeground(new Color(-1));
|
||||
|
||||
progressFrame.setVisible(true);
|
||||
|
||||
frame.dispose();
|
||||
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/audio/music").mkdirs();
|
||||
|
||||
int i = 0;
|
||||
for (AudioTrack at : tracklist) {
|
||||
Process p;
|
||||
for (int i = 0; i < tracklist.size(); i++) {
|
||||
AudioTrack at = tracklist.get(i);
|
||||
String trackno = String.format("%02d", i);
|
||||
progressDialog.setText("Encoding track " + (i+1) + " out of " + tracklist.size() + "...");
|
||||
try {
|
||||
System.out.println("Encoding \"" + at.title + " - " + at.artist + "\"...");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/audio/music/" + String.format("%02d", i)).mkdirs();
|
||||
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","cd " + System.getProperty("user.home") + "/.firestar/temp/" + ";wine ../at9tool.exe -e -br 144 \"" + at.path + "\" audio/music/" + String.format("%02d", i) + "/music_stereo.at9"});}
|
||||
else {p = Runtime.getRuntime().exec(new String[]{(System.getProperty("user.home") + "\\.firestar\\at9tool.exe"), "-e", "-br", "144", at.path, "audio\\music\\" + String.format("%02d", i) + "\\music_stereo.at9"}, null, new File((System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\")));}
|
||||
System.out.println("Encoding track #" + (i+1) + " \"" + at.title + " - " + at.artist + "\"...");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data/audio/music/" + trackno).mkdirs();
|
||||
Process p = Main.exec(new String[]{"../at9tool.exe", "-e", "-br", "144", at.path, "data/audio/music/" + trackno + "/music_stereo.at9"}, System.getProperty("user.home") + "/.firestar/temp/");
|
||||
p.waitFor();
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
progressBar.setValue(i++);
|
||||
progressDialog.setProgressValue(i);
|
||||
}
|
||||
if (sptrack != null) {
|
||||
progressDialog.setText("Encoding singleplayer frontend track...");
|
||||
if (new File(sptrack).exists()) {
|
||||
try {
|
||||
System.out.println("Encoding singleplayer frontend track...");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data/audio/music/FEMusic").mkdirs();
|
||||
Process p = Main.exec(new String[]{"../at9tool.exe", "-e", "-br", "144", sptrack, "data/audio/music/FEMusic/frontend_stereo.at9"}, System.getProperty("user.home") + "/.firestar/temp/");
|
||||
p.waitFor();
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||
}
|
||||
if (mptrack != null) {
|
||||
progressDialog.setText("Encoding multiplayer frontend track...");
|
||||
try {
|
||||
assert(new File(mptrack).exists());
|
||||
System.out.println("Encoding multiplayer frontend track...");
|
||||
new File(System.getProperty("user.home") + "/.firestar/temp/data/audio/music/FEDemoMusic").mkdirs();
|
||||
Process p = Main.exec(new String[]{"../at9tool.exe", "-e", "-br", "144", mptrack, "data/audio/music/FEDemoMusic/frontend_stereo.at9"}, System.getProperty("user.home") + "/.firestar/temp/");
|
||||
p.waitFor();
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||
}
|
||||
System.out.println("Finished encoding.");
|
||||
progressFrame.dispose();
|
||||
|
||||
progressDialog.setText("Generating Music Definitions...");
|
||||
/*
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
try {
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document doc = db.parse(new File());
|
||||
NodeList screen = doc.getElementsByTagName("Screen");
|
||||
for (int i = 0; i < tracklist.size(); i++) {
|
||||
AudioTrack at = tracklist.get(i);
|
||||
Node node = screen.item(i);
|
||||
}
|
||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||
|
||||
progressDialog.destroyDialog();
|
||||
frame.dispose();
|
||||
new Clifford().Action(this, new File(System.getProperty("user.home") + "/.firestar/temp/"));
|
||||
System.out.println("Post Clifford");
|
||||
parent.setEnabled(true);
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user