mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Missing theme files defined using variables now only trigger debug messages instead of errors or warnings.
Also added two DebugSkipMissingThemeFiles and DebugSkipMissingThemeFilesCustomCollections settings.
This commit is contained in:
parent
171ee4ded2
commit
c870664615
|
@ -1335,7 +1335,7 @@ void SystemData::loadTheme()
|
||||||
sysData.insert(std::pair<std::string, std::string>("system.theme.collections", "\b"));
|
sysData.insert(std::pair<std::string, std::string>("system.theme.collections", "\b"));
|
||||||
}
|
}
|
||||||
|
|
||||||
mTheme->loadFile(sysData, path);
|
mTheme->loadFile(sysData, path, isCustomCollection());
|
||||||
}
|
}
|
||||||
catch (ThemeException& e) {
|
catch (ThemeException& e) {
|
||||||
LOG(LogError) << e.what();
|
LOG(LogError) << e.what();
|
||||||
|
|
|
@ -285,6 +285,8 @@ void Settings::setDefaults()
|
||||||
//
|
//
|
||||||
|
|
||||||
mBoolMap["DebugSkipInputLogging"] = {false, false};
|
mBoolMap["DebugSkipInputLogging"] = {false, false};
|
||||||
|
mBoolMap["DebugSkipMissingThemeFiles"] = {false, false};
|
||||||
|
mBoolMap["DebugSkipMissingThemeFilesCustomCollections"] = {true, true};
|
||||||
mStringMap["OpenGLVersion"] = {"", ""};
|
mStringMap["OpenGLVersion"] = {"", ""};
|
||||||
mStringMap["ROMDirectory"] = {"", ""};
|
mStringMap["ROMDirectory"] = {"", ""};
|
||||||
mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"};
|
mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"};
|
||||||
|
|
|
@ -393,13 +393,17 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
|
|
||||||
ThemeData::ThemeData()
|
ThemeData::ThemeData()
|
||||||
: mLegacyTheme {false}
|
: mLegacyTheme {false}
|
||||||
|
, mCustomCollection {false}
|
||||||
{
|
{
|
||||||
mCurrentThemeSet = mThemeSets.find(Settings::getInstance()->getString("ThemeSet"));
|
mCurrentThemeSet = mThemeSets.find(Settings::getInstance()->getString("ThemeSet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeData::loadFile(const std::map<std::string, std::string>& sysDataMap,
|
void ThemeData::loadFile(const std::map<std::string, std::string>& sysDataMap,
|
||||||
const std::string& path)
|
const std::string& path,
|
||||||
|
const bool customCollection)
|
||||||
{
|
{
|
||||||
|
mCustomCollection = customCollection;
|
||||||
|
|
||||||
mPaths.push_back(path);
|
mPaths.push_back(path);
|
||||||
|
|
||||||
ThemeException error;
|
ThemeException error;
|
||||||
|
@ -903,8 +907,28 @@ void ThemeData::parseIncludes(const pugi::xml_node& root)
|
||||||
for (pugi::xml_node node = root.child("include"); node; node = node.next_sibling("include")) {
|
for (pugi::xml_node node = root.child("include"); node; node = node.next_sibling("include")) {
|
||||||
std::string relPath {resolvePlaceholders(node.text().as_string())};
|
std::string relPath {resolvePlaceholders(node.text().as_string())};
|
||||||
std::string path {Utils::FileSystem::resolveRelativePath(relPath, mPaths.back(), true)};
|
std::string path {Utils::FileSystem::resolveRelativePath(relPath, mPaths.back(), true)};
|
||||||
if (!ResourceManager::getInstance().fileExists(path))
|
|
||||||
throw error << " -> \"" << relPath << "\" not found (resolved to \"" << path << "\")";
|
if (!ResourceManager::getInstance().fileExists(path)) {
|
||||||
|
// For explicit paths, throw an error if the file couldn't be found, but only
|
||||||
|
// print a debug message if it was set using a variable.
|
||||||
|
if (relPath == node.text().get()) {
|
||||||
|
throw error << " -> \"" << relPath << "\" not found (resolved to \"" << path
|
||||||
|
<< "\")";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!(Settings::getInstance()->getBool("DebugSkipMissingThemeFiles") ||
|
||||||
|
(mCustomCollection && Settings::getInstance()->getBool(
|
||||||
|
"DebugSkipMissingThemeFilesCustomCollections")))) {
|
||||||
|
LOG(LogDebug) << error.message << ": Couldn't find file \"" << node.text().get()
|
||||||
|
<< "\" "
|
||||||
|
<< ((node.text().get() != path) ?
|
||||||
|
"which resolves to \"" + path + "\"" :
|
||||||
|
"");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error << " -> \"" << relPath << "\"";
|
error << " -> \"" << relPath << "\"";
|
||||||
|
|
||||||
mPaths.push_back(path);
|
mPaths.push_back(path);
|
||||||
|
@ -1312,21 +1336,30 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
|
|
||||||
if (!ResourceManager::getInstance().fileExists(path)) {
|
if (!ResourceManager::getInstance().fileExists(path)) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
// For explicits paths, print a warning if the file couldn't be found, but
|
// For explicit paths, print a warning if the file couldn't be found, but
|
||||||
// only print a debug message if it was set using a variable.
|
// only print a debug message if it was set using a variable.
|
||||||
if (str == node.text().as_string()) {
|
if (str == node.text().as_string()) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
<< error.message << ": Couldn't find file \"" << node.text().get()
|
<< error.message << ": Couldn't find file \"" << node.text().get()
|
||||||
<< "\" "
|
<< "\" "
|
||||||
<< ((node.text().get() != path) ? "which resolves to \"" + path + "\"" :
|
<< ((node.text().get() != path) ? "which resolves to \"" + path + "\"" :
|
||||||
"");
|
"")
|
||||||
|
<< "(element type \"" << element.type << "\", name \""
|
||||||
|
<< root.attribute("name").as_string() << "\", property \"" << nodeName
|
||||||
|
<< "\")";
|
||||||
}
|
}
|
||||||
else {
|
else if (!(Settings::getInstance()->getBool("DebugSkipMissingThemeFiles") ||
|
||||||
|
(mCustomCollection &&
|
||||||
|
Settings::getInstance()->getBool(
|
||||||
|
"DebugSkipMissingThemeFilesCustomCollections")))) {
|
||||||
LOG(LogDebug)
|
LOG(LogDebug)
|
||||||
<< error.message << ": Couldn't find file \"" << node.text().get()
|
<< error.message << ": Couldn't find file \"" << node.text().get()
|
||||||
<< "\" "
|
<< "\" "
|
||||||
<< ((node.text().get() != path) ? "which resolves to \"" + path + "\"" :
|
<< ((node.text().get() != path) ? "which resolves to \"" + path + "\"" :
|
||||||
"");
|
"")
|
||||||
|
<< " (element type \"" << element.type << "\", name \""
|
||||||
|
<< root.attribute("name").as_string() << "\", property \"" << nodeName
|
||||||
|
<< "\")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.properties[nodeName] = path;
|
element.properties[nodeName] = path;
|
||||||
|
|
|
@ -203,7 +203,9 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void loadFile(const std::map<std::string, std::string>& sysDataMap, const std::string& path);
|
void loadFile(const std::map<std::string, std::string>& sysDataMap,
|
||||||
|
const std::string& path,
|
||||||
|
const bool customCollection);
|
||||||
bool hasView(const std::string& view);
|
bool hasView(const std::string& view);
|
||||||
ThemeView& getViewElements(std::string view) { return mViews[view]; }
|
ThemeView& getViewElements(std::string view) { return mViews[view]; }
|
||||||
|
|
||||||
|
@ -281,6 +283,7 @@ private:
|
||||||
std::string mSelectedVariant;
|
std::string mSelectedVariant;
|
||||||
std::string mSelectedAspectRatio;
|
std::string mSelectedAspectRatio;
|
||||||
bool mLegacyTheme;
|
bool mLegacyTheme;
|
||||||
|
bool mCustomCollection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_THEME_DATA_H
|
#endif // ES_CORE_THEME_DATA_H
|
||||||
|
|
Loading…
Reference in a new issue