From 9c229b94d0aa52679e12e50d62aa8e6cbf9fb9c5 Mon Sep 17 00:00:00 2001 From: Orangerot Date: Tue, 7 Jan 2025 06:38:34 +0100 Subject: style: refactored searching files into Simfile class --- lib/level.dart | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'lib/level.dart') diff --git a/lib/level.dart b/lib/level.dart index cc17efb..e896615 100644 --- a/lib/level.dart +++ b/lib/level.dart @@ -9,8 +9,8 @@ import 'package:sense_the_rhythm/game_over_stats.dart'; import 'package:sense_the_rhythm/simfile.dart'; class Level extends StatefulWidget { - const Level({super.key, required this.stepmaniaFolderPath}); - final String stepmaniaFolderPath; + const Level(this.simfile, {super.key}); + final Simfile simfile; @override State createState() => _LevelState(); @@ -25,7 +25,6 @@ class InputDirection { class _LevelState extends State { final player = AudioPlayer(); - Simfile? simfile; bool _isPlaying = true; Duration? _duration; Duration? _position; @@ -77,7 +76,7 @@ class _LevelState extends State { player.onPlayerComplete.listen((void _) { Route route = MaterialPageRoute( builder: (context) => GameOverStats( - simfile: simfile!, + simfile: widget.simfile, notes: notes, )); Navigator.pushReplacement(context, route); @@ -131,10 +130,7 @@ class _LevelState extends State { } }); - simfile = Simfile(widget.stepmaniaFolderPath); - simfile!.load(); - - simfile!.chartSimplest!.beats.forEach((time, noteData) { + widget.simfile.chartSimplest!.beats.forEach((time, noteData) { int arrowIndex = noteData.indexOf('1'); if (arrowIndex < 0 || arrowIndex > 3) { return; @@ -142,7 +138,7 @@ class _LevelState extends State { notes.add(Note(time: time, direction: ArrowDirection.values[arrowIndex])); }); - player.play(DeviceFileSource(simfile!.audioPath!)); + player.play(DeviceFileSource(widget.simfile.audioPath!)); } @override @@ -192,7 +188,7 @@ class _LevelState extends State { } }, ), - title: Text(widget.stepmaniaFolderPath.split('/').last), + title: Text(widget.simfile.tags['TITLE']!), actions: [ IconButton( icon: Icon(Icons.close), -- cgit v1.2.3