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"
39 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m)
41 static struct menu_priv_s cfg_dflt
= {
45 static m_option_t cfg_fields
[] = {
46 MENU_LIST_PRIV_FIELDS
,
47 { "title",M_ST_OFF(struct menu_priv_s
,p
.title
), CONF_TYPE_STRING
, 0, 0, 0, NULL
},
48 { NULL
, NULL
, NULL
, 0,0,0,NULL
}
51 #define mpriv (menu->priv)
53 static void read_cmd(menu_t
* menu
,int cmd
) {
56 if(mpriv
->p
.current
->right
) {
57 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->right
);
59 } // fallback on ok if right is not defined
61 if (mpriv
->p
.current
->ok
)
62 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->ok
);
65 if(mpriv
->p
.current
->left
) {
66 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->left
);
68 } // fallback on cancel if left is not defined
70 if(mpriv
->p
.current
->cancel
) {
71 mp_input_parse_and_queue_cmds(menu
->input_ctx
, mpriv
->p
.current
->cancel
);
75 menu_list_read_cmd(menu
,cmd
);
79 static void free_entry(list_entry_t
* entry
) {
92 static void close_menu(menu_t
* menu
) {
93 menu_list_uninit(menu
,free_entry
);
96 static int parse_args(menu_t
* menu
,char* args
) {
97 char *element
,*body
, **attribs
, *name
;
98 list_entry_t
* m
= NULL
;
100 ASX_Parser_t
* parser
= asx_parser_new(menu
->mconfig
);
103 r
= asx_get_element(parser
,&args
,&element
,&body
,&attribs
);
105 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_SyntaxErrorAtLine
,parser
->line
);
106 asx_parser_free(parser
);
109 asx_parser_free(parser
);
111 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition
);
115 name
= asx_get_attrib("name",attribs
);
117 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_ListMenuEntryDefinitionsNeedAName
,parser
->line
);
120 asx_free_attribs(attribs
);
123 m
= calloc(1,sizeof(struct list_entry_s
));
125 m
->ok
= asx_get_attrib("ok",attribs
);
126 m
->cancel
= asx_get_attrib("cancel",attribs
);
127 m
->left
= asx_get_attrib("left",attribs
);
128 m
->right
= asx_get_attrib("right",attribs
);
129 menu_list_add_entry(menu
,m
);
133 asx_free_attribs(attribs
);
137 static int open_cmdlist(menu_t
* menu
, char* args
) {
138 menu
->draw
= menu_list_draw
;
139 menu
->read_cmd
= read_cmd
;
140 menu
->close
= close_menu
;
143 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_ListMenuNeedsAnArgument
);
147 menu_list_init(menu
);
148 if(!parse_args(menu
,args
))
153 const menu_info_t menu_info_cmdlist
= {
160 sizeof(struct menu_priv_s
),