Expand menu_entries_get_last_stack so we can grab enum_idx

This commit is contained in:
twinaphex 2016-06-17 16:08:47 +02:00
parent 03b93b224c
commit 3b3e822d78
8 changed files with 64 additions and 47 deletions

View File

@ -125,6 +125,7 @@ int generic_action_ok_displaylist_push(const char *path,
const char *info_label = NULL;
const char *info_path = NULL;
menu_handle_t *menu = NULL;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
@ -133,7 +134,7 @@ int generic_action_ok_displaylist_push(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, NULL);
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
if (path && menu_path)
fill_pathname_join(action_path, menu_path, path, sizeof(action_path));
@ -482,6 +483,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx,
char new_core_path[PATH_MAX_LENGTH] = {0};
char menu_path_new[PATH_MAX_LENGTH] = {0};
int ret = 0;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *menu_path = NULL;
const char *menu_label = NULL;
menu_handle_t *menu = NULL;
@ -490,7 +492,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, NULL);
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
if (!string_is_empty(menu_path))
strlcpy(menu_path_new, menu_path, sizeof(menu_path_new));
@ -848,6 +850,7 @@ static int generic_action_ok(const char *path,
char action_path[PATH_MAX_LENGTH] = {0};
unsigned flush_type = 0;
int ret = 0;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *menu_path = NULL;
const char *menu_label = NULL;
const char *flush_char = NULL;
@ -856,8 +859,7 @@ static int generic_action_ok(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
goto error;
menu_entries_get_last_stack(&menu_path, &menu_label,
NULL, NULL);
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
if (!string_is_empty(path))
fill_pathname_join(action_path, menu_path, path, sizeof(action_path));

View File

@ -44,6 +44,7 @@ int action_scan_file(const char *path,
const char *label, unsigned type, size_t idx)
{
char fullpath[PATH_MAX_LENGTH] = {0};
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = NULL;
@ -51,7 +52,7 @@ int action_scan_file(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, NULL);
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
fill_pathname_join(fullpath, menu_path, path, sizeof(fullpath));
@ -64,6 +65,7 @@ int action_scan_directory(const char *path,
const char *label, unsigned type, size_t idx)
{
char fullpath[PATH_MAX_LENGTH] = {0};
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *menu_label = NULL;
const char *menu_path = NULL;
menu_handle_t *menu = NULL;
@ -71,7 +73,7 @@ int action_scan_directory(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit();
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, NULL);
menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL);
strlcpy(fullpath, menu_path, sizeof(fullpath));

View File

@ -273,11 +273,12 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
int ret = 0;
uint32_t label_hash = 0;
uint32_t hash = 0;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
menu_handle_t *menu = (menu_handle_t*)data;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
menu_entries_get_last_stack(NULL, &label, NULL, NULL);
menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL);
if (!menu)
return 0;

View File

@ -47,6 +47,7 @@ void menu_cbs_init(void *data,
const char *menu_label = NULL;
uint32_t label_hash = 0;
uint32_t menu_label_hash = 0;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
file_list_t *list = (file_list_t*)data;
if (!list)
return;
@ -54,7 +55,7 @@ void menu_cbs_init(void *data,
elem0[0] = '\0';
elem1[0] = '\0';
menu_entries_get_last_stack(NULL, &menu_label, NULL, NULL);
menu_entries_get_last_stack(NULL, &menu_label, NULL, &enum_idx, NULL);
if (label)
str_list = string_split(label, "|");

View File

@ -3324,9 +3324,10 @@ static int menu_displaylist_parse_generic(
{
case MENU_LABEL_CORE_LIST:
{
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *dir = NULL;
menu_entries_get_last_stack(&dir, NULL, NULL, NULL);
menu_entries_get_last_stack(&dir, NULL, NULL, &enum_idx, NULL);
list_size = file_list_get_size(info->list);
@ -3567,12 +3568,13 @@ static bool menu_displaylist_push(menu_displaylist_ctx_entry_t *entry)
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
menu_displaylist_info_t info = {0};
if (!entry)
return false;
menu_entries_get_last_stack(&path, &label, &type, NULL);
menu_entries_get_last_stack(&path, &label, &type, &enum_idx, NULL);
info.list = entry->list;
info.menu_list = entry->stack;

View File

@ -389,9 +389,10 @@ void menu_entries_get(size_t i, menu_entry_t *entry)
const char *path = NULL;
const char *entry_label = NULL;
menu_file_list_cbs_t *cbs = NULL;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
menu_entries_get_last_stack(NULL, &label, NULL, NULL);
menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL);
entry->path[0] = entry->value[0] = string_is_empty(entry->label);
@ -419,12 +420,13 @@ int menu_entries_get_title(char *s, size_t len)
unsigned menu_type = 0;
const char *path = NULL;
const char *label = NULL;
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
menu_file_list_cbs_t *cbs = menu_entries_get_last_stack_actiondata();
if (!cbs)
return -1;
menu_entries_get_last_stack(&path, &label, &menu_type, NULL);
menu_entries_get_last_stack(&path, &label, &menu_type, &enum_idx, NULL);
if (cbs && cbs->action_get_title)
return cbs->action_get_title(path, label, menu_type, s, len);
@ -622,13 +624,19 @@ menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void)
}
void menu_entries_get_last_stack(const char **path, const char **label,
unsigned *file_type, size_t *entry_idx)
unsigned *file_type, enum menu_hash_enums *enum_idx, size_t *entry_idx)
{
menu_file_list_cbs_t *cbs = NULL;
menu_list_t *menu_list = NULL;
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
if (menu_list)
if (!menu_list)
return;
menu_entries_get_last(menu_list->menu_stack[0],
path, label, file_type, entry_idx);
cbs = menu_entries_get_last_stack_actiondata();
if (cbs)
*enum_idx = cbs->enum_idx;
}
void menu_entries_flush_stack(const char *needle, unsigned final_type)

View File

@ -143,7 +143,7 @@ void menu_entries_add(file_list_t *list, const char *path, const char *label,
unsigned type, size_t directory_ptr, size_t entry_idx);
void menu_entries_get_last_stack(const char **path, const char **label,
unsigned *file_type, size_t *entry_idx);
unsigned *file_type, enum menu_hash_enums *enum_idx, size_t *entry_idx);
menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void);

View File

@ -290,8 +290,9 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
if (cbs && cbs->action_get_value && use_representation)
{
enum menu_hash_enums enum_idx = MENU_ENUM_LABEL_UNKNOWN;
const char *label = NULL;
menu_entries_get_last_stack(NULL, &label, NULL, NULL);
menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL);
cbs->action_get_value(list,
&entry->spacing, entry->type, i, label,