@@ -99,97 +99,137 @@ std::vector<ChartSection> ParseSectionsFromChart(const char *contents)
99
99
return sections;
100
100
}
101
101
102
- std::map<int , int >
103
- ParseTimeSignaturesFromChartSections (std::vector<ChartSection> sections)
102
+ std::map<int , int > ParseTimeSignaturesFromChartSection (ChartSection section)
104
103
{
105
104
auto timeSignatures = std::map<int , int >();
106
105
107
- for ( auto & section : sections )
106
+ if ( section. name == ToString (NamedSection::SyncTrack) )
108
107
{
109
- if (section. name == ToString (NamedSection::SyncTrack) )
108
+ for ( auto &line : section. lines )
110
109
{
111
- for ( auto & line : section. lines )
110
+ if ( line. second . front () == ToString (TypeCode::TimeSignatureMarker) )
112
111
{
113
- if (line.second .front () ==
114
- ToString (TypeCode::TimeSignatureMarker))
115
- {
116
- timeSignatures.insert (
117
- {std::stoi (line.first ), std::stoi (line.second .at (1 ))});
118
- }
112
+ timeSignatures.insert (
113
+ {std::stoi (line.first ), std::stoi (line.second .at (1 ))});
119
114
}
120
115
}
121
116
}
122
117
123
118
return timeSignatures;
124
119
}
125
120
126
- std::map<int , int > ParseBpmFromChartSections (std::vector<ChartSection> sections)
121
+ std::map<int , int >
122
+ ParseTimeSignaturesFromChartSections (std::vector<ChartSection> sections)
123
+ {
124
+ for (auto §ion : sections)
125
+ {
126
+ if (section.name == ToString (NamedSection::SyncTrack))
127
+ {
128
+ return ParseTimeSignaturesFromChartSection (section);
129
+ }
130
+ }
131
+
132
+ return std::map<int , int >();
133
+ }
134
+
135
+ std::map<int , int > ParseBpmFromChartSection (ChartSection section)
127
136
{
128
137
auto bpm = std::map<int , int >();
129
138
139
+ if (section.name == ToString (NamedSection::SyncTrack))
140
+ {
141
+ for (auto &line : section.lines )
142
+ {
143
+ if (line.second .front () == ToString (TypeCode::BPM_Marker))
144
+ {
145
+ bpm.insert (
146
+ {std::stoi (line.first ), std::stoi (line.second .at (1 ))});
147
+ }
148
+ }
149
+ }
150
+
151
+ return bpm;
152
+ }
153
+
154
+ std::map<int , int > ParseBpmFromChartSections (std::vector<ChartSection> sections)
155
+ {
130
156
for (auto §ion : sections)
131
157
{
132
158
if (section.name == ToString (NamedSection::SyncTrack))
133
159
{
134
- for (auto &line : section.lines )
160
+ return ParseBpmFromChartSection (section);
161
+ }
162
+ }
163
+
164
+ return std::map<int , int >();
165
+ }
166
+
167
+ std::vector<Note> ParseNotesFromChartSection (ChartSection section,
168
+ Difficulty difficulty)
169
+ {
170
+ auto notes = std::vector<Note>();
171
+
172
+ if (section.name == ToString (difficulty) + " Single" )
173
+ {
174
+ for (auto &line : section.lines )
175
+ {
176
+ if (line.second .front () == ToString (TypeCode::NoteMarker))
135
177
{
136
- if (line.second .front () == ToString (TypeCode::BPM_Marker))
137
- {
138
- bpm.insert (
139
- {std::stoi (line.first ), std::stoi (line.second .at (1 ))});
140
- }
178
+ notes.push_back ({std::stoi (line.first ),
179
+ std::stoi (line.second .at (1 )),
180
+ std::stoi (line.second .at (2 ))});
141
181
}
142
182
}
143
183
}
144
184
145
- return bpm ;
185
+ return notes ;
146
186
}
147
187
148
188
std::vector<Note>
149
189
ParseNotesFromChartSections (std::vector<ChartSection> sections,
150
190
Difficulty difficulty)
151
191
{
152
- auto notes = std::vector<Note>();
153
-
154
192
for (auto §ion : sections)
155
193
{
156
194
if (section.name == ToString (difficulty) + " Single" )
157
195
{
158
- for (auto &line : section.lines )
196
+ return ParseNotesFromChartSection (section, difficulty);
197
+ }
198
+ }
199
+
200
+ return std::vector<Note>();
201
+ }
202
+
203
+ std::map<int , std::string> ParseLyricsFromChartSection (ChartSection section)
204
+ {
205
+ auto lyrics = std::map<int , std::string>();
206
+
207
+ if (section.name == ToString (NamedSection::Events))
208
+ {
209
+ for (auto &line : section.lines )
210
+ {
211
+ if (line.second .back ().rfind (" lyric" , 0 ) == 0 )
159
212
{
160
- if (line.second .front () == ToString (TypeCode::NoteMarker))
161
- {
162
- notes.push_back ({std::stoi (line.first ),
163
- std::stoi (line.second .at (1 )),
164
- std::stoi (line.second .at (2 ))});
165
- }
213
+ lyrics.insert ({std::stoi (line.first ), line.second .at (1 )});
166
214
}
167
215
}
168
216
}
169
217
170
- return notes ;
218
+ return lyrics ;
171
219
}
172
220
173
221
std::map<int , std::string>
174
222
ParseLyricsFromChartSections (std::vector<ChartSection> sections)
175
223
{
176
- auto lyrics = std::map<int , std::string>();
177
-
178
224
for (auto §ion : sections)
179
225
{
180
226
if (section.name == ToString (NamedSection::Events))
181
227
{
182
- for (auto &line : section.lines )
183
- {
184
- if (line.second .back ().rfind (" lyric" , 0 ) == 0 )
185
- {
186
- lyrics.insert ({std::stoi (line.first ), line.second .at (1 )});
187
- }
188
- }
228
+ return ParseLyricsFromChartSection (section);
189
229
}
190
230
}
191
231
192
- return lyrics ;
232
+ return std::map< int , std::string>() ;
193
233
}
194
234
195
235
} // namespace RhythmGameUtilities
0 commit comments