diff options
Diffstat (limited to 'lib/level.dart')
-rw-r--r-- | lib/level.dart | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/level.dart b/lib/level.dart index aa042f4..cc17efb 100644 --- a/lib/level.dart +++ b/lib/level.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/services.dart'; import 'package:sense_the_rhythm/arrows.dart'; +import 'package:sense_the_rhythm/game_over_stats.dart'; import 'package:sense_the_rhythm/simfile.dart'; class Level extends StatefulWidget { @@ -73,6 +74,15 @@ class _LevelState extends State<Level> { setState(() => _duration = d); }); + player.onPlayerComplete.listen((void _) { + Route route = MaterialPageRoute( + builder: (context) => GameOverStats( + simfile: simfile!, + notes: notes, + )); + Navigator.pushReplacement(context, route); + }); + player.onPositionChanged.listen((Duration p) { // print('Current position: $p'); setState(() => _position = p); @@ -121,19 +131,7 @@ class _LevelState extends State<Level> { } }); - String simfilePath = Directory(widget.stepmaniaFolderPath) - .listSync() - .firstWhere((entity) => entity.path.endsWith('.sm'), - orElse: () => File('')) - .path; - - String audioPath = Directory(widget.stepmaniaFolderPath) - .listSync() - .firstWhere((entity) => entity.path.endsWith('.ogg'), - orElse: () => File('')) - .path; - - simfile = Simfile(simfilePath); + simfile = Simfile(widget.stepmaniaFolderPath); simfile!.load(); simfile!.chartSimplest!.beats.forEach((time, noteData) { @@ -144,9 +142,7 @@ class _LevelState extends State<Level> { notes.add(Note(time: time, direction: ArrowDirection.values[arrowIndex])); }); - print(audioPath); - - player.play(DeviceFileSource(audioPath)); + player.play(DeviceFileSource(simfile!.audioPath!)); } @override |