summaryrefslogtreecommitdiff
path: root/lib/level.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/level.dart')
-rw-r--r--lib/level.dart16
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),