mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
implemented feature element to allow themes to support new features w… (#96)
* implemented feature element to allow themes to support new features without breaking older versions of ES * supported attribute should only allow one value
This commit is contained in:
parent
0bb7134b5d
commit
49940d62d7
|
@ -23,6 +23,9 @@ ElementMapType makeMap(const T& mapInit)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> ThemeData::sSupportedViews = boost::assign::list_of("system")("basic")("detailed")("video");
|
||||||
|
std::vector<std::string> ThemeData::sSupportedFeatures = boost::assign::list_of("video");
|
||||||
|
|
||||||
std::map< std::string, ElementMapType > ThemeData::sElementMap = boost::assign::map_list_of
|
std::map< std::string, ElementMapType > ThemeData::sElementMap = boost::assign::map_list_of
|
||||||
("image", makeMap(boost::assign::map_list_of
|
("image", makeMap(boost::assign::map_list_of
|
||||||
("pos", NORMALIZED_PAIR)
|
("pos", NORMALIZED_PAIR)
|
||||||
|
@ -181,6 +184,7 @@ void ThemeData::loadFile(const std::string& path)
|
||||||
|
|
||||||
parseIncludes(root);
|
parseIncludes(root);
|
||||||
parseViews(root);
|
parseViews(root);
|
||||||
|
parseFeatures(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,11 +215,31 @@ void ThemeData::parseIncludes(const pugi::xml_node& root)
|
||||||
|
|
||||||
parseIncludes(root);
|
parseIncludes(root);
|
||||||
parseViews(root);
|
parseViews(root);
|
||||||
|
parseFeatures(root);
|
||||||
|
|
||||||
mPaths.pop_back();
|
mPaths.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemeData::parseFeatures(const pugi::xml_node& root)
|
||||||
|
{
|
||||||
|
ThemeException error;
|
||||||
|
error.setFiles(mPaths);
|
||||||
|
|
||||||
|
for(pugi::xml_node node = root.child("feature"); node; node = node.next_sibling("feature"))
|
||||||
|
{
|
||||||
|
if(!node.attribute("supported"))
|
||||||
|
throw error << "Feature missing \"supported\" attribute!";
|
||||||
|
|
||||||
|
const std::string supportedAttr = node.attribute("supported").as_string();
|
||||||
|
|
||||||
|
if (std::find(sSupportedFeatures.begin(), sSupportedFeatures.end(), supportedAttr) != sSupportedFeatures.end())
|
||||||
|
{
|
||||||
|
parseViews(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThemeData::parseViews(const pugi::xml_node& root)
|
void ThemeData::parseViews(const pugi::xml_node& root)
|
||||||
{
|
{
|
||||||
ThemeException error;
|
ThemeException error;
|
||||||
|
@ -238,8 +262,11 @@ void ThemeData::parseViews(const pugi::xml_node& root)
|
||||||
prevOff = nameAttr.find_first_not_of(delim, off);
|
prevOff = nameAttr.find_first_not_of(delim, off);
|
||||||
off = nameAttr.find_first_of(delim, prevOff);
|
off = nameAttr.find_first_of(delim, prevOff);
|
||||||
|
|
||||||
ThemeView& view = mViews.insert(std::pair<std::string, ThemeView>(viewKey, ThemeView())).first->second;
|
if (std::find(sSupportedViews.begin(), sSupportedViews.end(), viewKey) != sSupportedViews.end())
|
||||||
parseView(node, view);
|
{
|
||||||
|
ThemeView& view = mViews.insert(std::pair<std::string, ThemeView>(viewKey, ThemeView())).first->second;
|
||||||
|
parseView(node, view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,10 +149,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map< std::string, std::map<std::string, ElementPropertyType> > sElementMap;
|
static std::map< std::string, std::map<std::string, ElementPropertyType> > sElementMap;
|
||||||
|
static std::vector<std::string> sSupportedFeatures;
|
||||||
|
static std::vector<std::string> sSupportedViews;
|
||||||
|
|
||||||
std::deque<boost::filesystem::path> mPaths;
|
std::deque<boost::filesystem::path> mPaths;
|
||||||
float mVersion;
|
float mVersion;
|
||||||
|
|
||||||
|
void parseFeatures(const pugi::xml_node& themeRoot);
|
||||||
void parseIncludes(const pugi::xml_node& themeRoot);
|
void parseIncludes(const pugi::xml_node& themeRoot);
|
||||||
void parseViews(const pugi::xml_node& themeRoot);
|
void parseViews(const pugi::xml_node& themeRoot);
|
||||||
void parseView(const pugi::xml_node& viewNode, ThemeView& view);
|
void parseView(const pugi::xml_node& viewNode, ThemeView& view);
|
||||||
|
|
Loading…
Reference in a new issue