1use crate::utils::parse_field;
2#[derive(Debug, Clone)]
3pub struct SmFile {
4 pub metadata: Metadata,
5 pub offset: f64, pub bpms: Vec<(f64, f64)>, pub stops: Vec<(f64, f64)>, pub charts: Vec<Chart>,
9}
10
11impl SmFile {
12 pub fn new() -> SmFile {
13 SmFile {
14 metadata: Metadata::new(),
15 offset: 0.0,
16 bpms: Vec::new(),
17 stops: Vec::new(),
18 charts: Vec::new(),
19 }
20 }
21}
22
23#[derive(Debug, Clone)]
24pub struct Metadata {
25 pub title: String,
26 pub subtitle: String,
27 pub artist: String,
28 pub title_translit: String,
29 pub artist_translit: String,
30 pub credit: String,
31 pub music: String,
32 pub banner: String,
33 pub background: String,
34}
35
36impl Metadata {
37 pub fn new() -> Metadata {
38 Metadata {
39 title: String::new(),
40 subtitle: String::new(),
41 artist: String::new(),
42 title_translit: String::new(),
43 artist_translit: String::new(),
44 credit: String::new(),
45 music: String::new(),
46 banner: String::new(),
47 background: String::new(),
48 }
49 }
50 pub fn parse(&mut self, content: &str) {
51 parse_field(content, r"#TITLE:(.*?);", &mut self.title);
52 parse_field(content, r"#SUBTITLE:(.*?);", &mut self.subtitle);
53 parse_field(content, r"#ARTIST:(.*?);", &mut self.artist);
54 parse_field(content, r"#TITLETRANSLIT:(.*?);", &mut self.title_translit);
55 parse_field(
56 content,
57 r"#ARTISTTRANSLIT:(.*?);",
58 &mut self.artist_translit,
59 );
60 parse_field(content, r"#CREDIT:(.*?);", &mut self.credit);
61 parse_field(content, r"#MUSIC:(.*?);", &mut self.music);
62 parse_field(content, r"#BANNER:(.*?);", &mut self.banner);
63 parse_field(content, r"#BACKGROUND:(.*?);", &mut self.background);
64 }
65}
66
67#[derive(Debug, Clone)]
68pub struct Chart {
69 pub stepstype: String,
70 pub description: String,
71 pub difficulty: String,
72 pub meter: u32,
73 pub radar_values: Vec<f64>,
74 pub column_count: u32,
75 pub measures: Vec<Measure>,
76}
77
78impl Chart {
79 pub fn new() -> Chart {
80 Chart {
81 stepstype: String::new(),
82 description: String::new(),
83 difficulty: String::new(),
84 meter: 0,
85 radar_values: Vec::new(),
86 column_count: 0,
87 measures: Vec::new(),
88 }
89 }
90}
91
92#[derive(Debug, Clone)]
93pub struct Measure {
94 pub beats: Vec<Beat>,
95 pub start_time: f64, }
97
98impl Measure {
99 pub fn new() -> Measure {
100 Measure {
101 beats: Vec::new(),
102 start_time: 0.0,
103 }
104 }
105}
106
107#[derive(Debug, Clone)]
108pub struct Beat {
109 pub time: f64, pub notes: Vec<bool>, }
112impl Beat {
113 pub fn new() -> Beat {
114 Beat {
115 time: 0.0,
116 notes: Vec::new(),
117 }
118 }
119}
120
121
122
123pub struct OsuSettings
124{
125 pub od: f64,
126 pub hp: f64,
127}