fix chart parsing

This commit is contained in:
muskit
2023-09-15 12:00:12 -07:00
parent 002ff7b1ff
commit 41d2576e58
4 changed files with 35 additions and 12 deletions
+24 -7
View File
@@ -21,15 +21,31 @@ namespace WacK.Data.Chart
public SortedList<float, NoteEvent<float>> tempoChgs { get; private set; }
public SortedList<float, NoteEvent<int>> events { get; private set; }
public Chart()
public Chart(string chartPath)
{
doneLoading = false;
var file = FileAccess.Open(chartPath, FileAccess.ModeFlags.Read);
if (file == null)
{
GD.PrintErr("Couldn't load chart in play!");
return;
}
var str = file.GetAsText();
file.Close();
var mer = new Mer.Mer(str);
Load(mer);
doneLoading = true;
}
// place notes and events relative to the previous
public void Load(Mer.Mer chart)
private void Load(Mer.Mer chart)
{
playNotes = new SortedList<float, List<NotePlay>>();
playNotes = new();
timeSigChgs = new();
tempoChgs = new();
events = new();
List<float> tempo = new List<float>();
List<int> tempoChangeMeasures = new List<int>();
@@ -56,8 +72,8 @@ namespace WacK.Data.Chart
Note prevNote = null;
Note curNote = null;
var prevHoldPoint = new System.Collections.Generic.Dictionary<int, NotePlay>(); // <note idx, previous point of hold>
var curHoldNote = new System.Collections.Generic.Dictionary<int, NoteHold>(); // <next hold idx, HoldStart>
var prevHoldPoint = new Dictionary<int, NotePlay>(); // <note idx, previous point of hold>
var curHoldNote = new Dictionary<int, NoteHold>(); // <next hold idx, HoldStart>
// Notes and Events //
foreach (var measure in chart.notes) // `measure` = measure: List
@@ -112,7 +128,8 @@ namespace WacK.Data.Chart
var de = int.Parse(words[1]);
if (beatsPerMeasure.Count == 1)
{
beatsPerMeasure.Add(int.Parse(chartNote.Item2.value));
// TODO: handle denominator (note that gets the beat)
beatsPerMeasure.Add(nu);
bpmChangeMeasures.Add(measure.Key);
}
else
@@ -327,7 +344,7 @@ namespace WacK.Data.Chart
// }
// }
doneLoading = true;
GD.Print("Finished forming Chart!");
}
}
}
+1
View File
@@ -15,6 +15,7 @@ namespace WacK.Data.Chart
: base(time, measureBeat, position, size,holdIndex, holdNext, type: NotePlayType.HoldStart, bonus: false)
{
// points = (SortedList<float, Note>)holdPoints.Skip(1);
points = new();
}
}
}