diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c index 8aa4fff208..dd79b26168 100644 --- a/menu/cbs/menu_cbs_select.c +++ b/menu/cbs/menu_cbs_select.c @@ -94,7 +94,7 @@ static int action_select_default( if (action != MENU_ACTION_NOOP) { menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); /* Note: If menu_entry_action() is modified, * will have to verify that these parameters diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 5bbea13ffc..f70610e5d5 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -2668,7 +2668,7 @@ static unsigned materialui_count_sublabel_lines( wrapped_sublabel_str[0] = '\0'; /* Get entry sublabel */ - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -4931,7 +4931,7 @@ static void materialui_render_menu_list( break; /* Get current entry */ - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.value_enabled = entry_value_enabled; entry.sublabel_enabled = entry_sublabel_enabled; @@ -6060,7 +6060,7 @@ static void materialui_show_fullscreen_thumbnails( mui->fullscreen_thumbnail_label[0] = '\0'; /* > Get menu entry */ - menu_entry_init(&selected_entry); + MENU_ENTRY_INIT(selected_entry); selected_entry.path_enabled = false; selected_entry.value_enabled = false; selected_entry.sublabel_enabled = false; @@ -8791,7 +8791,7 @@ static int materialui_menu_entry_action( /* Selection has changed - must update entry * pointer (we could probably get away without * doing this, but it would break the API...) */ - menu_entry_init(&new_entry); + MENU_ENTRY_INIT(new_entry); new_entry.path_enabled = false; new_entry.label_enabled = false; new_entry.rich_label_enabled = false; @@ -9186,7 +9186,7 @@ static int materialui_pointer_up_swipe_horz_default( menu_entry_t last_entry; /* Get entry */ - menu_entry_init(&last_entry); + MENU_ENTRY_INIT(last_entry); last_entry.path_enabled = false; last_entry.label_enabled = false; last_entry.rich_label_enabled = false; diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 7920ae04bc..6f7dbb60f7 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -103,7 +103,7 @@ static void ozone_set_thumbnail_content(void *data, const char *s) menu_entry_t entry; size_t selection = menu_navigation_get_selection(); - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.label_enabled = false; entry.rich_label_enabled = false; entry.value_enabled = false; @@ -124,7 +124,7 @@ static void ozone_set_thumbnail_content(void *data, const char *s) if (node) { - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.label_enabled = false; entry.rich_label_enabled = false; entry.value_enabled = false; @@ -511,7 +511,7 @@ static int ozone_menu_entry_action( { /* Selection has changed - must update * entry pointer */ - menu_entry_init(&new_entry); + MENU_ENTRY_INIT(new_entry); new_entry.path_enabled = false; new_entry.label_enabled = false; new_entry.rich_label_enabled = false; @@ -2508,7 +2508,7 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation) uintptr_t tag = (uintptr_t)selection_buf; size_t selection = menu_navigation_get_selection(); - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -3869,7 +3869,7 @@ void ozone_show_fullscreen_thumbnails(ozone_handle_t *ozone) ozone->fullscreen_thumbnail_label[0] = '\0'; /* > Get menu entry */ - menu_entry_init(&selected_entry); + MENU_ENTRY_INIT(selected_entry); selected_entry.path_enabled = false; selected_entry.value_enabled = false; selected_entry.sublabel_enabled = false; diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 11b64a9f8c..daf51118ca 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -340,7 +340,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) menu_entry_t entry; ozone_node_t *node = NULL; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -682,7 +682,7 @@ border_iterate: entry_selected = selection == i; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; menu_entry_get(&entry, 0, (unsigned)i, selection_buf, true); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 8892078bb9..97c555993c 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -3831,7 +3831,7 @@ static void rgui_render(void *data, type_str_buf[0] = '\0'; /* Get current entry */ - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.sublabel_enabled = false; @@ -5107,7 +5107,7 @@ static void rgui_update_menu_sublabel(rgui_t *rgui) { menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index ac3200419b..cf122d095d 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -900,7 +900,7 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos) new_path[0] = '\0'; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, i, NULL, true); entry_type = entry.type; @@ -1031,7 +1031,7 @@ static void stripes_update_savestate_thumbnail_path(void *data, unsigned i) if (!stripes) return; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, i, NULL, true); if (!string_is_empty(stripes->savestate_thumbnail_file_path)) @@ -1192,11 +1192,10 @@ static void stripes_selection_pointer_changed( const char *thumb_ident = stripes_thumbnails_ident('R'); const char *lft_thumb_ident= stripes_thumbnails_ident('L'); - menu_entry_init(&entry); - if (!stripes) return; + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, selection, NULL, true); end = (unsigned)menu_entries_get_size(); @@ -1751,7 +1750,7 @@ static void stripes_list_switch(stripes_handle_t *stripes) { menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, selection, NULL, true); if (!string_is_empty(entry.path)) @@ -1765,7 +1764,7 @@ static void stripes_list_switch(stripes_handle_t *stripes) { menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, selection, NULL, true); if (!string_is_empty(entry.path)) @@ -2660,7 +2659,7 @@ static void stripes_draw_items( { int ret; menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, i, list, true); ret = stripes_draw_item( userdata, diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 75bbf69842..ac50ed5d98 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1068,7 +1068,7 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i) { menu_entry_t entry; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.rich_label_enabled = false; entry.value_enabled = false; @@ -1290,7 +1290,7 @@ static void xmb_set_thumbnail_content(void *data, const char *s) menu_entry_t entry; size_t selection = menu_navigation_get_selection(); - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.label_enabled = false; entry.rich_label_enabled = false; entry.value_enabled = false; @@ -1314,7 +1314,7 @@ static void xmb_set_thumbnail_content(void *data, const char *s) if (node) { - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.label_enabled = false; entry.rich_label_enabled = false; entry.value_enabled = false; @@ -1444,7 +1444,7 @@ static void xmb_selection_pointer_changed( { menu_entry_t entry; unsigned entry_type; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -3082,7 +3082,7 @@ static int xmb_draw_item( if (icon_x < -half_size || icon_x > width) return 0; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.label_enabled = false; entry.sublabel_enabled = (i == current); menu_entry_get(&entry, 0, i, list, true); @@ -3667,7 +3667,7 @@ static void xmb_show_fullscreen_thumbnails( xmb->fullscreen_thumbnail_label[0] = '\0'; /* > Get menu entry */ - menu_entry_init(&selected_entry); + MENU_ENTRY_INIT(selected_entry); selected_entry.path_enabled = false; selected_entry.value_enabled = false; selected_entry.sublabel_enabled = false; @@ -3928,7 +3928,7 @@ static void xmb_render(void *data, if (get_entry) { - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 06d295b57f..96e71c2d0b 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -198,13 +198,43 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data); void menu_entries_set_checked(file_list_t *list, size_t entry_idx, bool checked); +/* Menu entry interface - + * + * This provides an abstraction of the currently displayed + * menu. + * + * It is organized into an event-based system where the UI companion + * calls this functions and RetroArch responds by changing the global + * state (including arranging for these functions to return different + * values). + * + * Its only interaction back to the UI is to arrange for + * notify_list_loaded on the UI companion. + */ + void menu_entry_get(menu_entry_t *entry, size_t stack_idx, size_t i, void *userdata, bool use_representation); int menu_entry_action( menu_entry_t *entry, size_t i, enum menu_action action); -void menu_entry_init(menu_entry_t *entry); +#define MENU_ENTRY_INIT(entry) \ + entry.path[0] = '\0'; \ + entry.label[0] = '\0'; \ + entry.sublabel[0] = '\0'; \ + entry.rich_label[0] = '\0'; \ + entry.value[0] = '\0'; \ + entry.password_value[0] = '\0'; \ + entry.enum_idx = MSG_UNKNOWN; \ + entry.entry_idx = 0; \ + entry.idx = 0; \ + entry.type = 0; \ + entry.spacing = 0; \ + entry.path_enabled = true; \ + entry.label_enabled = true; \ + entry.rich_label_enabled = true; \ + entry.value_enabled = true; \ + entry.sublabel_enabled = true RETRO_END_DECLS diff --git a/retroarch.c b/retroarch.c index 0fcd4c2baf..4b2dff5774 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4357,7 +4357,7 @@ static void get_current_menu_value(struct rarch_state *p_rarch, const char* entry_label; struct menu_state *menu_st = &p_rarch->menu_driver_state; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -4379,7 +4379,7 @@ static void get_current_menu_label(struct rarch_state *p_rarch, const char* entry_label; struct menu_state *menu_st = &p_rarch->menu_driver_state; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true); if (!string_is_empty(entry.rich_label)) @@ -4396,7 +4396,7 @@ static void get_current_menu_sublabel(struct rarch_state *p_rarch, menu_entry_t entry; struct menu_state *menu_st = &p_rarch->menu_driver_state; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); entry.path_enabled = false; entry.label_enabled = false; entry.rich_label_enabled = false; @@ -4694,7 +4694,7 @@ static int generic_menu_iterate( * should not rely on a hack like this in order to work. */ selection = MAX(MIN(selection, (menu_entries_get_size() - 1)), 0); - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); /* NOTE: If menu_entry_action() is modified, * will have to verify that these parameters * remain unused... */ @@ -5030,39 +5030,6 @@ void menu_navigation_set_selection(size_t val) menu_st->selection_ptr = val; } -/* Menu entry interface - - * - * This provides an abstraction of the currently displayed - * menu. - * - * It is organized into an event-based system where the UI companion - * calls this functions and RetroArch responds by changing the global - * state (including arranging for these functions to return different - * values). - * - * Its only interaction back to the UI is to arrange for - * notify_list_loaded on the UI companion. - */ - -void menu_entry_init(menu_entry_t *entry) -{ - entry->path[0] = '\0'; - entry->label[0] = '\0'; - entry->sublabel[0] = '\0'; - entry->rich_label[0] = '\0'; - entry->value[0] = '\0'; - entry->password_value[0] = '\0'; - entry->enum_idx = MSG_UNKNOWN; - entry->entry_idx = 0; - entry->idx = 0; - entry->type = 0; - entry->spacing = 0; - entry->path_enabled = true; - entry->label_enabled = true; - entry->rich_label_enabled = true; - entry->value_enabled = true; - entry->sublabel_enabled = true; -} void menu_entry_get(menu_entry_t *entry, size_t stack_idx, size_t i, void *userdata, bool use_representation) @@ -26367,7 +26334,7 @@ static void menu_input_post_iterate( (menu_file_list_cbs_t*)selection_buf->list[selection].actiondata : NULL; - menu_entry_init(&entry); + MENU_ENTRY_INIT(entry); /* Note: If menu_input_pointer_post_iterate() is * modified, will have to verify that these * parameters remain unused... */