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<float>> tempoChgs { get; private set; }
|
||||||
public SortedList<float, NoteEvent<int>> events { get; private set; }
|
public SortedList<float, NoteEvent<int>> events { get; private set; }
|
||||||
|
|
||||||
public Chart()
|
public Chart(string chartPath)
|
||||||
{
|
{
|
||||||
doneLoading = false;
|
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
|
// 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<float> tempo = new List<float>();
|
||||||
List<int> tempoChangeMeasures = new List<int>();
|
List<int> tempoChangeMeasures = new List<int>();
|
||||||
@@ -56,8 +72,8 @@ namespace WacK.Data.Chart
|
|||||||
|
|
||||||
Note prevNote = null;
|
Note prevNote = null;
|
||||||
Note curNote = null;
|
Note curNote = null;
|
||||||
var prevHoldPoint = new System.Collections.Generic.Dictionary<int, NotePlay>(); // <note idx, previous point of hold>
|
var prevHoldPoint = new Dictionary<int, NotePlay>(); // <note idx, previous point of hold>
|
||||||
var curHoldNote = new System.Collections.Generic.Dictionary<int, NoteHold>(); // <next hold idx, HoldStart>
|
var curHoldNote = new Dictionary<int, NoteHold>(); // <next hold idx, HoldStart>
|
||||||
|
|
||||||
// Notes and Events //
|
// Notes and Events //
|
||||||
foreach (var measure in chart.notes) // `measure` = measure: List
|
foreach (var measure in chart.notes) // `measure` = measure: List
|
||||||
@@ -112,7 +128,8 @@ namespace WacK.Data.Chart
|
|||||||
var de = int.Parse(words[1]);
|
var de = int.Parse(words[1]);
|
||||||
if (beatsPerMeasure.Count == 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);
|
bpmChangeMeasures.Add(measure.Key);
|
||||||
}
|
}
|
||||||
else
|
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)
|
: base(time, measureBeat, position, size,holdIndex, holdNext, type: NotePlayType.HoldStart, bonus: false)
|
||||||
{
|
{
|
||||||
// points = (SortedList<float, Note>)holdPoints.Skip(1);
|
// points = (SortedList<float, Note>)holdPoints.Skip(1);
|
||||||
|
points = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
namespace WacK.Data.Mer
|
namespace WacK.Data.Mer
|
||||||
{
|
{
|
||||||
@@ -133,7 +134,8 @@ namespace WacK.Data.Mer
|
|||||||
notes[currentMeasure].Add((currentBeat, new MerNote(value: tokens[3], type: MerType.Tempo)));
|
notes[currentMeasure].Add((currentBeat, new MerNote(value: tokens[3], type: MerType.Tempo)));
|
||||||
break;
|
break;
|
||||||
case "3": // beats per measure
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using WacK.Data.Chart;
|
||||||
|
using WacK.Data.Mer;
|
||||||
|
|
||||||
namespace WacK.Scenes
|
namespace WacK.Scenes
|
||||||
{
|
{
|
||||||
@@ -22,11 +24,12 @@ namespace WacK.Scenes
|
|||||||
// initialized by another scene, BEFORE loading this one!
|
// initialized by another scene, BEFORE loading this one!
|
||||||
public static PlayParameters playParams;
|
public static PlayParameters playParams;
|
||||||
|
|
||||||
private void Start()
|
private Chart chart;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
chart = new(playParams.chartPath);
|
||||||
|
}
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
playParams = null;
|
playParams = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user