-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOsuReader.cs
42 lines (41 loc) · 1.03 KB
/
OsuReader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.IO;
public static class OsuReader {
[Serializable]
public class OsuMap {
public string Title;
public string Artist;
public string AudioFile;
public int order;
}
public static OsuMap GetOsuMapInfo(string osuFile){
bool resultTaken = false;
int informationsTaken = 0;
var map = new OsuMap();
using (StreamReader reader = new StreamReader(osuFile)) {
while(!resultTaken){
try {
string result = reader.ReadLine();
if(result.StartsWith("AudioFilename: ", StringComparison.CurrentCulture)){
map.AudioFile = result.Remove(0,15);
informationsTaken++;
}
if(result.StartsWith("Title:", StringComparison.CurrentCulture)){
map.Title = result.Remove(0,6);
informationsTaken++;
}
if(result.StartsWith("Artist:", StringComparison.CurrentCulture)){
map.Artist = result.Remove(0,7);
informationsTaken++;
}
if(informationsTaken > 2){
resultTaken = true;
}
} catch {
resultTaken = true;
}
}
}
return map;
}
}