Skip to content

Commit

Permalink
Charters display properly now
Browse files Browse the repository at this point in the history
both "charters" and "charter" are supported as keys, and it can either be a single string, or an array of strings.
  • Loading branch information
NarrikSynthfox committed Dec 26, 2024
1 parent 6d5a92f commit 7a3b2f5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 37 deletions.
48 changes: 25 additions & 23 deletions Encore/Songs/Synthfox Soundworks - Untitled Chords Thing/info.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{
"title":"Untitled Chords Thing",
"artist":"Synthfox Soundworks",
"length":112,
"sid":"Drum",
"sib":"Bass",
"sig":"Guitar",
"siv":"Vocals",
"diff":{
"ds":3,
"ba":2,
"gr":3,
"vl":2
},
"midi":"notes.mid",
"stems":{
"drums":"drums.ogg",
"bass":"bass.ogg",
"lead":"lead.ogg",
"vocals":"vocals.ogg",
"backing":"backing.ogg"
},
"art":"cover.png"
}
"title": "Untitled Chords Thing",
"artist": "Synthfox Soundworks",
"charters": "Narrik Synthfox",
"release_year": 2024,
"length": 112,
"sid": "Drum",
"sib": "Bass",
"sig": "Guitar",
"siv": "Vocals",
"diff": {
"ds": 3,
"ba": 2,
"gr": 3,
"vl": 2
},
"midi": "notes.mid",
"stems": {
"drums": "drums.ogg",
"bass": "bass.ogg",
"lead": "lead.ogg",
"vocals": "vocals.ogg",
"backing": "backing.ogg"
},
"art": "cover.png"
}
2 changes: 1 addition & 1 deletion Encore/src/song/song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Song::LoadInfoINI(std::filesystem::path iniPath) {
artist = ini.GetString("song", "artist", "Unknown Artist");

// genre = ini.GetValue("song", "genre");
charters.push_back(ini.GetString("song", "charter", "Unkown Charter"));
charters.push_back(ini.GetString("song", "charter", "Unknown Charter"));

album = ini.GetString("song", "album", "Unknown Album");

Expand Down
35 changes: 22 additions & 13 deletions Encore/src/song/song.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <unordered_map>
#include <filesystem>
#include <cmath>

#include <string>
#include "picosha2.h"
#include "rapidjson/document.h"
#include "util/enclog.h"
Expand Down Expand Up @@ -405,10 +405,15 @@ class Song {
}
}
}
if (item.name == "charters" && item.value.IsObject()) {
for (auto &charter : item.value.GetObject()) {
if (charter.value.IsString()) {
charters.push_back(charter.value.GetString());
if (item.name == "charters" || item.name == "charter") {
if (item.value.IsString()) {
charters.push_back(item.value.GetString());
}
else if (item.value.IsArray()) {
for (auto &charter : item.value.GetArray()) {
if (charter.IsString()) {
charters.push_back(charter.GetString());
}
}
}
}
Expand Down Expand Up @@ -590,18 +595,22 @@ class Song {
}
}
}
if (item.name == "charters" && item.value.IsObject()) {
for (auto &charter : item.value.GetObject()) {
if (charter.value.IsString()) {
charters.push_back(charter.value.GetString());
if (item.name == "charters" || item.name == "charter") {
if (item.value.IsString()) {
charters.push_back(item.value.GetString());
} else if (item.value.IsArray()) {
for (auto &charter : item.value.GetArray()) {
if (charter.IsString()) {
charters.push_back(charter.GetString());
}
}
}
}
if (charters.empty()) {
charters.push_back("Unknown Charter");
}
}
}
if (charters.empty()) {
charters.push_back("Unknown Charter");
}
ifs.close();
}
void parseBeatLines(smf::MidiFile &midiFile, int trkidx) {
Expand Down Expand Up @@ -747,4 +756,4 @@ class Song {
};
};

#endif // ENCORE_SONG_H
#endif // ENCORE_SONG_H

0 comments on commit 7a3b2f5

Please sign in to comment.