/** * @brief Parse a @a dlabel definition. * * Syntax: dlabel=x,y,width,align,fontfile,"text" * * @param in definition to be analyzed * * @return 0 (ok) or 1 (error) */ static int item_dlabel(char *in) { int x, y, w, a, id; char fnt[256]; char txt[256]; wItem *item; if (!window_item("dlabel")) return 1; if (in_window("video")) return 1; if (in_window("menu")) return 1; x = cutItemToInt(in, ',', 0); y = cutItemToInt(in, ',', 1); w = cutItemToInt(in, ',', 2); a = cutItemToInt(in, ',', 3); cutItem(in, fnt, ',', 4); cutItem(in, txt, ',', 5); cutItem(txt, txt, '"', 1); mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] dlabel: \"%s\"\n", txt); mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] pos: %d,%d\n", x, y); mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] width: %d, align: %d\n", w, a); id = fntFindID(fnt); if (id < 0) { skin_error(MSGTR_SKIN_FONT_NonExistentFont, fnt); return 1; } mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, id); item = next_item(); if (!item) return 1; item->type = itDLabel; item->x = x; item->y = y; item->width = w; item->height = -1; item->fontid = id; item->align = a; item->label = strdup(txt); if (!item->label) { skin_error(MSGTR_SKIN_NotEnoughMemory); return 1; } return 0; }
int cmd_dlabel( char * in ) { // dlabel=x,y,sx,align,fontid,string ... char tmp[512]; char sid[63]; int x,y,sx,id,a; wItem * item; CHECKDEFLIST( "dlabel" ); CHECKWINLIST( "dlabel" ); CHECK( "sub" ); CHECK( "menu" ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" ); x=cutItemToInt( in,',',0 ); y=cutItemToInt( in,',',1 ); sx=cutItemToInt( in,',',2 ); a=cutItemToInt( in,',',3 ); cutItem( in,sid,',',4 ); id=fntFindID( sid ); if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; } cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] pos: %d,%d width: %d align: %d\n",x,y,sx,a ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] id: %s ( %d )\n",sid,id ); mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] str: '%s'\n",tmp ); (*currSubItem)++; item=&currSubItems[ *currSubItem ]; item->type=itDLabel; item->fontid=id; item->align=a; item->x=x; item->y=y; item->width=sx; item->height=-1; if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; } strcpy( item->label,tmp ); return 0; }
/** * @brief Parse a @a font definition. * * Syntax: font=fontfile * * @param in definition to be analyzed * * @return 0 (ok) or 1 (error) */ static int item_font(char *in) { char fnt[256]; if (!window_item("font")) return 1; if (in_window("video")) return 1; if (in_window("menu")) return 1; cutItem(in, fnt, ',', 0); // Note: This seems needless but isn't for compatibility // reasons with a meanwhile depreciated second parameter. switch (fntRead(path, fnt)) { case -1: skin_error(MSGTR_SKIN_NotEnoughMemory); return 1; case -2: skin_error(MSGTR_SKIN_FONT_TooManyFontsDeclared); return 1; case -3: skin_error(MSGTR_SKIN_FONT_FontFileNotFound); return 1; case -4: skin_error(MSGTR_SKIN_FONT_FontImageNotFound); return 1; } mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] font: %s (#%d)\n", fnt, fntFindID(fnt)); return 0; }