11 #include "libmpcodecs/img_format.h"
12 #include "libmpcodecs/mp_image.h"
16 #include "asxparser.h"
18 #include "menu_list.h"
20 #include "libvo/font_load.h"
22 #include "input/input.h"
40 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m)
42 static struct menu_priv_s cfg_dflt
= {
46 static m_option_t cfg_fields
[] = {
47 MENU_LIST_PRIV_FIELDS
,
48 { "title",M_ST_OFF(struct menu_priv_s
,p
.title
), CONF_TYPE_STRING
, 0, 0, 0, NULL
},
49 { NULL
, NULL
, NULL
, 0,0,0,NULL
}
52 #define mpriv (menu->priv)
54 static void read_cmd(menu_t
* menu
,int cmd
) {
57 if(mpriv
->p
.current
->right
) {
58 mp_input_parse_and_queue_cmds(mpriv
->p
.current
->right
);
60 } // fallback on ok if right is not defined
62 if (mpriv
->p
.current
->ok
)
63 mp_input_parse_and_queue_cmds(mpriv
->p
.current
->ok
);
66 if(mpriv
->p
.current
->left
) {
67 mp_input_parse_and_queue_cmds(mpriv
->p
.current
->left
);
69 } // fallback on cancel if left is not defined
71 if(mpriv
->p
.current
->cancel
) {
72 mp_input_parse_and_queue_cmds(mpriv
->p
.current
->cancel
);
76 menu_list_read_cmd(menu
,cmd
);
80 static void free_entry(list_entry_t
* entry
) {
93 static void close_menu(menu_t
* menu
) {
94 menu_list_uninit(menu
,free_entry
);
97 static int parse_args(menu_t
* menu
,char* args
) {
98 char *element
,*body
, **attribs
, *name
;
99 list_entry_t
* m
= NULL
;
101 ASX_Parser_t
* parser
= asx_parser_new(menu
->mconfig
);
104 r
= asx_get_element(parser
,&args
,&element
,&body
,&attribs
);
106 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_SyntaxErrorAtLine
,parser
->line
);
107 asx_parser_free(parser
);
110 asx_parser_free(parser
);
112 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition
);
116 name
= asx_get_attrib("name",attribs
);
118 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_ListMenuEntryDefinitionsNeedAName
,parser
->line
);
121 asx_free_attribs(attribs
);
124 m
= calloc(1,sizeof(struct list_entry_s
));
126 m
->ok
= asx_get_attrib("ok",attribs
);
127 m
->cancel
= asx_get_attrib("cancel",attribs
);
128 m
->left
= asx_get_attrib("left",attribs
);
129 m
->right
= asx_get_attrib("right",attribs
);
130 menu_list_add_entry(menu
,m
);
134 asx_free_attribs(attribs
);
138 static int open_cmdlist(menu_t
* menu
, char* args
) {
139 menu
->draw
= menu_list_draw
;
140 menu
->read_cmd
= read_cmd
;
141 menu
->close
= close_menu
;
144 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_ListMenuNeedsAnArgument
);
148 menu_list_init(menu
);
149 if(!parse_args(menu
,args
))
154 const menu_info_t menu_info_cmdlist
= {
161 sizeof(struct menu_priv_s
),