diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-10-12 12:03:07 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-10-12 12:03:07 +0000 |
commit | 69e379a47b6c7830fc17e912eecde6eb5100037f (patch) | |
tree | b6442e9c7ab6939c83b8565dbe20c5ff5fbd131e /apps | |
parent | e1c9eb31f79c1c403e03869f19b733fd2b5e7c0e (diff) |
Skin bar tags fix+cleanup:
Don't crash when not enough params were given (i.e forgetting the filename)
Make the parser enforce the first 4 params as compulsary
Be more leniant and don't require the image filename if one isnt going to be loaded (no more need for the - as the 5th param)
Add an option "image" to specify the filename (otherwise the first option will be used if it isnt a recognised option).
e.g: %pv(0,0,100,10) or %pv(0,0,100,10, bar.bmp) or %pv(0,0,100,10, ..., image, bar.bmp)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28247 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 75b4c4298f..5c169c81de 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -619,7 +619,7 @@ static int parse_progressbar_tag(struct skin_element* element, return -1; add_to_ll_chain(&wps_data->progressbars, item); - /* (x,y,width,height,filename) */ + /* (x, y, width, height, ...) */ if (!isdefault(param)) pb->x = param->data.number; else @@ -659,11 +659,15 @@ static int parse_progressbar_tag(struct skin_element* element, #endif } } - param++; - if (!isdefault(param)) - pb->bm.data = param->data.text; - - curr_param = 5; + /* optional params, first is the image filename if it isnt recognised as a keyword */ + + curr_param = 4; + if (isdefault(&element->params[curr_param])) + { + param++; + curr_param++; + } + pb->horizontal = pb->width > pb->height; while (curr_param < element->params_count) { @@ -679,9 +683,20 @@ static int parse_progressbar_tag(struct skin_element* element, curr_param++; param++; pb->slider = find_image(param->data.text, wps_data); - if (!pb->slider) - return -1; } + else /* option needs the next param */ + return -1; + } + else if (!strcmp(param->data.text, "image")) + { + if (curr_param+1 < element->params_count) + { + curr_param++; + param++; + pb->bm.data = param->data.text; + } + else /* option needs the next param */ + return -1; } else if (!strcmp(param->data.text, "vertical")) { @@ -691,6 +706,8 @@ static int parse_progressbar_tag(struct skin_element* element, } else if (!strcmp(param->data.text, "horizontal")) pb->horizontal = true; + else if (curr_param == 4) + pb->bm.data = param->data.text; curr_param++; } |