Soundtrack now uses index file's name

Closes #3.
Also removed combineStartFile since it's not used by any arguments for
simplicity's sake.
This commit is contained in:
Villermen 2014-11-21 23:27:09 +01:00
parent 8b6fe66102
commit 0186cb158d

View file

@ -21,7 +21,7 @@ namespace RSCacheTool
bool error = false; bool error = false;
bool help = false, extract = false, combine = false, overwrite = false, combineMergeIncomplete = false; bool help = false, extract = false, combine = false, overwrite = false, combineMergeIncomplete = false;
int extractArchive = -1, combineArchive = 40, combineStartFile = 0; int extractArchive = -1, combineArchive = 40;
OptionSet argsParser = new OptionSet() { OptionSet argsParser = new OptionSet() {
{ "h", "show this message", val => { help = true; } }, { "h", "show this message", val => { help = true; } },
@ -81,7 +81,7 @@ namespace RSCacheTool
ExtractFiles(extractArchive, overwrite); ExtractFiles(extractArchive, overwrite);
if (combine) if (combine)
CombineSounds(combineArchive, combineStartFile, overwrite, combineMergeIncomplete); CombineSounds(combineArchive, overwrite, combineMergeIncomplete);
} }
return 0; return 0;
@ -323,26 +323,21 @@ namespace RSCacheTool
/// <summary> /// <summary>
/// Combines the sound files (.jag &amp; .ogg) in the specified archive (40 for the build it was made on), and puts them into the soundtracks directory. /// Combines the sound files (.jag &amp; .ogg) in the specified archive (40 for the build it was made on), and puts them into the soundtracks directory.
/// </summary> /// </summary>
static void CombineSounds(int archive, int startFile, bool overwriteExisting, bool mergeIncomplete) static void CombineSounds(int archive, bool overwriteExisting, bool mergeIncomplete)
{ {
string archiveDir = outDir + archive + "\\"; string archiveDir = outDir + archive + "\\";
string soundDir = outDir + "sound\\"; string soundDir = outDir + "sound\\";
//gather all index files //gather all index files
string[] indexFiles = Directory.GetFiles(archiveDir, "*.jag", SearchOption.TopDirectoryOnly); string[] indexFiles = Directory.GetFiles(archiveDir, "*.jaga", SearchOption.TopDirectoryOnly);
//create directories //create directories
if (!Directory.Exists(soundDir + "incomplete\\")) if (!Directory.Exists(soundDir + "incomplete\\"))
Directory.CreateDirectory(soundDir + "incomplete\\"); Directory.CreateDirectory(soundDir + "incomplete\\");
int i = 0;
foreach (string indexFileString in indexFiles) foreach (string indexFileString in indexFiles)
{ {
if (i < startFile) string indexFileIdString = Path.GetFileNameWithoutExtension(indexFileString);
{
i++;
continue;
}
bool incomplete = false; bool incomplete = false;
List<string> chunkFiles = new List<string>(); List<string> chunkFiles = new List<string>();
@ -385,7 +380,7 @@ namespace RSCacheTool
if (!incomplete || incomplete && mergeIncomplete) if (!incomplete || incomplete && mergeIncomplete)
{ {
string outFile = soundDir + (incomplete ? "incomplete\\" : "") + i + ".ogg"; string outFile = soundDir + (incomplete ? "incomplete\\" : "") + indexFileIdString + ".ogg";
if (!overwriteExisting && File.Exists(outFile)) if (!overwriteExisting && File.Exists(outFile))
Console.WriteLine("Skipping track because it already exists."); Console.WriteLine("Skipping track because it already exists.");
@ -402,7 +397,7 @@ namespace RSCacheTool
{ {
soxProcess.StartInfo.Arguments += " " + str; soxProcess.StartInfo.Arguments += " " + str;
}); });
soxProcess.StartInfo.Arguments += " " + soundDir + "incomplete\\" + i + ".ogg "; soxProcess.StartInfo.Arguments += " " + soundDir + "incomplete\\" + indexFileIdString + ".ogg ";
soxProcess.StartInfo.UseShellExecute = false; soxProcess.StartInfo.UseShellExecute = false;
soxProcess.Start(); soxProcess.Start();
@ -413,13 +408,13 @@ namespace RSCacheTool
if (!incomplete) if (!incomplete)
{ {
//clear space //clear space
if (File.Exists(soundDir + i + ".ogg")) if (File.Exists(outFile))
File.Delete(soundDir + i + ".ogg"); File.Delete(outFile);
File.Move(soundDir + "incomplete\\" + i + ".ogg", soundDir + i + ".ogg"); File.Move(soundDir + "incomplete\\" + indexFileIdString + ".ogg", outFile);
} }
Console.WriteLine(soundDir + (incomplete ? "incomplete\\" : "") + i + ".ogg"); Console.WriteLine(outFile);
} }
else else
Console.WriteLine("SoX encountered error code " + soxProcess.ExitCode + " and probably didn't finish processing the files."); Console.WriteLine("SoX encountered error code " + soxProcess.ExitCode + " and probably didn't finish processing the files.");
@ -427,8 +422,6 @@ namespace RSCacheTool
} }
else else
Console.WriteLine("Skipping track because it's incomplete."); Console.WriteLine("Skipping track because it's incomplete.");
i++;
} }
//cleanup on isle 4 //cleanup on isle 4