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();
|
||||||
|
FileOutputStream fos = new FileOutputStream(new File(Main.inpath + "temp/fscript"));
|
||||||
|
PrintStream ps = new PrintStream(fos);
|
||||||
|
ps.println("fscript 1");
|
||||||
|
ps.println("# AUTOGENERATED BY FIRESTAR");
|
||||||
|
for (int i = 0; i < tracklist.size(); i++) {
|
||||||
|
AudioTrack at = tracklist.get(i);
|
||||||
|
String trackno = String.format("%02d", i+1);
|
||||||
|
new File(Main.inpath + "temp/data/audio/music/" + trackno).mkdirs();
|
||||||
|
if (at.path.getName().endsWith(".at9")) {
|
||||||
|
progressDialog.setText("Copying track " + (i+1) + " out of " + tracklist.size() + "...");
|
||||||
|
try {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String ocmd = "modify";
|
||||||
|
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 {
|
||||||
|
assert(mptrack.exists());
|
||||||
|
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();
|
||||||
|
} catch (IOException | InterruptedException 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);
|
||||||
|
}
|
||||||
|
System.out.println("Finished encoding.");
|
||||||
|
|
||||||
for (int i = 0; i < tracklist.size(); i++) {
|
progressDialog.setText("Generating Music Definitions...");
|
||||||
AudioTrack at = tracklist.get(i);
|
|
||||||
String trackno = String.format("%02d", i);
|
|
||||||
new File(Main.inpath + "temp/data/audio/music/" + trackno).mkdirs();
|
|
||||||
if (at.path.getName().endsWith(".at9")) {
|
|
||||||
progressDialog.setText("Copying track " + (i+1) + " out of " + tracklist.size() + "...");
|
|
||||||
try {
|
|
||||||
// Assume whoever made the AT9s knows what they're doing
|
|
||||||
System.out.println("Copying track #" + (i+1) + " \"" + at.title + " - " + at.artist + "\"...");
|
|
||||||
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.title + " - " + at.artist + "\"...");
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
progressDialog.setProgressValue(i+1);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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...");
|
progressDialog.setText("Finalizing script...");
|
||||||
try {
|
System.out.println("Finalizing Fscript...");
|
||||||
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
|
ps.println("# END FIRESTAR AUTOGENERATION");
|
||||||
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
|
ps.close();
|
||||||
|
fos.close();
|
||||||
Document defDoc = docBuilder.newDocument();
|
} catch (IOException ex) {
|
||||||
Element docScreen = defDoc.createElement("Screen");
|
|
||||||
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);
|
|
||||||
|
|
||||||
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