diff options
author | Orangerot <purple@orangerot.dev> | 2025-01-07 06:38:34 +0100 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2025-01-07 06:38:34 +0100 |
commit | 9c229b94d0aa52679e12e50d62aa8e6cbf9fb9c5 (patch) | |
tree | c148c6ee4bbf664be3f1a64f9c9501f00b38edf2 /lib/level.dart | |
parent | 685323adeab3d27bff4df16a201f9f14688475d5 (diff) |
style: refactored searching files into Simfile class
Diffstat (limited to 'lib/level.dart')
-rw-r--r-- | lib/level.dart | 16 |
1 files changed, 6 insertions, 10 deletions
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<Level> createState() => _LevelState(); @@ -25,7 +25,6 @@ class InputDirection { class _LevelState extends State<Level> { final player = AudioPlayer(); - Simfile? simfile; bool _isPlaying = true; Duration? _duration; Duration? _position; @@ -77,7 +76,7 @@ class _LevelState extends State<Level> { 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<Level> { } }); - 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<Level> { 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<Level> { } }, ), - title: Text(widget.stepmaniaFolderPath.split('/').last), + title: Text(widget.simfile.tags['TITLE']!), actions: [ IconButton( icon: Icon(Icons.close), |