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.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
@ -156,7 +158,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
AudioTrack at = tracklist.get(curIndex);
|
||||
fTitle.setText(at.title);
|
||||
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");
|
||||
} else {
|
||||
fTitle.setText("");
|
||||
|
@ -285,17 +287,21 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
progressDialog.setProgressMax(progressSize);
|
||||
progressDialog.setProgressValue(0);
|
||||
|
||||
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);
|
||||
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.title + " - " + at.artist + "\"...");
|
||||
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);
|
||||
|
@ -303,15 +309,22 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
} else {
|
||||
progressDialog.setText("Encoding track " + (i+1) + " out of " + tracklist.size() + "...");
|
||||
try {
|
||||
System.out.println("Encoding track #" + (i+1) + " \"" + at.title + " - " + at.artist + "\"...");
|
||||
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()) {
|
||||
|
@ -324,6 +337,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
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) {
|
||||
|
@ -337,6 +351,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
} 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.");
|
||||
|
@ -351,7 +366,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
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);
|
||||
String trackno = String.format("%02d", i+1);
|
||||
|
||||
Element trackElem = defDoc.createElement("PI_Music");
|
||||
trackElem.setAttribute("name", trackno);
|
||||
|
@ -386,9 +401,15 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
|||
}
|
||||
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.setText("Finalizing script...");
|
||||
System.out.println("Finalizing Fscript...");
|
||||
ps.println("# END FIRESTAR AUTOGENERATION");
|
||||
ps.close();
|
||||
fos.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Suggs.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
progressDialog.setProgressValue(progressDialog.getProgressValue()+1);
|
||||
|
||||
progressDialog.destroyDialog();
|
||||
|
|
Loading…
Reference in New Issue
Block a user