3
3
#include " utilities.hpp"
4
4
5
5
#include < RhythmGameUtilities/Common.hpp>
6
+ #include < RhythmGameUtilities/Parsers.hpp>
6
7
#include < RhythmGameUtilities/Utilities.hpp>
7
8
8
9
void rhythm_game_utilities::_bind_methods ()
@@ -17,6 +18,13 @@ void rhythm_game_utilities::_bind_methods()
17
18
D_METHOD (" inverse_lerp" , " a" , " b" , " v" ),
18
19
&rhythm_game_utilities::inverse_lerp);
19
20
21
+ // Parsers
22
+
23
+ ClassDB::bind_static_method (
24
+ " rhythm_game_utilities" ,
25
+ D_METHOD (" parse_sections_from_chart" , " contents" ),
26
+ &rhythm_game_utilities::parse_sections_from_chart);
27
+
20
28
// Utilities
21
29
22
30
ClassDB::bind_static_method (
@@ -65,6 +73,44 @@ float rhythm_game_utilities::inverse_lerp(float a, float b, float v)
65
73
return RhythmGameUtilities::InverseLerp (a, b, v);
66
74
}
67
75
76
+ // Parsers
77
+
78
+ Dictionary rhythm_game_utilities::parse_sections_from_chart (String contents)
79
+ {
80
+ Dictionary sections;
81
+
82
+ auto sectionsInternal =
83
+ RhythmGameUtilities::ParseSectionsFromChart (contents.utf8 ().get_data ());
84
+
85
+ for (auto sectionInternal = sectionsInternal.begin ();
86
+ sectionInternal != sectionsInternal.end (); sectionInternal++)
87
+ {
88
+ auto sectionKey = godot::String (sectionInternal->first .c_str ());
89
+
90
+ Dictionary section;
91
+
92
+ for (auto i = 0 ; i < sectionInternal->second .size (); i += 1 )
93
+ {
94
+ auto temp = sectionInternal->second [i];
95
+
96
+ auto key = godot::Variant (temp.first .c_str ());
97
+
98
+ Array values;
99
+
100
+ for (auto j = 0 ; j < temp.second .size (); j += 1 )
101
+ {
102
+ values.append (godot::Variant (temp.second [j].c_str ()));
103
+ }
104
+
105
+ section[key] = values;
106
+ }
107
+
108
+ sections[sectionKey] = section;
109
+ }
110
+
111
+ return sections;
112
+ }
113
+
68
114
// Utilities
69
115
70
116
int rhythm_game_utilities::convert_seconds_to_ticks (float seconds,
0 commit comments