branches and empty courses detector
This commit is contained in:
parent
576542129d
commit
9e2013b71e
@ -13,10 +13,20 @@ namespace TaikoSoundEditor.Data
|
||||
public byte[] Wav { get; set; }
|
||||
|
||||
public byte[] EBin { get; set; }
|
||||
public byte[] EBin1 { get; set; }
|
||||
public byte[] EBin2 { get; set; }
|
||||
public byte[] HBin { get; set; }
|
||||
public byte[] HBin1 { get; set; }
|
||||
public byte[] HBin2 { get; set; }
|
||||
public byte[] MBin { get; set; }
|
||||
public byte[] MBin1 { get; set; }
|
||||
public byte[] MBin2 { get; set; }
|
||||
public byte[] NBin { get; set; }
|
||||
public byte[] NBin1 { get; set; }
|
||||
public byte[] NBin2 { get; set; }
|
||||
public byte[] XBin { get; set; }
|
||||
public byte[] XBin1 { get; set; }
|
||||
public byte[] XBin2 { get; set; }
|
||||
|
||||
public byte[] Nus3Bank { get; set; }
|
||||
|
||||
|
88
MainForm.cs
88
MainForm.cs
@ -161,6 +161,7 @@ namespace TaikoSoundEditor
|
||||
{
|
||||
MessageBox.Show(e.Message, "An error has occured");
|
||||
Logger.Error(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
#region Editor
|
||||
@ -311,11 +312,48 @@ namespace TaikoSoundEditor
|
||||
return l;
|
||||
}).ToArray();
|
||||
|
||||
var missingCourses = new int[] { 0, 1, 2, 3 }.Where(i => !tja.Courses.Keys.Contains(i)).ToArray();
|
||||
var courseNames = new string[] { "Easy", "Normal", "Hard", "Oni" };
|
||||
|
||||
if (missingCourses.Length > 0)
|
||||
{
|
||||
|
||||
var caption = $"There are missing courses in the TJA file for difficulties: {string.Join(", ", missingCourses.Select(i => courseNames[i]))}.\n" +
|
||||
$"Do you want to add a placeholder for the missing courses?";
|
||||
|
||||
if (MessageBox.Show(caption, "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
foreach (var difficulty in missingCourses)
|
||||
{
|
||||
text = text.Concat(new string[]
|
||||
{
|
||||
"",
|
||||
$"COURSE:{courseNames[difficulty]}",
|
||||
"LEVEL:1",
|
||||
"BALLOON:",
|
||||
"SCOREINIT:",
|
||||
"SCOREDIFF:",
|
||||
"#START",
|
||||
"1",
|
||||
"#END"
|
||||
}).ToArray();
|
||||
|
||||
tja.Courses[difficulty] = new TJA.Course(difficulty, new TJA.CourseHeader(), new List<TJA.Measure>
|
||||
{
|
||||
new TJA.Measure(new int[]{1,1}, new Dictionary<string, bool>(), "1", new List<TJA.MeasureEvent>())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Logger.Info("Creating temporary tja");
|
||||
var newTja = @$".-tmp\{Path.GetFileName(tjaPath)}";
|
||||
File.WriteAllLines(newTja, text);
|
||||
|
||||
|
||||
|
||||
|
||||
FeedbackBox.AppendText("Running tja2fumen\r\n");
|
||||
|
||||
var tja_binaries = TJA.RunTja2Fumen(newTja);
|
||||
@ -331,7 +369,18 @@ namespace TaikoSoundEditor
|
||||
ns.EBin = tja_binaries[0];
|
||||
ns.HBin = tja_binaries[1];
|
||||
ns.MBin = tja_binaries[2];
|
||||
ns.NBin = tja_binaries[3];
|
||||
ns.NBin = tja_binaries[3];
|
||||
|
||||
ns.EBin1 = tja_binaries[5];
|
||||
ns.HBin1 = tja_binaries[6];
|
||||
ns.MBin1 = tja_binaries[7];
|
||||
ns.NBin1 = tja_binaries[8];
|
||||
|
||||
ns.EBin2 = tja_binaries[10];
|
||||
ns.HBin2 = tja_binaries[11];
|
||||
ns.MBin2 = tja_binaries[12];
|
||||
ns.NBin2 = tja_binaries[13];
|
||||
|
||||
|
||||
var selectedMusicInfo = LoadedMusicBox.SelectedItem as MusicInfo;
|
||||
|
||||
@ -360,6 +409,11 @@ namespace TaikoSoundEditor
|
||||
mi.HardOnpuNum = tja.Courses[2].NotesCount;
|
||||
mi.ManiaOnpuNum = tja.Courses[3].NotesCount;
|
||||
|
||||
mi.BranchEasy = tja.Courses[0].HasBranches;
|
||||
mi.BranchNormal = tja.Courses[1].HasBranches;
|
||||
mi.BranchHard = tja.Courses[2].HasBranches;
|
||||
mi.BranchMania = tja.Courses[3].HasBranches;
|
||||
|
||||
mi.StarEasy = tja.Courses[0].Headers.Level;
|
||||
mi.StarNormal = tja.Courses[1].Headers.Level;
|
||||
mi.StarHard = tja.Courses[2].Headers.Level;
|
||||
@ -370,8 +424,8 @@ namespace TaikoSoundEditor
|
||||
FeedbackBox.AppendText("URA course detected\r\n");
|
||||
mi.UraOnpuNum = tja.Courses[4].NotesCount;
|
||||
mi.StarUra = tja.Courses[4].Headers.Level;
|
||||
ma.CanPlayUra = true;
|
||||
|
||||
mi.BranchUra = tja.Courses[4].HasBranches;
|
||||
ma.CanPlayUra = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -398,9 +452,11 @@ namespace TaikoSoundEditor
|
||||
mi.ShinutiUraDuet = (mi.ShinutiScoreUraDuet / mi.UraOnpuNum) / 10 * 10;
|
||||
}
|
||||
|
||||
if(ma.CanPlayUra)
|
||||
if (ma.CanPlayUra)
|
||||
{
|
||||
ns.XBin = tja_binaries[4];
|
||||
ns.XBin1 = tja_binaries[9];
|
||||
ns.XBin2 = tja_binaries[14];
|
||||
}
|
||||
|
||||
mi.SongFileName = $"sound/song_{songName}";
|
||||
@ -552,21 +608,21 @@ namespace TaikoSoundEditor
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_h.bin"), ns.HBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_m.bin"), ns.MBin);
|
||||
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_e_1.bin"), ns.EBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_n_1.bin"), ns.NBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_h_1.bin"), ns.HBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_m_1.bin"), ns.MBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_e_1.bin"), ns.EBin1);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_n_1.bin"), ns.NBin1);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_h_1.bin"), ns.HBin1);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_m_1.bin"), ns.MBin1);
|
||||
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_e_2.bin"), ns.EBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_n_2.bin"), ns.NBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_h_2.bin"), ns.HBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_m_2.bin"), ns.MBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_e_2.bin"), ns.EBin2);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_n_2.bin"), ns.NBin2);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_h_2.bin"), ns.HBin2);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_m_2.bin"), ns.MBin2);
|
||||
|
||||
if(ns.MusicAttribute.CanPlayUra)
|
||||
{
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_x.bin"), ns.XBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_x_1.bin"), ns.XBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_x_2.bin"), ns.XBin);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_x_1.bin"), ns.XBin1);
|
||||
File.WriteAllBytes(Path.Combine(sdir, $"{ns.Id}_x_2.bin"), ns.XBin2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -639,10 +695,10 @@ namespace TaikoSoundEditor
|
||||
var dtpath = Path.Combine(path, "datatable");
|
||||
if (!Directory.Exists(dtpath)) Directory.CreateDirectory(dtpath);
|
||||
|
||||
var nupath = Path.Combine(path, "nus3banks");
|
||||
var nupath = Path.Combine(path, "sound");
|
||||
if (!Directory.Exists(nupath)) Directory.CreateDirectory(nupath);
|
||||
|
||||
var sbpath = Path.Combine(path, "soundsbin");
|
||||
var sbpath = Path.Combine(path, "fumen");
|
||||
if (!Directory.Exists(sbpath)) Directory.CreateDirectory(sbpath);
|
||||
|
||||
ExportDatatable(dtpath);
|
||||
|
36
TJA.cs
36
TJA.cs
@ -117,6 +117,7 @@ namespace TaikoSoundEditor
|
||||
var currentBranch = "N";
|
||||
var targetBranch = "N";
|
||||
var flagLevelhold = false;
|
||||
bool hasBranches = false;
|
||||
|
||||
foreach(var line in lines)
|
||||
{
|
||||
@ -143,9 +144,9 @@ namespace TaikoSoundEditor
|
||||
|
||||
if (line.Name == "BRANCHSTART")
|
||||
{
|
||||
hasBranches = true;
|
||||
if (!flagLevelhold)
|
||||
{
|
||||
|
||||
var values = line.Value.Split(',');
|
||||
if (values[0] == "r")
|
||||
{
|
||||
@ -267,7 +268,7 @@ namespace TaikoSoundEditor
|
||||
measures[measures.Count - 1].Events.Add(ev);
|
||||
}
|
||||
}
|
||||
var c = new Course(course, headers, measures);
|
||||
var c = new Course(course, headers, measures) { HasBranches = hasBranches };
|
||||
Logger.Info($"Course created : {c}");
|
||||
return c;
|
||||
}
|
||||
@ -349,6 +350,8 @@ namespace TaikoSoundEditor
|
||||
public CourseHeader Headers { get; set; }
|
||||
public List<Measure> Measures { get; set; }
|
||||
|
||||
public bool HasBranches { get; set; }
|
||||
|
||||
public Course(int courseN, CourseHeader headers, List<Measure> measures)
|
||||
{
|
||||
CourseN = courseN;
|
||||
@ -464,7 +467,7 @@ namespace TaikoSoundEditor
|
||||
File.ReadAllBytes(Path.Combine(dir, fname + "_e.bin")),
|
||||
File.ReadAllBytes(Path.Combine(dir, fname + "_h.bin")),
|
||||
File.ReadAllBytes(Path.Combine(dir, fname + "_m.bin")),
|
||||
File.ReadAllBytes(Path.Combine(dir, fname + "_n.bin"))
|
||||
File.ReadAllBytes(Path.Combine(dir, fname + "_n.bin"))
|
||||
|
||||
};
|
||||
|
||||
@ -472,12 +475,35 @@ namespace TaikoSoundEditor
|
||||
File.Delete(Path.Combine(dir, fname + "_h.bin"));
|
||||
File.Delete(Path.Combine(dir, fname + "_m.bin"));
|
||||
File.Delete(Path.Combine(dir, fname + "_n.bin"));
|
||||
|
||||
|
||||
if (File.Exists(Path.Combine(dir, fname + "_x.bin")))
|
||||
{
|
||||
{
|
||||
result.Add(File.ReadAllBytes(Path.Combine(dir, fname + "_x.bin")));
|
||||
File.Delete(Path.Combine(dir, fname + "_x.bin"));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(new byte[0]);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
int k = 0;
|
||||
foreach (var d in "ehmnx")
|
||||
{
|
||||
var path = Path.Combine(dir, $"{fname}_{d}_{i}.bin");
|
||||
if(File.Exists(path))
|
||||
{
|
||||
result.Add(File.ReadAllBytes(path));
|
||||
File.Delete(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(result[k].ToArray());
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user