79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using Manager;
|
|
using MoreChartFormats.MaiSxt.Structures;
|
|
|
|
namespace MoreChartFormats.MaiSxt;
|
|
|
|
public class SrtReader(NotesReferences refs) : SxtReaderBase(refs)
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
protected override void LoadRow(int rowIdx, in SxtRow row)
|
|
{
|
|
var rowTime = row.NotesTime(Refs.Reader);
|
|
var note = new NoteData
|
|
{
|
|
type = row.NoteType switch
|
|
{
|
|
0 when row.SlideId != 0 => NotesTypeID.Def.Star,
|
|
0 => NotesTypeID.Def.Tap,
|
|
2 => NotesTypeID.Def.Hold,
|
|
4 when row.SlideId != 0 => NotesTypeID.Def.BreakStar,
|
|
4 => NotesTypeID.Def.Break,
|
|
128 => NotesTypeID.Def.Slide,
|
|
_ => throw new Exception($"Unknown note type ID {row.NoteType} at row {rowIdx}, expected 0/2/4/128")
|
|
},
|
|
startButtonPos = row.Position,
|
|
time = rowTime,
|
|
end = rowTime,
|
|
beatType = ParserUtilities.GetBeatType(rowTime.grid),
|
|
index = rowIdx,
|
|
indexNote = NoteIndex
|
|
};
|
|
|
|
if (note.type.isHold())
|
|
{
|
|
note.end += ParserUtilities.NotesTimeFromBars(Refs, row.HoldDuration);
|
|
note.end.calcMsec(Refs.Reader);
|
|
}
|
|
|
|
if (note.type.isSlide())
|
|
{
|
|
if (!SlideHeads.TryGetValue(row.SlideId, out var starNoteRow))
|
|
{
|
|
throw new Exception($"Slide body (ID {row.SlideId}) declared without or before its head");
|
|
}
|
|
|
|
note.startButtonPos = starNoteRow.Position;
|
|
note.slideData = new SlideData
|
|
{
|
|
type = row.SlidePattern switch
|
|
{
|
|
0 => SlideType.Slide_Straight,
|
|
1 => SlideType.Slide_Circle_R,
|
|
2 => SlideType.Slide_Circle_L,
|
|
_ => throw new Exception($"Unknown slide type {row.SlidePattern} at row {rowIdx}, expected 0/1/2"),
|
|
},
|
|
index = row.SlideId,
|
|
targetNote = row.Position,
|
|
shoot = new TimingBase { index = rowIdx },
|
|
arrive = new TimingBase { index = rowIdx },
|
|
};
|
|
|
|
note.time = starNoteRow.NotesTime(Refs.Reader);
|
|
note.beatType = ParserUtilities.GetBeatType(note.time.grid);
|
|
note.slideData.shoot.time = note.time + starNoteRow.SlideDelayNotesTime(Refs);
|
|
note.slideData.shoot.time.calcMsec(Refs.Reader);
|
|
note.slideData.arrive.time.copy(rowTime);
|
|
note.end.copy(rowTime);
|
|
}
|
|
|
|
if (note.type.isStar())
|
|
{
|
|
SlideHeads[row.SlideId] = row;
|
|
}
|
|
|
|
Refs.Notes._noteData.Add(note);
|
|
NoteIndex++;
|
|
}
|
|
} |