implement fscript into suggs
This commit is contained in:
parent
3c6b3e84ba
commit
c24da0edfd
|
@ -27,8 +27,10 @@ import java.awt.event.ActionListener;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
@ -156,7 +158,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
AudioTrack at = tracklist.get(curIndex);
|
AudioTrack at = tracklist.get(curIndex);
|
||||||
fTitle.setText(at.title);
|
fTitle.setText(at.title);
|
||||||
fArtist.setText(at.artist);
|
fArtist.setText(at.artist);
|
||||||
dTrackNo.setText(String.format("MT_%02d", curIndex));
|
dTrackNo.setText(String.format("MT_%02d", curIndex+1));
|
||||||
dFileSize.setText((at.size / 1000) + "kb");
|
dFileSize.setText((at.size / 1000) + "kb");
|
||||||
} else {
|
} else {
|
||||||
fTitle.setText("");
|
fTitle.setText("");
|
||||||
|
@ -285,110 +287,129 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
progressDialog.setProgressMax(progressSize);
|
progressDialog.setProgressMax(progressSize);
|
||||||
progressDialog.setProgressValue(0);
|
progressDialog.setProgressValue(0);
|
||||||
|
|
||||||
new File(Main.inpath + "temp/data/audio/music").mkdirs();
|
try {
|
||||||
|
new File(Main.inpath + "temp/data/audio/music").mkdirs();
|
||||||
for (int i = 0; i < tracklist.size(); i++) {
|
FileOutputStream fos = new FileOutputStream(new File(Main.inpath + "temp/fscript"));
|
||||||
AudioTrack at = tracklist.get(i);
|
PrintStream ps = new PrintStream(fos);
|
||||||
String trackno = String.format("%02d", i);
|
ps.println("fscript 1");
|
||||||
new File(Main.inpath + "temp/data/audio/music/" + trackno).mkdirs();
|
ps.println("# AUTOGENERATED BY FIRESTAR");
|
||||||
if (at.path.getName().endsWith(".at9")) {
|
for (int i = 0; i < tracklist.size(); i++) {
|
||||||
progressDialog.setText("Copying track " + (i+1) + " out of " + tracklist.size() + "...");
|
AudioTrack at = tracklist.get(i);
|
||||||
try {
|
String trackno = String.format("%02d", i+1);
|
||||||
// Assume whoever made the AT9s knows what they're doing
|
new File(Main.inpath + "temp/data/audio/music/" + trackno).mkdirs();
|
||||||
System.out.println("Copying track #" + (i+1) + " \"" + at.title + " - " + at.artist + "\"...");
|
if (at.path.getName().endsWith(".at9")) {
|
||||||
Files.copy(at.path.toPath(), Paths.get(Main.inpath + "tmp/data/audio/music/" + trackno + "/music_stereo.at9"), StandardCopyOption.REPLACE_EXISTING);
|
progressDialog.setText("Copying track " + (i+1) + " out of " + tracklist.size() + "...");
|
||||||
} catch (IOException ex) {
|
try {
|
||||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
// Assume whoever made the AT9s knows what they're doing
|
||||||
|
System.out.println("Copying track #" + (i+1) + " \"" + at.artist + " - " + at.title + "\"...");
|
||||||
|
Files.copy(at.path.toPath(), Paths.get(Main.inpath + "tmp/data/audio/music/" + trackno + "/music_stereo.at9"), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
progressDialog.setText("Encoding track " + (i+1) + " out of " + tracklist.size() + "...");
|
||||||
|
try {
|
||||||
|
System.out.println("Encoding track #" + (i+1) + " \"" + at.artist + " - " + at.title + "\"...");
|
||||||
|
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", at.path.getPath(), "data/audio/music/" + trackno + "/music_stereo.at9"}, Main.inpath + "temp/");
|
||||||
|
p.waitFor();
|
||||||
|
} catch (IOException | InterruptedException ex) {
|
||||||
|
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
String ocmd = "modify";
|
||||||
progressDialog.setText("Encoding track " + (i+1) + " out of " + tracklist.size() + "...");
|
if (i >= 12) ocmd = "create";
|
||||||
|
ps.println("file \"data/plugins/languages/american/entries.xml\" xml "+ocmd+" StringTable.entry#MT_"+trackno+" set attribute \"string\" \""+at.artist.replace("\"", "\\\"")+"\\n"+at.title.replace("\"", "\\\"")+"\"");
|
||||||
|
ps.println("file \"data/audio/music/"+trackno+"/music_stereo.fft\" delete");
|
||||||
|
progressDialog.setProgressValue(i+1);
|
||||||
|
}
|
||||||
|
for (int s = tracklist.size(); s < 12; s++) {
|
||||||
|
ps.println("file \"data/audio/music/"+String.format("%02d", s+1)+"/music_stereo.fft\" delete");
|
||||||
|
}
|
||||||
|
if (sptrack != null) {
|
||||||
|
progressDialog.setText("Encoding singleplayer frontend track...");
|
||||||
|
if (sptrack.exists()) {
|
||||||
|
try {
|
||||||
|
System.out.println("Encoding singleplayer frontend track...");
|
||||||
|
new File(Main.inpath + "temp/data/audio/music/FEMusic").mkdirs();
|
||||||
|
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", sptrack.getPath(), "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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ps.println("file \"data/audio/music/FEMusic/frontend_stereo.fft\" delete");
|
||||||
|
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||||
|
}
|
||||||
|
if (mptrack != null) {
|
||||||
|
progressDialog.setText("Encoding multiplayer frontend track...");
|
||||||
try {
|
try {
|
||||||
System.out.println("Encoding track #" + (i+1) + " \"" + at.title + " - " + at.artist + "\"...");
|
assert(mptrack.exists());
|
||||||
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", at.path.getPath(), "data/audio/music/" + trackno + "/music_stereo.at9"}, Main.inpath + "temp/");
|
System.out.println("Encoding multiplayer frontend track...");
|
||||||
|
new File(Main.inpath + "temp/data/audio/music/FEDemoMusic").mkdirs();
|
||||||
|
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", mptrack.getPath(), "data/audio/music/FEDemoMusic/frontend_stereo.at9"}, System.getProperty("user.home") + "/.firestar/temp/");
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
} catch (IOException | InterruptedException ex) {
|
} catch (IOException | InterruptedException ex) {
|
||||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
ps.println("file \"data/audio/music/FEDemoMusic/frontend_stereo.fft\" delete");
|
||||||
|
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||||
}
|
}
|
||||||
progressDialog.setProgressValue(i+1);
|
System.out.println("Finished encoding.");
|
||||||
}
|
|
||||||
if (sptrack != null) {
|
progressDialog.setText("Generating Music Definitions...");
|
||||||
progressDialog.setText("Encoding singleplayer frontend track...");
|
|
||||||
if (sptrack.exists()) {
|
|
||||||
try {
|
|
||||||
System.out.println("Encoding singleplayer frontend track...");
|
|
||||||
new File(Main.inpath + "temp/data/audio/music/FEMusic").mkdirs();
|
|
||||||
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", sptrack.getPath(), "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 {
|
try {
|
||||||
assert(mptrack.exists());
|
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
||||||
System.out.println("Encoding multiplayer frontend track...");
|
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
||||||
new File(Main.inpath + "temp/data/audio/music/FEDemoMusic").mkdirs();
|
|
||||||
Process p = Main.exec(new String[]{Main.inpath + "at9tool.exe", "-e", "-br", "144", mptrack.getPath(), "data/audio/music/FEDemoMusic/frontend_stereo.at9"}, System.getProperty("user.home") + "/.firestar/temp/");
|
Document defDoc = docBuilder.newDocument();
|
||||||
p.waitFor();
|
Element docScreen = defDoc.createElement("Screen");
|
||||||
} catch (IOException | InterruptedException ex) {
|
docScreen.setAttribute("name", "Top");
|
||||||
|
for (int i = 0; i < tracklist.size(); i++) { // TODO: support for additive
|
||||||
|
AudioTrack at = tracklist.get(i);
|
||||||
|
String trackno = String.format("%02d", i+1);
|
||||||
|
|
||||||
|
Element trackElem = defDoc.createElement("PI_Music");
|
||||||
|
trackElem.setAttribute("name", trackno);
|
||||||
|
|
||||||
|
Element pathElem = defDoc.createElement("Values");
|
||||||
|
pathElem.setAttribute("location", "data\\audio\\music\\"+trackno);
|
||||||
|
trackElem.appendChild(pathElem);
|
||||||
|
|
||||||
|
Element artistElem = defDoc.createElement("Entry");
|
||||||
|
artistElem.setAttribute("Artist", at.artist);
|
||||||
|
trackElem.appendChild(artistElem);
|
||||||
|
|
||||||
|
Element titleElem = defDoc.createElement("Entry");
|
||||||
|
titleElem.setAttribute("Label", at.title);
|
||||||
|
trackElem.appendChild(titleElem);
|
||||||
|
|
||||||
|
docScreen.appendChild(trackElem);
|
||||||
|
System.out.println("Adding \"" + trackno + ". " + at.artist + " - " + at.title + "\" to Definition.xml");
|
||||||
|
}
|
||||||
|
defDoc.appendChild(docScreen);
|
||||||
|
|
||||||
|
new File(Main.inpath + "temp/data/plugins/music/").mkdirs();
|
||||||
|
FileOutputStream output = new FileOutputStream(Main.inpath + "temp/data/plugins/music/Definition.xml");
|
||||||
|
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||||
|
Transformer transformer = transformerFactory.newTransformer();
|
||||||
|
DOMSource source = new DOMSource(defDoc);
|
||||||
|
StreamResult result = new StreamResult(output);
|
||||||
|
|
||||||
|
transformer.transform(source, result);
|
||||||
|
} catch (IOException | ParserConfigurationException | TransformerException ex) {
|
||||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||||
}
|
|
||||||
System.out.println("Finished encoding.");
|
|
||||||
|
|
||||||
progressDialog.setText("Generating Music Definitions...");
|
|
||||||
try {
|
|
||||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
|
||||||
|
|
||||||
Document defDoc = docBuilder.newDocument();
|
progressDialog.setText("Finalizing script...");
|
||||||
Element docScreen = defDoc.createElement("Screen");
|
System.out.println("Finalizing Fscript...");
|
||||||
docScreen.setAttribute("name", "Top");
|
ps.println("# END FIRESTAR AUTOGENERATION");
|
||||||
for (int i = 0; i < tracklist.size(); i++) { // TODO: support for additive
|
ps.close();
|
||||||
AudioTrack at = tracklist.get(i);
|
fos.close();
|
||||||
String trackno = String.format("%02d", i);
|
} catch (IOException ex) {
|
||||||
|
|
||||||
Element trackElem = defDoc.createElement("PI_Music");
|
|
||||||
trackElem.setAttribute("name", trackno);
|
|
||||||
|
|
||||||
Element pathElem = defDoc.createElement("Values");
|
|
||||||
pathElem.setAttribute("location", "data\\audio\\music\\"+trackno);
|
|
||||||
trackElem.appendChild(pathElem);
|
|
||||||
|
|
||||||
Element artistElem = defDoc.createElement("Entry");
|
|
||||||
artistElem.setAttribute("Artist", at.artist);
|
|
||||||
trackElem.appendChild(artistElem);
|
|
||||||
|
|
||||||
Element titleElem = defDoc.createElement("Entry");
|
|
||||||
titleElem.setAttribute("Label", at.title);
|
|
||||||
trackElem.appendChild(titleElem);
|
|
||||||
|
|
||||||
docScreen.appendChild(trackElem);
|
|
||||||
System.out.println("Adding \"" + trackno + ". " + at.artist + " - " + at.title + "\" to Definition.xml");
|
|
||||||
}
|
|
||||||
defDoc.appendChild(docScreen);
|
|
||||||
|
|
||||||
new File(Main.inpath + "temp/data/plugins/music/").mkdirs();
|
|
||||||
FileOutputStream output = new FileOutputStream(Main.inpath + "temp/data/plugins/music/Definition.xml");
|
|
||||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
|
||||||
Transformer transformer = transformerFactory.newTransformer();
|
|
||||||
DOMSource source = new DOMSource(defDoc);
|
|
||||||
StreamResult result = new StreamResult(output);
|
|
||||||
|
|
||||||
transformer.transform(source, result);
|
|
||||||
} catch (IOException | ParserConfigurationException | TransformerException ex) {
|
|
||||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
|
||||||
|
|
||||||
progressDialog.setText("Localizing...");
|
|
||||||
System.out.println("Creating localization edits for music tracks...");
|
|
||||||
// TODO: Actually do what the above print-out says
|
|
||||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||||
|
|
||||||
progressDialog.destroyDialog();
|
progressDialog.destroyDialog();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user