diff options
author | Orangerot <purple@orangerot.dev> | 2025-01-07 06:05:28 +0100 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2025-01-07 06:05:28 +0100 |
commit | 685323adeab3d27bff4df16a201f9f14688475d5 (patch) | |
tree | ffda52d0d2ebd01451914fc5d3cb15ab564146a6 /lib/simfile.dart | |
parent | 0178eb5ffcc6ba798ab5f30c055d4be35610c655 (diff) |
feat: GameOverStats Widgets shows stats after a course
Diffstat (limited to 'lib/simfile.dart')
-rw-r--r-- | lib/simfile.dart | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/simfile.dart b/lib/simfile.dart index 102c989..764e3aa 100644 --- a/lib/simfile.dart +++ b/lib/simfile.dart @@ -37,7 +37,10 @@ class Chart { } class Simfile { - String path; + String directoryPath; + String? simfilePath; + String? audioPath; + String? bannerPath; String? lines; // tags of simfile @@ -48,7 +51,7 @@ class Simfile { Map<double, double> bpms = {}; double offset = 0; - Simfile(this.path); + Simfile(this.directoryPath); void _parseChart({required List<String> keys, required String value}) { Chart chart = Chart(); @@ -118,7 +121,18 @@ class Simfile { } void load() { - lines = File(path).readAsStringSync(); + simfilePath = Directory(directoryPath) + .listSync() + .firstWhere((entity) => entity.path.endsWith('.sm'), + orElse: () => File('')).path; + + audioPath = Directory(directoryPath) + .listSync() + .firstWhere((entity) => entity.path.endsWith('.ogg'), + orElse: () => File('')) + .path; + + lines = File(simfilePath!).readAsStringSync(); RegExp commentsRegExp = RegExp(r'//.*$'); lines = lines?.replaceAll(commentsRegExp, ''); |