Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 70 additions & 44 deletions includes/RhythmGameUtilities/Parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,97 +99,123 @@ std::vector<ChartSection> ParseSectionsFromChart(const char *contents)
return sections;
}

std::map<int, int>
ParseTimeSignaturesFromChartSections(std::vector<ChartSection> sections)
std::map<int, int> ParseTimeSignaturesFromChartSection(ChartSection section)
{
auto timeSignatures = std::map<int, int>();

for (auto &line : section.lines)
{
if (line.second.front() == ToString(TypeCode::TimeSignatureMarker))
{
timeSignatures.insert(
{std::stoi(line.first), std::stoi(line.second.at(1))});
}
}

return timeSignatures;
}

std::map<int, int>
ParseTimeSignaturesFromChartSections(std::vector<ChartSection> sections)
{
for (auto &section : sections)
{
if (section.name == ToString(NamedSection::SyncTrack))
{
for (auto &line : section.lines)
{
if (line.second.front() ==
ToString(TypeCode::TimeSignatureMarker))
{
timeSignatures.insert(
{std::stoi(line.first), std::stoi(line.second.at(1))});
}
}
return ParseTimeSignaturesFromChartSection(section);
}
}

return timeSignatures;
return std::map<int, int>();
}

std::map<int, int> ParseBpmFromChartSections(std::vector<ChartSection> sections)
std::map<int, int> ParseBpmFromChartSection(ChartSection section)
{
auto bpm = std::map<int, int>();

for (auto &line : section.lines)
{
if (line.second.front() == ToString(TypeCode::BPM_Marker))
{
bpm.insert({std::stoi(line.first), std::stoi(line.second.at(1))});
}
}

return bpm;
}

std::map<int, int> ParseBpmFromChartSections(std::vector<ChartSection> sections)
{
for (auto &section : sections)
{
if (section.name == ToString(NamedSection::SyncTrack))
{
for (auto &line : section.lines)
{
if (line.second.front() == ToString(TypeCode::BPM_Marker))
{
bpm.insert(
{std::stoi(line.first), std::stoi(line.second.at(1))});
}
}
return ParseBpmFromChartSection(section);
}
}

return bpm;
return std::map<int, int>();
}

std::vector<Note> ParseNotesFromChartSection(ChartSection section)
{
auto notes = std::vector<Note>();

for (auto &line : section.lines)
{
if (line.second.front() == ToString(TypeCode::NoteMarker))
{
notes.push_back({std::stoi(line.first),
std::stoi(line.second.at(1)),
std::stoi(line.second.at(2))});
}
}

return notes;
}

std::vector<Note>
ParseNotesFromChartSections(std::vector<ChartSection> sections,
Difficulty difficulty)
{
auto notes = std::vector<Note>();

for (auto &section : sections)
{
if (section.name == ToString(difficulty) + "Single")
{
for (auto &line : section.lines)
{
if (line.second.front() == ToString(TypeCode::NoteMarker))
{
notes.push_back({std::stoi(line.first),
std::stoi(line.second.at(1)),
std::stoi(line.second.at(2))});
}
}
return ParseNotesFromChartSection(section);
}
}

return notes;
return std::vector<Note>();
}

std::map<int, std::string>
ParseLyricsFromChartSections(std::vector<ChartSection> sections)
std::map<int, std::string> ParseLyricsFromChartSection(ChartSection section)
{
auto lyrics = std::map<int, std::string>();

for (auto &line : section.lines)
{
if (line.second.back().rfind("lyric", 0) == 0)
{
lyrics.insert({std::stoi(line.first), line.second.at(1)});
}
}

return lyrics;
}

std::map<int, std::string>
ParseLyricsFromChartSections(std::vector<ChartSection> sections)
{
for (auto &section : sections)
{
if (section.name == ToString(NamedSection::Events))
{
for (auto &line : section.lines)
{
if (line.second.back().rfind("lyric", 0) == 0)
{
lyrics.insert({std::stoi(line.first), line.second.at(1)});
}
}
return ParseLyricsFromChartSection(section);
}
}

return lyrics;
return std::map<int, std::string>();
}

} // namespace RhythmGameUtilities