fix chart parsing
This commit is contained in:
@@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
namespace WacK.Data.Mer
|
||||
{
|
||||
@@ -133,7 +134,8 @@ namespace WacK.Data.Mer
|
||||
notes[currentMeasure].Add((currentBeat, new MerNote(value: tokens[3], type: MerType.Tempo)));
|
||||
break;
|
||||
case "3": // beats per measure
|
||||
notes[currentMeasure].Add((currentBeat, new MerNote(value: $"{tokens[3]} {tokens[4]}", type: MerType.TimeSignature)));
|
||||
string de = tokens.Count >= 5 ? tokens[4] : "4"; // TODO: use previously-estbalished denominator?
|
||||
notes[currentMeasure].Add((currentBeat, new MerNote(value: $"{tokens[3]} {de}", type: MerType.TimeSignature)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user