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