diff options
Diffstat (limited to 'lib/screens')
| -rw-r--r-- | lib/screens/level.dart | 10 | ||||
| -rw-r--r-- | lib/screens/level_selection.dart | 4 | 
2 files changed, 14 insertions, 0 deletions
| diff --git a/lib/screens/level.dart b/lib/screens/level.dart index 9c5823b..a22c237 100644 --- a/lib/screens/level.dart +++ b/lib/screens/level.dart @@ -87,6 +87,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin {        }      }); +    // go to GameOverStats when level finishes      player.onPlayerComplete.listen((void _) {        Route route = MaterialPageRoute(            builder: (context) => GameOverStats( @@ -105,6 +106,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin {        });      } +    // convert beats to notes      widget.simfile.chartSimplest?.beats.forEach((time, noteData) {        int arrowIndex = noteData.indexOf('1');        if (arrowIndex < 0 || arrowIndex > 3) { @@ -126,6 +128,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin {      super.dispose();    } +  /// toggle between pause and resume    void _pauseResume() {      if (_isPlaying) {        player.pause(); @@ -140,18 +143,24 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin {      }    } +  /// checks if the [note] is hit on [time] with the correct InputDirection    void _noteHitCheck(Note note, Duration time) {      note.position = note.time - time.inMilliseconds / 60000.0;      if (note.wasHit != null) {        return;      } + +    // you have +- half a second to hit      if (note.position.abs() < 0.5 * 1.0 / 60.0) { +      // combine keyboard and esense input        InputDirection esenseDirection =            ESenseInput.instance.getInputDirection(note.direction);        inputDirection.up |= esenseDirection.up;        inputDirection.down |= esenseDirection.down;        inputDirection.left |= esenseDirection.left;        inputDirection.right |= esenseDirection.right; + +      // check if input matches arrow direction        bool keypressCorrect = false;        switch (note.direction) {          case ArrowDirection.up: @@ -189,6 +198,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin {      }    } +  /// sets the InputDirection based on the arrow keys    void _keyboardHandler(event) {      bool isDown = false;      if (event is KeyDownEvent) { diff --git a/lib/screens/level_selection.dart b/lib/screens/level_selection.dart index 7241ad7..5984e65 100644 --- a/lib/screens/level_selection.dart +++ b/lib/screens/level_selection.dart @@ -28,6 +28,7 @@ class _LevelSelectionState extends State<LevelSelection> {      loadFolderPath();    } +  /// gets folder path from persistent storage and updates state with loaded simfiles    Future<void> loadFolderPath() async {      SharedPreferences prefs = await SharedPreferences.getInstance();      final String? stepmaniaCoursesPathSetting = @@ -44,6 +45,7 @@ class _LevelSelectionState extends State<LevelSelection> {      });    } +  /// open folder selection dialog and save selected folder in persistent storage    Future<void> selectFolder() async {      await Permission.manageExternalStorage.request();      String? selectedFolder = await FilePicker.platform.getDirectoryPath(); @@ -57,6 +59,7 @@ class _LevelSelectionState extends State<LevelSelection> {      }    } +  /// load all simfiles from a [directoryPath]    Future<List<Simfile>> listFilesAndFolders(String directoryPath) async {      final directory = Directory(directoryPath);      try { @@ -86,6 +89,7 @@ class _LevelSelectionState extends State<LevelSelection> {      }    } +  /// filter stepmaniaCoursesFolders based on [input]    void filterLevels(String input) {      setState(() {        stepmaniaCoursesFoldersFiltered = stepmaniaCoursesFolders | 
