@@ -55,7 +55,7 @@ void rhythm_game_utilities::_bind_methods()
55
55
ClassDB::bind_static_method (
56
56
" rhythm_game_utilities" ,
57
57
D_METHOD (" convert_seconds_to_ticks" , " seconds" , " resolution" ,
58
- " bpm_changes" ),
58
+ " bpm_changes" , " time_signature_changes " ),
59
59
&rhythm_game_utilities::convert_seconds_to_ticks);
60
60
61
61
ClassDB::bind_static_method (
@@ -140,19 +140,24 @@ Dictionary rhythm_game_utilities::parse_sections_from_chart(String contents)
140
140
return sections;
141
141
}
142
142
143
- Dictionary rhythm_game_utilities::parse_bpm_from_chart_section (Array section)
143
+ Array rhythm_game_utilities::parse_bpm_from_chart_section (Array section)
144
144
{
145
- auto bpm_internal = RhythmGameUtilities::ParseBpmFromChartSection (
145
+ auto bpm_changes_internal = RhythmGameUtilities::ParseBpmFromChartSection (
146
146
convert_section_to_section_internal (section));
147
147
148
- Dictionary bpm ;
148
+ Array bpm_changes ;
149
149
150
- for (auto const &[key, val] : bpm_internal )
150
+ for (auto &bpm_change_internal : bpm_changes_internal )
151
151
{
152
- bpm[key] = bpm_internal[key];
152
+ Dictionary bpm_change;
153
+
154
+ bpm_change[" position" ] = bpm_change_internal.Position ;
155
+ bpm_change[" bpm" ] = bpm_change_internal.BPM ;
156
+
157
+ bpm_changes.append (bpm_change);
153
158
}
154
159
155
- return bpm ;
160
+ return bpm_changes ;
156
161
}
157
162
158
163
Dictionary rhythm_game_utilities::parse_lyrics_from_chart_section (Array section)
@@ -199,41 +204,86 @@ Array rhythm_game_utilities::parse_notes_from_chart_section(Array section)
199
204
{
200
205
Dictionary note;
201
206
207
+ note[" position" ] = note_internal.Position ;
202
208
note[" hand_position" ] = note_internal.HandPosition ;
203
209
note[" length" ] = note_internal.Length ;
204
- note[" position" ] = note_internal.Position ;
205
210
206
211
notes.append (note);
207
212
}
208
213
209
214
return notes;
210
215
}
211
216
212
- Dictionary
213
- rhythm_game_utilities::parse_time_signatures_from_chart_section ( Array section)
217
+ Array rhythm_game_utilities::parse_time_signatures_from_chart_section (
218
+ Array section)
214
219
{
215
220
auto time_signatures_internal =
216
221
RhythmGameUtilities::ParseTimeSignaturesFromChartSection (
217
222
convert_section_to_section_internal (section));
218
223
219
- Dictionary time_signatures;
224
+ Array time_signatures;
220
225
221
- for (auto const &[key, val] : time_signatures_internal)
226
+ for (auto &time_signature_internal : time_signatures_internal)
222
227
{
223
- time_signatures[key] = time_signatures_internal[key];
228
+ Dictionary time_signature;
229
+
230
+ time_signature[" position" ] = time_signature_internal.Position ;
231
+ time_signature[" numerator" ] = time_signature_internal.Numerator ;
232
+ time_signature[" denominator" ] = time_signature_internal.Denominator ;
233
+
234
+ time_signatures.append (time_signature);
224
235
}
225
236
226
237
return time_signatures;
227
238
}
228
239
229
240
// Utilities
230
241
231
- int rhythm_game_utilities::convert_seconds_to_ticks (float seconds,
232
- int resolution,
233
- Dictionary bpm_changes )
242
+ int rhythm_game_utilities::convert_seconds_to_ticks (
243
+ float seconds, int resolution, Array bpm_changes ,
244
+ Array time_signature_changes )
234
245
{
246
+ std::vector<RhythmGameUtilities::Tempo> bpm_changes_internal;
247
+ bpm_changes_internal.reserve (bpm_changes.size ());
248
+
249
+ for (auto i = 0 ; i < bpm_changes.size (); i += 1 )
250
+ {
251
+ RhythmGameUtilities::Tempo bpm_change_internal;
252
+
253
+ if (bpm_changes[i].get_type () == Variant::DICTIONARY)
254
+ {
255
+ Dictionary variant = bpm_changes[i];
256
+
257
+ bpm_change_internal.Position = variant[" position" ];
258
+ bpm_change_internal.BPM = variant[" bpm" ];
259
+ }
260
+
261
+ bpm_changes_internal.push_back (bpm_change_internal);
262
+ }
263
+
264
+ std::vector<RhythmGameUtilities::TimeSignature>
265
+ time_signature_changes_internal;
266
+ time_signature_changes_internal.reserve (time_signature_changes.size ());
267
+
268
+ for (auto i = 0 ; i < time_signature_changes.size (); i += 1 )
269
+ {
270
+ RhythmGameUtilities::TimeSignature time_signature_internal;
271
+
272
+ if (time_signature_changes[i].get_type () == Variant::DICTIONARY)
273
+ {
274
+ Dictionary variant = time_signature_changes[i];
275
+
276
+ time_signature_internal.Position = variant[" position" ];
277
+ time_signature_internal.Numerator = variant[" numerator" ];
278
+ time_signature_internal.Denominator = variant[" denominator" ];
279
+ }
280
+
281
+ time_signature_changes_internal.push_back (time_signature_internal);
282
+ }
283
+
235
284
return RhythmGameUtilities::ConvertSecondsToTicks (
236
- seconds, resolution, convert_dictionary_to_map<int , int >(bpm_changes));
285
+ seconds, resolution, bpm_changes_internal,
286
+ time_signature_changes_internal);
237
287
}
238
288
239
289
float rhythm_game_utilities::convert_tick_to_position (int tick, int resolution)
@@ -262,22 +312,39 @@ float rhythm_game_utilities::calculate_accuracy_ratio(int position,
262
312
current_position, delta);
263
313
}
264
314
265
- Array rhythm_game_utilities::calculate_beat_bars (Dictionary bpm_changes,
315
+ Array rhythm_game_utilities::calculate_beat_bars (Array bpm_changes,
266
316
int resolution, int ts,
267
317
bool include_half_notes)
268
318
{
269
- auto beat_bars = RhythmGameUtilities::CalculateBeatBars (
270
- convert_dictionary_to_map<int , int >(bpm_changes), resolution, ts,
271
- include_half_notes);
319
+ std::vector<RhythmGameUtilities::Tempo> bpm_changes_internal;
320
+ bpm_changes_internal.reserve (bpm_changes.size ());
321
+
322
+ for (auto i = 0 ; i < bpm_changes.size (); i += 1 )
323
+ {
324
+ RhythmGameUtilities::Tempo bpm_change_internal;
325
+
326
+ if (bpm_changes[i].get_type () == Variant::DICTIONARY)
327
+ {
328
+ Dictionary variant = bpm_changes[i];
329
+
330
+ bpm_change_internal.Position = variant[" position" ];
331
+ bpm_change_internal.BPM = variant[" bpm" ];
332
+ }
333
+
334
+ bpm_changes_internal.push_back (bpm_change_internal);
335
+ }
336
+
337
+ auto beat_bars_internal = RhythmGameUtilities::CalculateBeatBars (
338
+ bpm_changes_internal, resolution, ts, include_half_notes);
272
339
273
340
Array beat_bars_dictionary_array;
274
341
275
- for (auto &beat_bar : beat_bars )
342
+ for (auto &beat_bar_internal : beat_bars_internal )
276
343
{
277
344
Dictionary beat_bar_dictionary;
278
345
279
- beat_bar_dictionary[" bpm " ] = beat_bar. BPM ;
280
- beat_bar_dictionary[" position " ] = beat_bar. Position ;
346
+ beat_bar_dictionary[" position " ] = beat_bar_internal. Position ;
347
+ beat_bar_dictionary[" bpm " ] = beat_bar_internal. BPM ;
281
348
282
349
beat_bars_dictionary_array.append (beat_bar_dictionary);
283
350
}
0 commit comments