Change return types of menu_driver_list_get_selection/get_size

and simplify struct
This commit is contained in:
libretroadmin 2023-05-10 08:36:44 +02:00
parent 5de30567a1
commit 0674613d28
8 changed files with 51 additions and 82 deletions

View File

@ -270,26 +270,23 @@ static int action_left_goto_tab(void)
static int action_left_mainmenu(unsigned type, const char *label,
bool wraparound)
{
menu_ctx_list_t list_info;
settings_t *settings = config_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable;
const char *menu_ident = menu_driver_ident();
size_t selection = menu_driver_list_get_selection();
size_t size = menu_driver_list_get_size(MENU_LIST_PLAIN);
menu_driver_list_get_selection(&list_info);
list_info.type = MENU_LIST_PLAIN;
menu_driver_list_get_size(&list_info);
#ifdef HAVE_XMB
/* Tab switching functionality only applies
* to XMB */
if ( (list_info.size == 1)
if ( (size == 1)
&& string_is_equal(menu_ident, "xmb"))
{
if ((list_info.selection != 0) || menu_nav_wraparound_enable)
if ((selection != 0) || menu_nav_wraparound_enable)
return action_left_goto_tab();
}
else
#endif
action_left_scroll(0, "", false);
return 0;
@ -358,11 +355,12 @@ static int action_left_shader_filter_default(unsigned type, const char *label,
static int action_left_cheat_num_passes(unsigned type, const char *label,
bool wraparound)
{
bool refresh = false;
unsigned new_size = 0;
bool refresh = false;
unsigned new_size = 0;
unsigned cheat_size = cheat_manager_get_size();
if (cheat_manager_get_size())
new_size = cheat_manager_get_size() - 1;
if (cheat_size)
new_size = cheat_size - 1;
menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);
menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL);
cheat_manager_realloc(new_size, CHEAT_HANDLER_TYPE_EMU);

View File

@ -303,36 +303,27 @@ static int action_right_goto_tab(void)
static int action_right_mainmenu(unsigned type, const char *label,
bool wraparound)
{
menu_ctx_list_t list_info;
settings_t *settings = config_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable;
const char *menu_ident = menu_driver_ident();
size_t selection = menu_driver_list_get_selection();
size_t size = menu_driver_list_get_size(MENU_LIST_PLAIN);
menu_driver_list_get_selection(&list_info);
list_info.type = MENU_LIST_PLAIN;
menu_driver_list_get_size(&list_info);
#ifdef HAVE_XMB
/* Tab switching functionality only applies
* to XMB */
if ((list_info.size == 1) &&
string_is_equal(menu_ident, "xmb"))
if ( (size == 1)
&& string_is_equal(menu_ident, "xmb"))
{
menu_ctx_list_t list_horiz_info;
menu_ctx_list_t list_tabs_info;
size_t horiz_size = menu_driver_list_get_size(MENU_LIST_HORIZONTAL);
size_t tabs_size = menu_driver_list_get_size(MENU_LIST_TABS);
list_horiz_info.type = MENU_LIST_HORIZONTAL;
list_tabs_info.type = MENU_LIST_TABS;
menu_driver_list_get_size(&list_horiz_info);
menu_driver_list_get_size(&list_tabs_info);
if ((list_info.selection != (list_horiz_info.size + list_tabs_info.size))
if ( (selection != (horiz_size + tabs_size))
|| menu_nav_wraparound_enable)
return action_right_goto_tab();
}
else
#endif
action_right_scroll(0, "", false);
return 0;

View File

@ -3331,22 +3331,16 @@ static void menu_displaylist_set_new_playlist(
}
static int menu_displaylist_parse_horizontal_list(
menu_handle_t *menu,
settings_t *settings,
menu_handle_t *menu, settings_t *settings,
menu_displaylist_info_t *info)
{
menu_ctx_list_t list_info;
menu_ctx_list_t list_horiz_info;
struct item_file *item = NULL;
struct item_file *item = NULL;
size_t selection = menu_driver_list_get_selection();
size_t size = menu_driver_list_get_size(MENU_LIST_TABS);
menu_driver_list_get_selection(&list_info);
list_info.type = MENU_LIST_TABS;
menu_driver_list_get_size(&list_info);
list_horiz_info.type = MENU_LIST_HORIZONTAL;
list_horiz_info.idx = list_info.selection - (list_info.size +1);
list_horiz_info.type = MENU_LIST_HORIZONTAL;
list_horiz_info.idx = selection - (size +1);
menu_driver_list_get_entry(&list_horiz_info);

View File

@ -4561,33 +4561,22 @@ bool menu_driver_list_get_entry(menu_ctx_list_t *list)
return true;
}
bool menu_driver_list_get_selection(menu_ctx_list_t *list)
size_t menu_driver_list_get_selection(void)
{
struct menu_state *menu_st = &menu_driver_state;
struct menu_state *menu_st = &menu_driver_state;
if ( !menu_st->driver_ctx ||
!menu_st->driver_ctx->list_get_selection)
{
list->selection = 0;
return false;
}
list->selection = menu_st->driver_ctx->list_get_selection(
menu_st->userdata);
return true;
return 0;
return menu_st->driver_ctx->list_get_selection(menu_st->userdata);
}
bool menu_driver_list_get_size(menu_ctx_list_t *list)
size_t menu_driver_list_get_size(enum menu_list_type type)
{
struct menu_state *menu_st = &menu_driver_state;
if ( !menu_st->driver_ctx ||
!menu_st->driver_ctx->list_get_size)
{
list->size = 0;
return false;
}
list->size = menu_st->driver_ctx->list_get_size(
menu_st->userdata, list->type);
return true;
struct menu_state *menu_st = &menu_driver_state;
if ( !menu_st->driver_ctx
|| !menu_st->driver_ctx->list_get_size)
return 0;
return menu_st->driver_ctx->list_get_size(menu_st->userdata, type);
}
void menu_input_get_pointer_state(menu_input_pointer_t *copy_target)

View File

@ -622,12 +622,12 @@ bool menu_driver_list_cache(menu_ctx_list_t *list);
bool menu_driver_init(bool video_is_threaded);
bool menu_driver_list_get_selection(menu_ctx_list_t *list);
size_t menu_driver_list_get_selection(void);
size_t menu_driver_list_get_size(enum menu_list_type type);
bool menu_driver_list_get_entry(menu_ctx_list_t *list);
bool menu_driver_list_get_size(menu_ctx_list_t *list);
retro_time_t menu_driver_get_current_time(void);
void menu_display_timedate(gfx_display_ctx_datetime_t *datetime);

View File

@ -82,8 +82,6 @@ typedef struct menu_ctx_list
file_list_t *list;
void *entry;
size_t idx;
size_t selection;
size_t size;
size_t list_size;
unsigned entry_type;
unsigned action;

View File

@ -1001,26 +1001,24 @@ static const char* explore_get_view_path(void)
/* check if we are opening a saved view from the horizontal/tabs menu */
if (cur->type == MENU_SETTING_HORIZONTAL_MENU)
{
menu_ctx_list_t tabs, horizontal;
tabs.type = MENU_LIST_TABS;
if (menu_driver_list_get_selection(&tabs) && menu_driver_list_get_size(&tabs))
size_t selection, size;
selection = menu_driver_list_get_selection();
size = menu_driver_list_get_size(MENU_LIST_TABS);
if (selection > 0 && size > 0)
{
menu_ctx_list_t horizontal;
horizontal.type = MENU_LIST_HORIZONTAL;
horizontal.idx = tabs.selection - (tabs.size + 1);
horizontal.idx = selection - (size + 1);
/* Label contains the path and path contains the label */
if (menu_driver_list_get_entry(&horizontal))
{
/* label contains the path and path contains the label */
return ((struct item_file*)horizontal.entry)->label;
}
}
}
/* check if we are opening a saved view via Content > Playlists */
if (cur->type == MENU_EXPLORE_TAB && cur->path && !string_is_equal(cur->path,
msg_hash_to_str(MENU_ENUM_LABEL_GOTO_EXPLORE)))
{
return cur->path;
}
return NULL;
}

View File

@ -93,12 +93,13 @@ static void cb_task_menu_explore_init(
/* check if we are opening a saved view from the horizontal/tabs menu */
if (menu_type == MENU_SETTING_HORIZONTAL_MENU)
{
menu_ctx_list_t tabs, horizontal;
tabs.type = MENU_LIST_TABS;
if (menu_driver_list_get_selection(&tabs) && menu_driver_list_get_size(&tabs))
size_t selection = menu_driver_list_get_selection();
size_t size = menu_driver_list_get_size(MENU_LIST_TABS);
if (selection > 0 && size > 0)
{
menu_ctx_list_t horizontal;
horizontal.type = MENU_LIST_HORIZONTAL;
horizontal.idx = tabs.selection - (tabs.size + 1);
horizontal.idx = selection - (size + 1);
if (menu_driver_list_get_entry(&horizontal))
menu_type = ((struct item_file*)horizontal.entry)->type;
}