Merge branch 'features' into trophies-list

This commit is contained in:
igor725 2024-05-07 13:24:14 +03:00 committed by GitHub
commit cfdf0215af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 14 deletions

View File

@ -64,6 +64,7 @@ class Hotkeys: public IHotkeys {
};
auto readBind = [](std::string& str, KBind* kb) -> bool {
if (str.length() == 0) return false;
auto delim = str.find_last_of("||");
if (delim != std::string::npos) {
auto mod = str.substr(0, delim - 1);
@ -83,9 +84,12 @@ class Hotkeys: public IHotkeys {
}
}
kb->kc = SDL_GetScancodeFromName(str.c_str());
kb->mod = 0x0000;
return true;
if ((kb->kc = SDL_GetScancodeFromName(str.c_str())) != SDL_SCANCODE_UNKNOWN) {
kb->mod = 0x0000;
return true;
}
return false;
};
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::CONTROLS);
@ -97,6 +101,7 @@ class Hotkeys: public IHotkeys {
auto& bind = m_binds[(uint32_t)it->second];
if (!readBind(temp, &bind)) {
printf("Missing key binding for \"%s\"!\n", bname.c_str());
bind = {0, 0};
continue;
}

View File

@ -184,19 +184,21 @@ Config::Config() {
removeUnused = [&getVal, &removeUnused](json& obj, json& def) -> bool {
bool unused = false;
for (auto& [ckey, cval]: obj.items()) {
if (ckey.starts_with("_")) { // Temporary (probably) workaround to stop removing underscore objects
continue;
}
json& dval = getVal(def, ckey);
for (auto it = obj.begin(); it != obj.end();) {
auto& ckey = it.key();
if (!ckey.starts_with("_")) { // Temporary (probably) workaround to stop removing underscore objects
json& dval = getVal(def, ckey);
if (dval.is_null()) {
obj.erase(ckey);
unused = true;
} else if (dval.is_structured()) {
unused |= removeUnused(cval, dval);
continue;
if (dval.is_null()) {
it = obj.erase(it);
unused = true;
continue;
} else if (dval.is_structured()) {
unused |= removeUnused(*it, dval);
}
}
++it;
}
return unused;