mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Placing an es_find_rules.xml file in custom_systems will now complement rather than override the bundled file
This commit is contained in:
parent
1c30e23614
commit
cdf7a192c4
|
@ -41,32 +41,35 @@ FindRules::FindRules()
|
||||||
|
|
||||||
void FindRules::loadFindRules()
|
void FindRules::loadFindRules()
|
||||||
{
|
{
|
||||||
const std::string& customSystemsDirectory {Utils::FileSystem::getHomePath() +
|
std::vector<std::string> paths;
|
||||||
"/.emulationstation/custom_systems"};
|
std::string filePath {Utils::FileSystem::getHomePath() + "/.emulationstation/custom_systems" +
|
||||||
|
"/es_find_rules.xml"};
|
||||||
|
|
||||||
std::string path {customSystemsDirectory + "/es_find_rules.xml"};
|
if (Utils::FileSystem::exists(filePath)) {
|
||||||
|
paths.emplace_back(filePath);
|
||||||
if (Utils::FileSystem::exists(path)) {
|
|
||||||
LOG(LogInfo) << "Found custom find rules configuration file";
|
LOG(LogInfo) << "Found custom find rules configuration file";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
path = ResourceManager::getInstance().getResourcePath(":/systems/windows/es_find_rules.xml",
|
filePath = ResourceManager::getInstance().getResourcePath(":/systems/windows/es_find_rules.xml",
|
||||||
false);
|
false);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
path = ResourceManager::getInstance().getResourcePath(":/systems/macos/es_find_rules.xml",
|
filePath =
|
||||||
false);
|
ResourceManager::getInstance().getResourcePath(":/systems/macos/es_find_rules.xml", false);
|
||||||
#else
|
#else
|
||||||
path = ResourceManager::getInstance().getResourcePath(":/systems/unix/es_find_rules.xml",
|
filePath =
|
||||||
false);
|
ResourceManager::getInstance().getResourcePath(":/systems/unix/es_find_rules.xml", false);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (path == "") {
|
if (filePath == "" && paths.empty()) {
|
||||||
LOG(LogWarning) << "No find rules configuration file found";
|
LOG(LogWarning) << "No find rules configuration file found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filePath != "")
|
||||||
|
paths.emplace_back(filePath);
|
||||||
|
|
||||||
|
for (auto& path : paths) {
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
LOG(LogInfo) << "Parsing find rules configuration file \""
|
LOG(LogInfo) << "Parsing find rules configuration file \""
|
||||||
<< Utils::String::replace(path, "/", "\\") << "\"...";
|
<< Utils::String::replace(path, "/", "\\") << "\"...";
|
||||||
|
@ -84,7 +87,7 @@ void FindRules::loadFindRules()
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
LOG(LogError) << "Couldn't parse es_find_rules.xml: " << res.description();
|
LOG(LogError) << "Couldn't parse es_find_rules.xml: " << res.description();
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually read the file.
|
// Actually read the file.
|
||||||
|
@ -92,7 +95,7 @@ void FindRules::loadFindRules()
|
||||||
|
|
||||||
if (!ruleList) {
|
if (!ruleList) {
|
||||||
LOG(LogError) << "es_find_rules.xml is missing the <ruleList> tag";
|
LOG(LogError) << "es_find_rules.xml is missing the <ruleList> tag";
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EmulatorRules emulatorRules;
|
EmulatorRules emulatorRules;
|
||||||
|
@ -106,11 +109,14 @@ void FindRules::loadFindRules()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mEmulators.find(emulatorName) != mEmulators.end()) {
|
if (mEmulators.find(emulatorName) != mEmulators.end()) {
|
||||||
|
if (paths.size() == 1) {
|
||||||
LOG(LogWarning) << "Found repeating emulator tag \"" << emulatorName
|
LOG(LogWarning) << "Found repeating emulator tag \"" << emulatorName
|
||||||
<< "\", skipping entry";
|
<< "\", skipping entry";
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (pugi::xml_node rule = emulator.child("rule"); rule; rule = rule.next_sibling("rule")) {
|
for (pugi::xml_node rule = emulator.child("rule"); rule;
|
||||||
|
rule = rule.next_sibling("rule")) {
|
||||||
const std::string& ruleType {rule.attribute("type").as_string()};
|
const std::string& ruleType {rule.attribute("type").as_string()};
|
||||||
if (ruleType.empty()) {
|
if (ruleType.empty()) {
|
||||||
LOG(LogWarning) << "Found rule tag without type attribute for emulator \""
|
LOG(LogWarning) << "Found rule tag without type attribute for emulator \""
|
||||||
|
@ -123,8 +129,8 @@ void FindRules::loadFindRules()
|
||||||
#else
|
#else
|
||||||
if (ruleType != "systempath" && ruleType != "staticpath") {
|
if (ruleType != "systempath" && ruleType != "staticpath") {
|
||||||
#endif
|
#endif
|
||||||
LOG(LogWarning) << "Found invalid rule type \"" << ruleType << "\" for emulator \""
|
LOG(LogWarning) << "Found invalid rule type \"" << ruleType
|
||||||
<< emulatorName << "\", skipping entry";
|
<< "\" for emulator \"" << emulatorName << "\", skipping entry";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (pugi::xml_node entry {rule.child("entry")}; entry;
|
for (pugi::xml_node entry {rule.child("entry")}; entry;
|
||||||
|
@ -158,14 +164,17 @@ void FindRules::loadFindRules()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mCores.find(coreName) != mCores.end()) {
|
if (mCores.find(coreName) != mCores.end()) {
|
||||||
LOG(LogWarning) << "Found repeating core tag \"" << coreName << "\", skipping entry";
|
if (paths.size() == 1) {
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "Found repeating core tag \"" << coreName << "\", skipping entry";
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (pugi::xml_node rule {core.child("rule")}; rule; rule = rule.next_sibling("rule")) {
|
for (pugi::xml_node rule {core.child("rule")}; rule; rule = rule.next_sibling("rule")) {
|
||||||
const std::string& ruleType {rule.attribute("type").as_string()};
|
const std::string& ruleType {rule.attribute("type").as_string()};
|
||||||
if (ruleType.empty()) {
|
if (ruleType.empty()) {
|
||||||
LOG(LogWarning) << "Found rule tag without type attribute for core \"" << coreName
|
LOG(LogWarning) << "Found rule tag without type attribute for core \""
|
||||||
<< "\", skipping entry";
|
<< coreName << "\", skipping entry";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ruleType != "corepath") {
|
if (ruleType != "corepath") {
|
||||||
|
@ -184,6 +193,7 @@ void FindRules::loadFindRules()
|
||||||
coreRules.corePaths.clear();
|
coreRules.corePaths.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SystemData::SystemData(const std::string& name,
|
SystemData::SystemData(const std::string& name,
|
||||||
const std::string& fullName,
|
const std::string& fullName,
|
||||||
|
|
Loading…
Reference in a new issue