mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
redo r24943. the font mappings are not needed once the skin is finished parsing so using the skin buffer there is a waste and overcomplicates things.
Also that commit breaks plain %pb so make sure you dont use %pb inside a viewport with a font number > 1 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24957 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8c5eaa35ec
commit
8717c1eaa1
3 changed files with 27 additions and 49 deletions
|
@ -431,18 +431,6 @@ struct gui_img* find_image(char label, struct wps_data *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct skin_font* find_font(int id, struct wps_data *data)
|
|
||||||
{
|
|
||||||
struct skin_token_list *list = data->fonts;
|
|
||||||
while (list)
|
|
||||||
{
|
|
||||||
struct skin_font *f = (struct skin_font*)list->token->value.data;
|
|
||||||
if (f->id == id)
|
|
||||||
return f;
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* traverse the viewport linked list for a viewport */
|
/* traverse the viewport linked list for a viewport */
|
||||||
|
@ -705,10 +693,11 @@ static int parse_image_load(const char *wps_bufptr,
|
||||||
/* Skip the rest of the line */
|
/* Skip the rest of the line */
|
||||||
return skip_end_of_line(wps_bufptr);
|
return skip_end_of_line(wps_bufptr);
|
||||||
}
|
}
|
||||||
|
struct skin_font {
|
||||||
/* this array acts as a simple mapping between the id the user uses for a font
|
int id; /* the id from font_load */
|
||||||
* and the id the font actually gets from the font loader.
|
char *name; /* filename without path and extension */
|
||||||
* font id 2 is always the first skin font (regardless of how many screens */
|
};
|
||||||
|
static struct skin_font skinfonts[MAXUSERFONTS];
|
||||||
static int parse_font_load(const char *wps_bufptr,
|
static int parse_font_load(const char *wps_bufptr,
|
||||||
struct wps_token *token, struct wps_data *wps_data)
|
struct wps_token *token, struct wps_data *wps_data)
|
||||||
{
|
{
|
||||||
|
@ -716,7 +705,6 @@ static int parse_font_load(const char *wps_bufptr,
|
||||||
const char *ptr = wps_bufptr;
|
const char *ptr = wps_bufptr;
|
||||||
int id;
|
int id;
|
||||||
char *filename;
|
char *filename;
|
||||||
struct skin_font *font;
|
|
||||||
|
|
||||||
if (*ptr != '|')
|
if (*ptr != '|')
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
@ -732,24 +720,15 @@ static int parse_font_load(const char *wps_bufptr,
|
||||||
|
|
||||||
if (id <= FONT_UI || id >= MAXFONTS-1)
|
if (id <= FONT_UI || id >= MAXFONTS-1)
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
|
#if defined(DEBUG) || defined(SIMULATOR)
|
||||||
font = skin_buffer_alloc(sizeof(struct skin_font));
|
if (skinfonts[id-FONT_FIRSTUSERFONT].name != NULL)
|
||||||
int len = ptr-filename+1;
|
{
|
||||||
char* name = skin_buffer_alloc(len);
|
DEBUGF("font id %d already being used\n", id);
|
||||||
if (!font || !name)
|
}
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
#endif
|
||||||
|
skinfonts[id-FONT_FIRSTUSERFONT].id = -1;
|
||||||
strlcpy(name, filename, len);
|
skinfonts[id-FONT_FIRSTUSERFONT].name = filename;
|
||||||
font->id = id;
|
|
||||||
font->font_id = -1;
|
|
||||||
font->name = name;
|
|
||||||
|
|
||||||
struct skin_token_list *item = new_skin_token_list_item(NULL, font);
|
|
||||||
|
|
||||||
if (!item)
|
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
|
||||||
add_to_ll_chain(&wps_data->fonts, item);
|
|
||||||
|
|
||||||
return skip_end_of_line(wps_bufptr);
|
return skip_end_of_line(wps_bufptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1974,7 +1953,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
|
||||||
static void skin_data_reset(struct wps_data *wps_data)
|
static void skin_data_reset(struct wps_data *wps_data)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
wps_data->images = wps_data->progressbars = wps_data->fonts = NULL;
|
wps_data->images = NULL;
|
||||||
|
wps_data->progressbars = NULL;
|
||||||
#endif
|
#endif
|
||||||
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
||||||
wps_data->backdrop = NULL;
|
wps_data->backdrop = NULL;
|
||||||
|
@ -2121,7 +2101,7 @@ static bool skin_load_fonts(struct wps_data *data)
|
||||||
int skin_font_id = vp->font-1;
|
int skin_font_id = vp->font-1;
|
||||||
|
|
||||||
/* now find the corresponding skin_font */
|
/* now find the corresponding skin_font */
|
||||||
struct skin_font *font = find_font(skin_font_id, data);
|
struct skin_font *font = &skinfonts[skin_font_id-FONT_FIRSTUSERFONT];
|
||||||
if (!font)
|
if (!font)
|
||||||
{
|
{
|
||||||
DEBUGF("Could not find font %d\n", skin_font_id);
|
DEBUGF("Could not find font %d\n", skin_font_id);
|
||||||
|
@ -2131,10 +2111,14 @@ static bool skin_load_fonts(struct wps_data *data)
|
||||||
|
|
||||||
/* load the font - will handle loading the same font again if
|
/* load the font - will handle loading the same font again if
|
||||||
* multiple viewports use the same */
|
* multiple viewports use the same */
|
||||||
if (font->font_id < 0)
|
if (font->id < 0)
|
||||||
font->font_id = skin_font_load(font->name);
|
{
|
||||||
|
char *bar = strchr(font->name, '|');
|
||||||
|
*bar = '\0';
|
||||||
|
font->id = skin_font_load(font->name);
|
||||||
|
}
|
||||||
|
|
||||||
if (font->font_id < 0)
|
if (font->id < 0)
|
||||||
{
|
{
|
||||||
DEBUGF("Unable to load font %d: '%s.fnt'\n",
|
DEBUGF("Unable to load font %d: '%s.fnt'\n",
|
||||||
skin_font_id, font->name);
|
skin_font_id, font->name);
|
||||||
|
@ -2143,7 +2127,7 @@ static bool skin_load_fonts(struct wps_data *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finally, assign the font_id to the viewport */
|
/* finally, assign the font_id to the viewport */
|
||||||
vp->font = font->font_id;
|
vp->font = font->id;
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -264,12 +264,6 @@ struct skin_albumart {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct skin_font {
|
|
||||||
int id; /* the id used in the %V tags */
|
|
||||||
int font_id; /* the id returned by font_load */
|
|
||||||
char *name; /* filename without path and extension */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* wps_data
|
/* wps_data
|
||||||
this struct holds all necessary data which describes the
|
this struct holds all necessary data which describes the
|
||||||
viewable content of a wps */
|
viewable content of a wps */
|
||||||
|
@ -278,7 +272,6 @@ struct wps_data
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
struct skin_token_list *images;
|
struct skin_token_list *images;
|
||||||
struct skin_token_list *progressbars;
|
struct skin_token_list *progressbars;
|
||||||
struct skin_token_list *fonts;
|
|
||||||
#endif
|
#endif
|
||||||
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
||||||
char *backdrop;
|
char *backdrop;
|
||||||
|
|
|
@ -51,7 +51,8 @@ enum {
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
FONT_UI_REMOTE, /* UI font for remote LCD */
|
FONT_UI_REMOTE, /* UI font for remote LCD */
|
||||||
#endif
|
#endif
|
||||||
SYSTEMFONTCOUNT /* Number of fonts reserved for the system and ui */
|
SYSTEMFONTCOUNT, /* Number of fonts reserved for the system and ui */
|
||||||
|
FONT_FIRSTUSERFONT = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXFONTS 10
|
#define MAXFONTS 10
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue