Get rid of menu_entries_get_menu_stack_ptr

This commit is contained in:
libretroadmin 2023-05-10 04:48:27 +02:00
parent a1e4918288
commit 9861073363
7 changed files with 43 additions and 33 deletions

View File

@ -34,7 +34,8 @@ static int action_info_default(unsigned type, const char *label)
{
menu_displaylist_info_t info;
struct menu_state *menu_st = menu_state_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
size_t selection = menu_st->selection_ptr;
settings_t *settings = config_get_ptr();
#ifdef HAVE_AUDIOMIXER

View File

@ -8864,9 +8864,11 @@ static int materialui_environ(enum menu_environ_cb type,
static bool materialui_preswitch_tabs(
materialui_handle_t *mui, materialui_nav_bar_menu_tab_t *target_tab)
{
size_t stack_size = 0;
file_list_t *menu_stack = NULL;
bool stack_flushed = false;
size_t stack_size = 0;
file_list_t *menu_stack = NULL;
bool stack_flushed = false;
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
/* Pressing a navigation menu tab always returns us to
* one of the top level menus. There are two ways to
@ -8897,7 +8899,7 @@ static bool materialui_preswitch_tabs(
/* Get current stack
* (stack size should be zero here, but account
* for unknown errors) */
menu_stack = menu_entries_get_menu_stack_ptr(0);
menu_stack = MENU_LIST_GET(menu_list, 0);
stack_size = menu_stack->size;
/* Sanity check

View File

@ -9401,23 +9401,26 @@ static void ozone_context_destroy(void *data)
static void *ozone_list_get_entry(void *data,
enum menu_list_type type, unsigned i)
{
size_t list_size = 0;
ozone_handle_t* ozone = (ozone_handle_t*) data;
switch (type)
{
case MENU_LIST_PLAIN:
{
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
list_size = menu_entries_get_stack_size(0);
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
size_t list_size = MENU_LIST_GET_STACK_SIZE(menu_list, 0);
if (i < list_size)
return (void*)&menu_stack->list[i];
}
break;
case MENU_LIST_HORIZONTAL:
list_size = ozone->horizontal_list.size;
if (i < list_size)
return (void*)&ozone->horizontal_list.list[i];
{
size_t list_size = ozone->horizontal_list.size;
if (i < list_size)
return (void*)&ozone->horizontal_list.list[i];
}
break;
default:
break;

View File

@ -503,15 +503,6 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
}
}
file_list_t *menu_entries_get_menu_stack_ptr(size_t idx)
{
struct menu_state *menu_st = &menu_driver_state;
menu_list_t *menu_list = menu_st->entries.list;
if (!menu_list)
return NULL;
return MENU_LIST_GET(menu_list, (unsigned)idx);
}
file_list_t *menu_entries_get_selection_buf_ptr(size_t idx)
{
struct menu_state *menu_st = &menu_driver_state;

View File

@ -170,8 +170,6 @@ void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
file_list_t *menu_entries_get_selection_buf_ptr(size_t idx);
file_list_t *menu_entries_get_menu_stack_ptr(size_t idx);
void menu_entries_get_last_stack(const char **path, const char **label,
unsigned *file_type, enum msg_hash_enums *enum_idx, size_t *entry_idx);

View File

@ -875,9 +875,11 @@ static int explore_action_ok(const char *path, const char *label,
const char* explore_tab = msg_hash_to_str(MENU_ENUM_LABEL_EXPLORE_TAB);
if (type >= EXPLORE_TYPE_FIRSTITEM || type == EXPLORE_TYPE_FILTERNULL)
{
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
unsigned prev_type = menu_stack->list[menu_stack->size - 1].type;
unsigned cat = (prev_type - EXPLORE_TYPE_FIRSTCATEGORY);
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
unsigned prev_type = menu_stack->list[menu_stack->size - 1].type;
unsigned cat = (prev_type - EXPLORE_TYPE_FIRSTCATEGORY);
if (cat < EXPLORE_CAT_COUNT)
{
explore_state_t *state = explore_state;
@ -914,8 +916,10 @@ static int explore_action_ok(const char *path, const char *label,
static int explore_cancel(const char *path,
const char *label, unsigned type, size_t idx)
{
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
unsigned closed_type = menu_stack->list[menu_stack->size - 1].type;
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
unsigned closed_type = menu_stack->list[menu_stack->size - 1].type;
if (closed_type >= EXPLORE_TYPE_FIRSTITEM ||
closed_type == EXPLORE_TYPE_FILTERNULL)
{
@ -989,8 +993,10 @@ static int explore_action_ok_find(const char *path, const char *label, unsigned
static const char* explore_get_view_path(void)
{
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
struct item_file *cur = (struct item_file *)&menu_stack->list[menu_stack->size - 1];
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
struct item_file *cur = (struct item_file *)&menu_stack->list[menu_stack->size - 1];
/* check if we are opening a saved view from the horizontal/tabs menu */
if (cur->type == MENU_SETTING_HORIZONTAL_MENU)
@ -1033,10 +1039,14 @@ static void explore_on_edit_views(enum msg_hash_enums msg)
static int explore_action_ok_deleteview(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx)
{
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
filestream_delete(explore_get_view_path());
explore_on_edit_views(MENU_ENUM_LABEL_EXPLORE_VIEW_DELETED);
if (menu_entries_get_menu_stack_ptr(0)->size == 1)
if (menu_stack->size == 1)
{
/* if we're at the top of the menu we can't cancel so just refresh
what becomes selected after MENU_ENVIRON_RESET_HORIZONTAL_LIST. */
@ -1295,7 +1305,9 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
unsigned i;
char tmp[512];
struct explore_state *state = explore_state;
struct file_list *menu_stack = menu_entries_get_menu_stack_ptr(0);
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
struct item_file *stack_top = menu_stack->list;
size_t depth = menu_stack->size;
unsigned current_type = (depth > 0 ? stack_top[depth - 1].type : 0);

View File

@ -6980,7 +6980,8 @@ int menu_action_handle_setting(rarch_setting_t *setting,
menu_displaylist_info_t info;
settings_t *settings = config_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
const char *name = setting->name;
size_t selection = menu_st->selection_ptr;
@ -7825,7 +7826,9 @@ static void general_write_handler(rarch_setting_t *setting)
{
menu_displaylist_info_t info;
settings_t *settings = config_get_ptr();
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
menu_displaylist_info_init(&info);