mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-10 04:21:44 +00:00
fix pc color swap crash
This commit is contained in:
parent
a2f98dc05c
commit
8f6c4ad5ee
1 changed files with 22 additions and 21 deletions
|
@ -288,33 +288,34 @@ namespace PC {
|
||||||
std::fstream profilesFile;
|
std::fstream profilesFile;
|
||||||
nlohmann::ordered_json profilesJson;
|
nlohmann::ordered_json profilesJson;
|
||||||
download::getRequest(PC_COLOR_URL, profilesJson);
|
download::getRequest(PC_COLOR_URL, profilesJson);
|
||||||
profilesJson += fs::parseJsonFile(path);
|
|
||||||
if (profilesJson.empty()) {
|
if (profilesJson.empty()) {
|
||||||
profilesJson = {{{"BTN", "e6e6e6"},
|
profilesJson = {{{"BTN", "e6e6e6"},
|
||||||
{"BODY", "2d2d2d"},
|
{"BODY", "2d2d2d"},
|
||||||
{"name", "Default black"}}};
|
{"name", "Default black"}}};
|
||||||
}
|
}
|
||||||
for (const auto& x : profilesJson.items()) {
|
for (const auto& profiles : {fs::parseJsonFile(path), profilesJson}) {
|
||||||
std::string name = x.value()["name"];
|
for (const auto& x : profiles.items()) {
|
||||||
std::vector<std::string> values = {
|
std::string name = x.value()["name"];
|
||||||
std::string(x.value()["BODY"]),
|
std::vector<std::string> values = {
|
||||||
std::string(x.value()["BTN"])};
|
std::string(x.value()["BODY"]),
|
||||||
properData = true;
|
std::string(x.value()["BTN"])};
|
||||||
for (auto& str : values) {
|
properData = true;
|
||||||
if (!isHexaAnd3Bytes(str)) {
|
for (auto& str : values) {
|
||||||
properData = false;
|
if (!isHexaAnd3Bytes(str)) {
|
||||||
|
properData = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (properData) {
|
||||||
if (properData) {
|
if (name == "") name = "Unamed";
|
||||||
if (name == "") name = "Unamed";
|
auto profile = std::make_pair(name, (std::vector<int>){
|
||||||
auto profile = std::make_pair(name, (std::vector<int>){
|
hexToBGR(values[0]),
|
||||||
hexToBGR(values[0]),
|
hexToBGR(values[1])});
|
||||||
hexToBGR(values[1])});
|
if (name == BACKUP) {
|
||||||
if (name == BACKUP) {
|
res.push_front(profile);
|
||||||
res.push_front(profile);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
res.push_back(profile);
|
||||||
res.push_back(profile);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue