summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-08-18 07:17:51 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-08-18 07:17:51 +0000
commitdab7e161767f951a55d6fbc0988fae5f3d9df474 (patch)
tree7fe7a5dcbc9fa3bd2ff270fee738f36e05c9dd90
parent36ca4967e0ced08ab8d262ba046189e6dfbe71da (diff)
downloadrockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.zip
rockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.tar.gz
rockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.tar.bz2
rockbox-dab7e161767f951a55d6fbc0988fae5f3d9df474.tar.xz
store the image label instead of a number so debug output is actually useful when %xd is used witout a coresponding %xl
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22404 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/skin_engine/skin_display.c6
-rw-r--r--apps/gui/skin_engine/skin_parser.c24
-rw-r--r--apps/gui/skin_engine/wps_debug.c4
-rw-r--r--apps/gui/skin_engine/wps_internals.h4
4 files changed, 16 insertions, 22 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 1e88863..6b86a8b 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -478,13 +478,13 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
return true;
}
#ifdef HAVE_LCD_BITMAP
-struct gui_img* find_image(int n, struct wps_data *data)
+struct gui_img* find_image(char label, struct wps_data *data)
{
struct skin_token_list *list = data->images;
while (list)
{
struct gui_img *img = (struct gui_img *)list->token->value.data;
- if (img->id == n)
+ if (img->label == label)
return img;
list = list->next;
}
@@ -555,7 +555,7 @@ static bool get_line(struct gui_wps *gwps,
#ifdef HAVE_LCD_BITMAP
case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
{
- int n = data->tokens[i].value.i & 0xFF;
+ char n = data->tokens[i].value.i & 0xFF;
int subimage = data->tokens[i].value.i >> 8;
struct gui_img *img = find_image(n, data);
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 82083e8..b7f2ec3 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -482,19 +482,17 @@ static int parse_image_display(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
{
- int n = get_image_id(wps_bufptr[0]);
+ char label = wps_bufptr[0];
int subimage;
struct gui_img *img;;
- if (n == -1)
- {
- /* invalid picture display tag */
- return WPS_ERROR_INVALID_PARAM;
- }
/* sanity check */
- img = find_image(n, wps_data);
+ img = find_image(label, wps_data);
if (!img)
+ {
+ token->value.i = label; /* do debug works */
return WPS_ERROR_INVALID_PARAM;
+ }
if ((subimage = get_image_id(wps_bufptr[1])) != -1)
{
@@ -502,10 +500,10 @@ static int parse_image_display(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM;
/* Store sub-image number to display in high bits */
- token->value.i = n | (subimage << 8);
+ token->value.i = label | (subimage << 8);
return 2; /* We have consumed 2 bytes */
} else {
- token->value.i = n;
+ token->value.i = label;
return 1; /* We have consumed 1 byte */
}
}
@@ -514,7 +512,6 @@ static int parse_image_load(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
{
- int n;
const char *ptr = wps_bufptr;
const char *pos;
const char* filename;
@@ -540,11 +537,8 @@ static int parse_image_load(const char *wps_bufptr,
if (*ptr != '|')
return WPS_ERROR_INVALID_PARAM;
- /* get the image ID */
- n = get_image_id(*id);
-
/* check the image number and load state */
- if(n < 0 || find_image(n, wps_data))
+ if(find_image(*id, wps_data))
{
/* Invalid image ID */
return WPS_ERROR_INVALID_PARAM;
@@ -554,7 +548,7 @@ static int parse_image_load(const char *wps_bufptr,
return WPS_ERROR_INVALID_PARAM;
/* save a pointer to the filename */
img->bm.data = (char*)filename;
- img->id = n;
+ img->label = *id;
img->x = x;
img->y = y;
img->num_subimages = 1;
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
index e3e6e96..60f53b8 100644
--- a/apps/gui/skin_engine/wps_debug.c
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -113,8 +113,8 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data,
break;
case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY:
- snprintf(buf, bufsize, "display preloaded image %d",
- token->value.i);
+ snprintf(buf, bufsize, "display preloaded image '%c'",
+ token->value.i&0xFF);
break;
case WPS_TOKEN_IMAGE_DISPLAY:
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 4136347..0adae04 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -77,7 +77,7 @@
#ifdef HAVE_LCD_BITMAP
struct gui_img {
- short int id;
+ char label;
struct bitmap bm;
struct viewport* vp; /* The viewport to display this image in */
short int x; /* x-pos */
@@ -346,7 +346,7 @@ const char *get_token_value(struct gui_wps *gwps,
-struct gui_img* find_image(int n, struct wps_data *data);
+struct gui_img* find_image(char label, struct wps_data *data);
struct skin_viewport* find_viewport(char label, struct wps_data *data);
#endif