From f577670d7564b24dfe8cc247459670a2d7ef5bab Mon Sep 17 00:00:00 2001 From: Orangerot Date: Sun, 29 Dec 2024 16:49:42 +0100 Subject: style: refactored time offset generation of beat inside of Simfile class --- lib/level.dart | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'lib/level.dart') diff --git a/lib/level.dart b/lib/level.dart index 548a752..a6d4967 100644 --- a/lib/level.dart +++ b/lib/level.dart @@ -125,24 +125,13 @@ class _LevelState extends State { simfile = Simfile(simfilePath); simfile!.load(); - double bpm = simfile!.bpms.entries.first.value; - - for (final (measureIndex, measure) - in simfile!.chartSimplest!.measures!.indexed) { - for (final (noteIndex, noteData) in measure.indexed) { - int arrowIndex = noteData.indexOf('1'); - if (arrowIndex < 0 || arrowIndex > 3) { - continue; - } - double beat = - measureIndex * 4.0 + (noteIndex.toDouble() / measure.length) * 4.0; - double minutesPerBeat = 1.0 / bpm; - double offsetMinutes = simfile!.offset / 60.0; - notes.add(Note( - time: beat * minutesPerBeat + offsetMinutes, - direction: ArrowDirection.values[arrowIndex])); + simfile!.chartSimplest!.beats.forEach((time, noteData) { + int arrowIndex = noteData.indexOf('1'); + if (arrowIndex < 0 || arrowIndex > 3) { + return; } - } + notes.add(Note(time: time, direction: ArrowDirection.values[arrowIndex])); + }); print(audioPath); -- cgit v1.2.3