mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-12-01 18:45:39 +00:00
Added a workaround for legacy theme sets where the md_releasedate and md_lastplayed element types have incorrectly been defined as text instead of datetime.
This commit is contained in:
parent
141700af80
commit
5699988767
|
@ -1104,14 +1104,29 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
||||||
off = nameAttr.find_first_of(delim, prevOff);
|
off = nameAttr.find_first_of(delim, prevOff);
|
||||||
|
|
||||||
// Add the element type as a prefix to avoid name collisions between different
|
// Add the element type as a prefix to avoid name collisions between different
|
||||||
// component types.
|
// component types. Also include a workaround for legacy theme sets if the
|
||||||
|
// md_releasedate and md_lastplayed element types are incorrectly defined as
|
||||||
|
// text instead of datetime.
|
||||||
const std::string elementType {node.name()};
|
const std::string elementType {node.name()};
|
||||||
elemKey = std::string(node.name()) + "_" + elemKey;
|
bool dateTimeWorkaround {false};
|
||||||
|
|
||||||
|
if (mLegacyTheme && elementType == "text" &&
|
||||||
|
(elemKey == "md_releasedate" || elemKey == "md_lastplayed")) {
|
||||||
|
LOG(LogDebug) << "ThemeData::parseView(): Element type for \"" << elemKey
|
||||||
|
<< "\" incorrectly set to \"text\" "
|
||||||
|
"instead of \"datetime\", applying workaround";
|
||||||
|
dateTimeWorkaround = true;
|
||||||
|
elemKey = "datetime_" + elemKey;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elemKey = elementType + "_" + elemKey;
|
||||||
|
}
|
||||||
|
|
||||||
parseElement(
|
parseElement(
|
||||||
node, elemTypeIt->second,
|
node, elemTypeIt->second,
|
||||||
view.elements.insert(std::pair<std::string, ThemeElement>(elemKey, ThemeElement()))
|
view.elements.insert(std::pair<std::string, ThemeElement>(elemKey, ThemeElement()))
|
||||||
.first->second);
|
.first->second,
|
||||||
|
dateTimeWorkaround);
|
||||||
|
|
||||||
if (mLegacyTheme &&
|
if (mLegacyTheme &&
|
||||||
std::find(view.legacyOrderedKeys.cbegin(), view.legacyOrderedKeys.cend(),
|
std::find(view.legacyOrderedKeys.cbegin(), view.legacyOrderedKeys.cend(),
|
||||||
|
@ -1123,12 +1138,16 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
||||||
|
|
||||||
void ThemeData::parseElement(const pugi::xml_node& root,
|
void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
const std::map<std::string, ElementPropertyType>& typeMap,
|
const std::map<std::string, ElementPropertyType>& typeMap,
|
||||||
ThemeElement& element)
|
ThemeElement& element,
|
||||||
|
bool dateTimeWorkaround)
|
||||||
{
|
{
|
||||||
ThemeException error;
|
ThemeException error;
|
||||||
error << "ThemeData::parseElement(): ";
|
error << "ThemeData::parseElement(): ";
|
||||||
error.setFiles(mPaths);
|
error.setFiles(mPaths);
|
||||||
|
|
||||||
|
if (dateTimeWorkaround)
|
||||||
|
element.type = "datetime";
|
||||||
|
else
|
||||||
element.type = root.name();
|
element.type = root.name();
|
||||||
|
|
||||||
element.extra = root.attribute("extra").as_bool(false);
|
element.extra = root.attribute("extra").as_bool(false);
|
||||||
|
|
|
@ -252,7 +252,8 @@ private:
|
||||||
void parseView(const pugi::xml_node& viewNode, ThemeView& view);
|
void parseView(const pugi::xml_node& viewNode, ThemeView& view);
|
||||||
void parseElement(const pugi::xml_node& elementNode,
|
void parseElement(const pugi::xml_node& elementNode,
|
||||||
const std::map<std::string, ElementPropertyType>& typeMap,
|
const std::map<std::string, ElementPropertyType>& typeMap,
|
||||||
ThemeElement& element);
|
ThemeElement& element,
|
||||||
|
bool dateTimeWorkaround = false);
|
||||||
|
|
||||||
static std::vector<std::string> sSupportedViews;
|
static std::vector<std::string> sSupportedViews;
|
||||||
static std::vector<std::string> sLegacySupportedViews;
|
static std::vector<std::string> sLegacySupportedViews;
|
||||||
|
|
Loading…
Reference in a new issue