From 943de3ce49e3ff4bbdefa7459dbc3b885fe145ad Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 28 Oct 2010 11:00:36 +0000 Subject: skin_parser: Change the way hardware conditionals are done (i.e %?cc) They now only parse the correct branch (so only the true branch, or only the false branch). This shuold allow you to load different images/backdrops with the same id's depending on the targets hardware. Add a new %Tp - "touchscreen present?" tag to check if the target has a touchscreen git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28370 a1c6a512-1295-4272-9138-f99709370657 --- lib/skin_parser/skin_parser.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/skin_parser/skin_parser.c') diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 64ac462..f574d3f 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -877,6 +877,7 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc #ifdef ROCKBOX bool feature_available = true; const char *false_branch = NULL; + const char *conditional_end = NULL; #endif /* Some conditional tags allow for target feature checking, @@ -955,6 +956,12 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc false_branch = cursor+1; children--; } + if (element->tag->flags&FEATURE_TAG) + { + if (feature_available) + children--; + } + conditional_end = cursor; /* if we are skipping the true branch fix that up */ cursor = false_branch ? false_branch : bookmark; #else @@ -969,7 +976,13 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc for(i = 0; i < children; i++) { element->children[i] = skin_parse_code_as_arg(&cursor); + if (element->children[i] == NULL) + return 0; skip_whitespace(&cursor); +#ifdef ROCKBOX + if ((element->tag->flags&FEATURE_TAG) && feature_available) + cursor = conditional_end; +#endif if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM) { @@ -986,7 +999,6 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc cursor++; } } - *document = cursor; return 1; -- cgit v1.1