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