Get rid of some useless wrapper functions

This commit is contained in:
libretroadmin 2023-05-28 17:56:28 +02:00
parent 8844c991e1
commit 976d7b8067
7 changed files with 86 additions and 122 deletions

View File

@ -267,11 +267,10 @@ static int action_left_goto_tab(void)
static int action_left_mainmenu(unsigned type, const char *label, static int action_left_mainmenu(unsigned type, const char *label,
bool wraparound) bool wraparound)
{ {
settings_t *settings = config_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable; const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx;
const char *menu_ident = menu_driver_ident(); const char *menu_ident = (driver_ctx && driver_ctx->ident) ? driver_ctx->ident : NULL;
size_t selection = menu_driver_list_get_selection(); size_t size = (driver_ctx && driver_ctx->list_get_size) ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_PLAIN) : 0;
size_t size = menu_driver_list_get_size(MENU_LIST_PLAIN);
#ifdef HAVE_XMB #ifdef HAVE_XMB
/* Tab switching functionality only applies /* Tab switching functionality only applies
@ -279,6 +278,9 @@ static int action_left_mainmenu(unsigned type, const char *label,
if ( (size == 1) if ( (size == 1)
&& string_is_equal(menu_ident, "xmb")) && string_is_equal(menu_ident, "xmb"))
{ {
settings_t *settings = config_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable;
size_t selection = (driver_ctx && driver_ctx->list_get_selection) ? driver_ctx->list_get_selection(menu_st->userdata) : 0;
if ((selection != 0) || menu_nav_wraparound_enable) if ((selection != 0) || menu_nav_wraparound_enable)
return action_left_goto_tab(); return action_left_goto_tab();
} }

View File

@ -295,11 +295,10 @@ static int action_right_goto_tab(void)
static int action_right_mainmenu(unsigned type, const char *label, static int action_right_mainmenu(unsigned type, const char *label,
bool wraparound) bool wraparound)
{ {
settings_t *settings = config_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable; const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx;
const char *menu_ident = menu_driver_ident(); const char *menu_ident = (driver_ctx && driver_ctx->ident) ? driver_ctx->ident : NULL;
size_t selection = menu_driver_list_get_selection(); size_t size = (driver_ctx && driver_ctx->list_get_size) ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_PLAIN) : 0;
size_t size = menu_driver_list_get_size(MENU_LIST_PLAIN);
#ifdef HAVE_XMB #ifdef HAVE_XMB
/* Tab switching functionality only applies /* Tab switching functionality only applies
@ -307,8 +306,18 @@ static int action_right_mainmenu(unsigned type, const char *label,
if ( (size == 1) if ( (size == 1)
&& string_is_equal(menu_ident, "xmb")) && string_is_equal(menu_ident, "xmb"))
{ {
size_t horiz_size = menu_driver_list_get_size(MENU_LIST_HORIZONTAL); size_t horiz_size = 0, tabs_size = 0, selection = 0;
size_t tabs_size = menu_driver_list_get_size(MENU_LIST_TABS); settings_t *settings = config_get_ptr();
bool menu_nav_wraparound_enable = settings->bools.menu_navigation_wraparound_enable;
if (driver_ctx)
{
selection = (driver_ctx->list_get_selection) ? driver_ctx->list_get_selection(menu_st->userdata) : 0;
if (driver_ctx->list_get_size)
{
horiz_size = driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_HORIZONTAL);
tabs_size = driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS);
}
}
if ( (selection != (horiz_size + tabs_size)) if ( (selection != (horiz_size + tabs_size))
|| menu_nav_wraparound_enable) || menu_nav_wraparound_enable)

View File

@ -3330,20 +3330,20 @@ static void menu_displaylist_set_new_playlist(
} }
static int menu_displaylist_parse_horizontal_list( static int menu_displaylist_parse_horizontal_list(
menu_handle_t *menu, settings_t *settings, menu_handle_t *menu, struct menu_state *menu_st,
settings_t *settings,
menu_displaylist_info_t *info) menu_displaylist_info_t *info)
{ {
menu_ctx_list_t list_horiz_info; struct item_file *item = NULL;
struct item_file *item = NULL; const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx;
size_t selection = menu_driver_list_get_selection(); size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0;
size_t size = menu_driver_list_get_size(MENU_LIST_TABS); size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0;
list_horiz_info.type = MENU_LIST_HORIZONTAL; if (!driver_ctx->list_get_entry)
list_horiz_info.idx = selection - (size +1); return -1;
menu_driver_list_get_entry(&list_horiz_info); if (!(item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL,
(unsigned)(selection - (size +1)))))
if (!(item = (struct item_file*)list_horiz_info.entry))
return -1; return -1;
/* When opening a saved view the explore menu will handle the list */ /* When opening a saved view the explore menu will handle the list */
@ -5617,7 +5617,7 @@ static int menu_displaylist_parse_playlist_generic(
bool sort_enabled, bool sort_enabled,
int *ret) int *ret)
{ {
unsigned count = 0; unsigned count = 0;
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
menu_displaylist_set_new_playlist(menu, settings, menu_displaylist_set_new_playlist(menu, settings,
@ -13608,7 +13608,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
break; break;
case DISPLAYLIST_HORIZONTAL: case DISPLAYLIST_HORIZONTAL:
menu_entries_clear(info->list); menu_entries_clear(info->list);
ret = menu_displaylist_parse_horizontal_list(menu, settings, info); ret = menu_displaylist_parse_horizontal_list(menu, menu_st, settings, info);
/* Playlists themselves are sorted /* Playlists themselves are sorted
* > Display lists generated from playlists * > Display lists generated from playlists

View File

@ -4422,39 +4422,6 @@ void menu_driver_destroy(
menu_st->input_driver_flushing_input = 0; menu_st->input_driver_flushing_input = 0;
} }
bool menu_driver_list_get_entry(menu_ctx_list_t *list)
{
struct menu_state *menu_st = &menu_driver_state;
if ( !menu_st->driver_ctx ||
!menu_st->driver_ctx->list_get_entry)
{
list->entry = NULL;
return false;
}
list->entry = menu_st->driver_ctx->list_get_entry(
menu_st->userdata,
list->type, (unsigned int)list->idx);
return true;
}
size_t menu_driver_list_get_selection(void)
{
struct menu_state *menu_st = &menu_driver_state;
if ( !menu_st->driver_ctx ||
!menu_st->driver_ctx->list_get_selection)
return 0;
return menu_st->driver_ctx->list_get_selection(menu_st->userdata);
}
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)
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) void menu_input_get_pointer_state(menu_input_pointer_t *copy_target)
{ {
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;

View File

@ -619,12 +619,6 @@ int menu_driver_deferred_push_content_list(file_list_t *list);
bool menu_driver_init(bool video_is_threaded); bool menu_driver_init(bool video_is_threaded);
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);
retro_time_t menu_driver_get_current_time(void); retro_time_t menu_driver_get_current_time(void);
void menu_display_timedate(gfx_display_ctx_datetime_t *datetime); void menu_display_timedate(gfx_display_ctx_datetime_t *datetime);

View File

@ -993,16 +993,19 @@ static const char* explore_get_view_path(struct menu_state *menu_st, menu_list_t
/* check if we are opening a saved view from the horizontal/tabs menu */ /* check if we are opening a saved view from the horizontal/tabs menu */
if (cur->type == MENU_SETTING_HORIZONTAL_MENU) if (cur->type == MENU_SETTING_HORIZONTAL_MENU)
{ {
size_t selection = menu_driver_list_get_selection(); const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx;
size_t size = menu_driver_list_get_size(MENU_LIST_TABS); if (driver_ctx->list_get_entry)
if (selection > 0 && size > 0)
{ {
menu_ctx_list_t horizontal; size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0;
horizontal.type = MENU_LIST_HORIZONTAL; size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0;
horizontal.idx = selection - (size + 1); if (selection > 0 && size > 0)
/* Label contains the path and path contains the label */ {
if (menu_driver_list_get_entry(&horizontal)) struct item_file *item = NULL;
return ((struct item_file*)horizontal.entry)->label; /* Label contains the path and path contains the label */
if ((item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL,
(unsigned)(selection - (size +1)))))
return item->label;
}
} }
} }

View File

@ -24,7 +24,6 @@
#include "tasks_internal.h" #include "tasks_internal.h"
#include "../menu/menu_entries.h"
#include "../menu/menu_driver.h" #include "../menu/menu_driver.h"
typedef struct menu_explore_init_handle typedef struct menu_explore_init_handle
@ -73,13 +72,12 @@ static void cb_task_menu_explore_init(
{ {
menu_explore_init_handle_t *menu_explore = NULL; menu_explore_init_handle_t *menu_explore = NULL;
unsigned menu_type = 0; unsigned menu_type = 0;
struct menu_state *menu_st = menu_state_get_ptr();
if (!task) if (!task)
return; return;
menu_explore = (menu_explore_init_handle_t*)task->state; if (!(menu_explore = (menu_explore_init_handle_t*)task->state))
if (!menu_explore)
return; return;
/* Assign global menu explore state object */ /* Assign global menu explore state object */
@ -93,24 +91,25 @@ static void cb_task_menu_explore_init(
/* check if we are opening a saved view from the horizontal/tabs menu */ /* check if we are opening a saved view from the horizontal/tabs menu */
if (menu_type == MENU_SETTING_HORIZONTAL_MENU) if (menu_type == MENU_SETTING_HORIZONTAL_MENU)
{ {
size_t selection = menu_driver_list_get_selection(); const menu_ctx_driver_t *driver_ctx = menu_st->driver_ctx;
size_t size = menu_driver_list_get_size(MENU_LIST_TABS); if (driver_ctx->list_get_entry)
if (selection > 0 && size > 0)
{ {
menu_ctx_list_t horizontal; size_t selection = driver_ctx->list_get_selection ? driver_ctx->list_get_selection(menu_st->userdata) : 0;
horizontal.type = MENU_LIST_HORIZONTAL; size_t size = driver_ctx->list_get_size ? driver_ctx->list_get_size(menu_st->userdata, MENU_LIST_TABS) : 0;
horizontal.idx = selection - (size + 1); if (selection > 0 && size > 0)
if (menu_driver_list_get_entry(&horizontal)) {
menu_type = ((struct item_file*)horizontal.entry)->type; struct item_file *item = NULL;
/* Label contains the path and path contains the label */
if ((item = (struct item_file*)driver_ctx->list_get_entry(menu_st->userdata, MENU_LIST_HORIZONTAL,
(unsigned)(selection - (size +1)))))
menu_type = item->type;
}
} }
} }
if (menu_type == MENU_EXPLORE_TAB) if (menu_type == MENU_EXPLORE_TAB)
{
struct menu_state *menu_st = menu_state_get_ptr();
menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH
| MENU_ST_FLAG_PREVENT_POPULATE; | MENU_ST_FLAG_PREVENT_POPULATE;
}
} }
static void task_menu_explore_init_free(retro_task_t *task) static void task_menu_explore_init_free(retro_task_t *task)
@ -131,47 +130,37 @@ static void task_menu_explore_init_free(retro_task_t *task)
static void task_menu_explore_init_handler(retro_task_t *task) static void task_menu_explore_init_handler(retro_task_t *task)
{ {
menu_explore_init_handle_t *menu_explore = NULL;
if (!task)
goto task_finished;
menu_explore = (menu_explore_init_handle_t*)task->state;
if (!menu_explore)
goto task_finished;
if (task_get_cancelled(task))
goto task_finished;
/* TODO/FIXME: It could be beneficial to
* initialise the explore menu iteratively,
* but this would require a non-trivial rewrite
* of the menu_explore code. For now, we will
* do it in a single shot (the most important
* consideration here is to place this
* initialisation on a background thread) */
menu_explore->state = menu_explore_build_list(
menu_explore->directory_playlist,
menu_explore->directory_database);
task_set_progress(task, 100);
task_finished:
if (task) if (task)
{
menu_explore_init_handle_t *menu_explore = NULL;
if ((menu_explore = (menu_explore_init_handle_t*)task->state))
{
if (!task_get_cancelled(task))
{
/* TODO/FIXME: It could be beneficial to
* initialise the explore menu iteratively,
* but this would require a non-trivial rewrite
* of the menu_explore code. For now, we will
* do it in a single shot (the most important
* consideration here is to place this
* initialisation on a background thread) */
menu_explore->state = menu_explore_build_list(
menu_explore->directory_playlist,
menu_explore->directory_database);
task_set_progress(task, 100);
}
}
task_set_finished(task, true); task_set_finished(task, true);
}
} }
static bool task_menu_explore_init_finder( static bool task_menu_explore_init_finder(
retro_task_t *task, void *user_data) retro_task_t *task, void *user_data)
{ {
if (!task) if (task && task->handler == task_menu_explore_init_handler)
return false;
if (task->handler == task_menu_explore_init_handler)
return true; return true;
return false; return false;
} }
@ -182,8 +171,8 @@ bool task_push_menu_explore_init(const char *directory_playlist,
retro_task_t *task = NULL; retro_task_t *task = NULL;
menu_explore_init_handle_t *menu_explore = NULL; menu_explore_init_handle_t *menu_explore = NULL;
if (string_is_empty(directory_playlist) || if ( string_is_empty(directory_playlist)
string_is_empty(directory_database)) || string_is_empty(directory_database))
goto error; goto error;
task = task_init(); task = task_init();