diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 1959b3282..dee6fc7bb 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -1335,7 +1335,7 @@ void SystemData::loadTheme() sysData.insert(std::pair("system.theme.collections", "\b")); } - mTheme->loadFile(sysData, path); + mTheme->loadFile(sysData, path, isCustomCollection()); } catch (ThemeException& e) { LOG(LogError) << e.what(); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 6d0ffc326..64e0a064d 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -285,6 +285,8 @@ void Settings::setDefaults() // mBoolMap["DebugSkipInputLogging"] = {false, false}; + mBoolMap["DebugSkipMissingThemeFiles"] = {false, false}; + mBoolMap["DebugSkipMissingThemeFilesCustomCollections"] = {true, true}; mStringMap["OpenGLVersion"] = {"", ""}; mStringMap["ROMDirectory"] = {"", ""}; mStringMap["UIMode_passkey"] = {"uuddlrlrba", "uuddlrlrba"}; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 9782de7ee..672bd6208 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -393,13 +393,17 @@ std::map> ThemeData::ThemeData() : mLegacyTheme {false} + , mCustomCollection {false} { mCurrentThemeSet = mThemeSets.find(Settings::getInstance()->getString("ThemeSet")); } void ThemeData::loadFile(const std::map& sysDataMap, - const std::string& path) + const std::string& path, + const bool customCollection) { + mCustomCollection = customCollection; + mPaths.push_back(path); 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")) { std::string relPath {resolvePlaceholders(node.text().as_string())}; 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 << "\""; mPaths.push_back(path); @@ -1312,21 +1336,30 @@ void ThemeData::parseElement(const pugi::xml_node& root, if (!ResourceManager::getInstance().fileExists(path)) { 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. if (str == node.text().as_string()) { LOG(LogWarning) << error.message << ": Couldn't find file \"" << node.text().get() << "\" " << ((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) << error.message << ": Couldn't find file \"" << node.text().get() << "\" " << ((node.text().get() != path) ? "which resolves to \"" + path + "\"" : - ""); + "") + << " (element type \"" << element.type << "\", name \"" + << root.attribute("name").as_string() << "\", property \"" << nodeName + << "\")"; } } element.properties[nodeName] = path; diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index 01931e3a0..044b48ab6 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -203,7 +203,9 @@ public: } }; - void loadFile(const std::map& sysDataMap, const std::string& path); + void loadFile(const std::map& sysDataMap, + const std::string& path, + const bool customCollection); bool hasView(const std::string& view); ThemeView& getViewElements(std::string view) { return mViews[view]; } @@ -281,6 +283,7 @@ private: std::string mSelectedVariant; std::string mSelectedAspectRatio; bool mLegacyTheme; + bool mCustomCollection; }; #endif // ES_CORE_THEME_DATA_H