33#include " utilities.hpp"
44
55#include < RhythmGameUtilities/Common.hpp>
6+ #include < RhythmGameUtilities/Parsers.hpp>
67#include < RhythmGameUtilities/Utilities.hpp>
78
89void rhythm_game_utilities::_bind_methods ()
@@ -17,6 +18,13 @@ void rhythm_game_utilities::_bind_methods()
1718 D_METHOD (" inverse_lerp" , " a" , " b" , " v" ),
1819 &rhythm_game_utilities::inverse_lerp);
1920
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+
2028 // Utilities
2129
2230 ClassDB::bind_static_method (
@@ -65,6 +73,44 @@ float rhythm_game_utilities::inverse_lerp(float a, float b, float v)
6573 return RhythmGameUtilities::InverseLerp (a, b, v);
6674}
6775
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+
68114// Utilities
69115
70116int rhythm_game_utilities::convert_seconds_to_ticks (float seconds,
0 commit comments