(file_list) Start adding entry_idx to file_list_* functions

This commit is contained in:
twinaphex 2015-06-10 22:43:06 +02:00
parent ff2d8478be
commit 5bd138b6ac
11 changed files with 276 additions and 246 deletions

View File

@ -28,7 +28,8 @@
void file_list_push(file_list_t *list,
const char *path, const char *label,
unsigned type, size_t directory_ptr)
unsigned type, size_t directory_ptr,
size_t entry_idx)
{
if (list->size >= list->capacity)
{
@ -47,6 +48,7 @@ void file_list_push(file_list_t *list,
list->list[list->size].alt = NULL;
list->list[list->size].type = type;
list->list[list->size].directory_ptr = directory_ptr;
list->list[list->size].entry_idx = entry_idx;
if (label)
list->list[list->size].label = strdup(label);
@ -63,6 +65,15 @@ size_t file_list_get_size(const file_list_t *list)
return list->size;
}
size_t file_list_get_entry_index(const file_list_t *list)
{
size_t size = 0;
if (!list)
return 0;
size = file_list_get_size(list);
return list->list[size].entry_idx;
}
size_t file_list_get_directory_ptr(const file_list_t *list)
{
size_t size = file_list_get_size(list);
@ -167,6 +178,7 @@ void file_list_copy(file_list_t *list, file_list_t *list_old)
list_old->list[i].alt = NULL;
list_old->list[i].type = list->list[i].type;
list_old->list[i].directory_ptr = list->list[i].directory_ptr;
list_old->list[i].entry_idx = list->list[i].entry_idx;
list_old->list[i].userdata = list->list[i].userdata;
list_old->list[i].actiondata = list->list[i].actiondata;
@ -282,7 +294,8 @@ void *file_list_get_last_actiondata(const file_list_t *list)
}
void file_list_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type)
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx)
{
if (!list)
return;
@ -293,17 +306,19 @@ void file_list_get_at_offset(const file_list_t *list, size_t idx,
*label = list->list[idx].label;
if (file_type)
*file_type = list->list[idx].type;
if (entry_idx)
*entry_idx = list->list[idx].entry_idx;
}
void file_list_get_last(const file_list_t *list,
const char **path, const char **label,
unsigned *file_type)
unsigned *file_type, size_t *entry_idx)
{
if (!list)
return;
if (list->size)
file_list_get_at_offset(list, list->size - 1, path, label, file_type);
file_list_get_at_offset(list, list->size - 1, path, label, file_type, entry_idx);
}
bool file_list_search(const file_list_t *list, const char *needle, size_t *idx)

View File

@ -36,6 +36,7 @@ struct item_file
char *alt;
unsigned type;
size_t directory_ptr;
size_t entry_idx;
void *userdata;
void *actiondata;
};
@ -58,7 +59,8 @@ void *file_list_get_actiondata_at_offset(const file_list_t *list,
void file_list_free(file_list_t *list);
void file_list_push(file_list_t *userdata, const char *path,
const char *label, unsigned type, size_t current_directory_ptr);
const char *label, unsigned type, size_t current_directory_ptr,
size_t entry_index);
void file_list_pop(file_list_t *list, size_t *directory_ptr);
@ -68,17 +70,19 @@ void file_list_copy(file_list_t *list, file_list_t *list_old);
void file_list_get_last(const file_list_t *list,
const char **path, const char **label,
unsigned *type);
unsigned *type, size_t *entry_idx);
void *file_list_get_last_actiondata(const file_list_t *list);
size_t file_list_get_size(const file_list_t *list);
size_t file_list_get_entry_index(const file_list_t *list);
size_t file_list_get_directory_ptr(const file_list_t *list);
void file_list_get_at_offset(const file_list_t *list, size_t index,
const char **path, const char **label,
unsigned *type);
unsigned *type, size_t *entry_idx);
void file_list_set_label_at_offset(file_list_t *list, size_t index,
const char *label);

View File

@ -38,6 +38,7 @@ static int archive_open(void)
const char *menu_label = NULL;
const char* path = NULL;
unsigned int type = 0;
size_t entry_idx = 0;
menu_navigation_t *nav = menu_navigation_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
@ -47,13 +48,13 @@ static int archive_open(void)
menu_list_pop_stack(menu_list);
menu_list_get_last_stack(menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
if (menu_list_get_size(menu_list) == 0)
return 0;
menu_list_get_at_offset(menu_list->selection_buf,
nav->selection_ptr, &path, NULL, &type);
nav->selection_ptr, &path, NULL, &type, &entry_idx);
fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path));
@ -76,6 +77,7 @@ static int archive_load(void)
const char *menu_path = NULL;
const char *menu_label = NULL;
const char* path = NULL;
size_t entry_idx = 0;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
@ -87,13 +89,13 @@ static int archive_load(void)
menu_list_pop_stack(menu->menu_list);
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
if (menu_list_get_size(menu->menu_list) == 0)
return 0;
menu_list_get_at_offset(menu->menu_list->selection_buf,
selected, &path, NULL, NULL);
selected, &path, NULL, NULL, &entry_idx);
ret = rarch_defer_core(global->core_info, menu_path, path, menu_label,
menu->deferred_path, sizeof(menu->deferred_path));
@ -240,7 +242,7 @@ static int action_iterate_info(char *s, size_t len, const char *label)
else
{
const char *lbl = NULL;
menu_list_get_at_offset(list, selection, NULL, &lbl, &info_type);
menu_list_get_at_offset(list, selection, NULL, &lbl, &info_type, NULL);
if (lbl)
strlcpy(needle, lbl, sizeof(needle));
@ -286,7 +288,7 @@ static int action_iterate_menu_viewport(char *s, size_t len, const char *label,
if (!menu)
return -1;
menu_list_get_last_stack(menu_list, NULL, NULL, &type);
menu_list_get_last_stack(menu_list, NULL, NULL, &type, NULL);
geom = (struct retro_game_geometry*)&av_info->geometry;
@ -407,7 +409,7 @@ static int action_iterate_menu_viewport(char *s, size_t len, const char *label,
break;
}
menu_list_get_last_stack(menu_list, NULL, &label, &type);
menu_list_get_last_stack(menu_list, NULL, &label, &type, NULL);
menu_driver_render();

View File

@ -59,7 +59,7 @@ static int rarch_defer_core_wrapper(menu_displaylist_info_t *info,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
ret = rarch_defer_core(global->core_info,
menu_path, path, menu_label, menu->deferred_path,
@ -240,7 +240,7 @@ static int action_ok_shader_pass_load(const char *path,
#ifdef HAVE_SHADER_MANAGER
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(menu->shader->pass[hack_shader_pass].source.path,
menu_path, path,
@ -604,7 +604,7 @@ static int action_ok_record_configfile_load(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(global->record.config, menu_path, path, sizeof(global->record.config));
@ -625,7 +625,7 @@ static int action_ok_remap_file_load(const char *path,
(void)menu_path;
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(remap_path, menu_path, path, sizeof(remap_path));
input_remapping_load_file(remap_path);
@ -650,7 +650,7 @@ static int action_ok_video_filter_file_load(const char *path,
(void)menu_path;
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(filter_path, menu_path, path, sizeof(filter_path));
@ -677,7 +677,7 @@ static int action_ok_cheat_file_load(const char *path,
(void)cheat_path;
(void)menu_path;
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(cheat_path, menu_path, path, sizeof(cheat_path));
@ -707,7 +707,7 @@ static int action_ok_menu_wallpaper_load(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label,
NULL);
NULL, NULL);
setting = menu_setting_find(menu_label);
@ -742,7 +742,7 @@ static int action_ok_shader_preset_load(const char *path,
(void)menu_path;
#ifdef HAVE_SHADER_MANAGER
menu_list_get_last_stack(menu->menu_list, &menu_path, NULL,
NULL);
NULL, NULL);
fill_pathname_join(shader_path, menu_path, path, sizeof(shader_path));
menu_shader_manager_set_preset(menu->shader,
@ -947,7 +947,7 @@ static int action_ok_core_load(const char *path,
(void)global;
menu_list_get_last_stack(menu->menu_list,
&menu_path, NULL, NULL);
&menu_path, NULL, NULL, NULL);
fill_pathname_join(settings->libretro, menu_path, path,
sizeof(settings->libretro));
@ -1010,7 +1010,7 @@ static int action_ok_directory_push(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path));
@ -1084,7 +1084,7 @@ static int action_ok_config_load(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, NULL, NULL);
&menu_path, NULL, NULL, NULL);
fill_pathname_join(config, menu_path, path, sizeof(config));
menu_list_flush_stack(menu->menu_list, NULL, MENU_SETTINGS);
@ -1109,7 +1109,7 @@ static int action_ok_disk_image_append(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, NULL, NULL);
&menu_path, NULL, NULL, NULL);
fill_pathname_join(image, menu_path, path, sizeof(image));
event_disk_control_append_image(image);
@ -1134,7 +1134,7 @@ static int action_ok_file_load(const char *path,
return -1;
menu_list_get_last(menu->menu_list->menu_stack,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
setting = menu_setting_find(menu_label);
@ -1172,7 +1172,7 @@ static int action_ok_set_path(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
setting = menu_setting_find(menu_label);

View File

@ -31,7 +31,7 @@ static int action_scan_file(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
fill_pathname_join(fullpath, menu_path, path, sizeof(fullpath));
@ -50,7 +50,7 @@ static int action_scan_directory(const char *path,
return -1;
menu_list_get_last_stack(menu->menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
fill_pathname_join(fullpath, menu_path, path, sizeof(fullpath));

View File

@ -1014,7 +1014,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
video_driver_get_size(&width, &height);
file_list_get_last(stack, NULL, &label, NULL);
file_list_get_last(stack, NULL, &label, NULL, NULL);
if (cat_selection_ptr)
core_node = xmb_get_userdata_from_horizontal_list(xmb, cat_selection_ptr - 1);

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ void menu_entries_init(void *data,
return;
menu_list_get_last_stack(menu->menu_list,
NULL, &menu_label, NULL);
NULL, &menu_label, NULL, NULL);
if (label)
str_list = string_split(label, "|");

View File

@ -70,7 +70,7 @@ int menu_entries_get_title(char *s, size_t len)
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
menu_list_get_last_stack(menu_list, &path, &label, &menu_type);
menu_list_get_last_stack(menu_list, &path, &label, &menu_type, NULL);
(void)cbs;
@ -140,10 +140,11 @@ static rarch_setting_t *menu_entry_get_setting(uint32_t i)
menu_list_t *menu_list = menu_list_get_ptr();
unsigned menu_type = 0;
menu_list_get_last_stack(menu_list, &dir, &label, &menu_type);
menu_list_get_last_stack(menu_list, &dir,
&label, &menu_type, NULL);
menu_list_get_at_offset(menu_list->selection_buf, i, &path,
&entry_label, &type);
&entry_label, &type, NULL);
return menu_setting_find(
menu_list->selection_buf->list[i].label);
@ -159,10 +160,11 @@ enum menu_entry_type menu_entry_get_type(uint32_t i)
menu_list_t *menu_list = menu_list_get_ptr();
unsigned menu_type = 0;
menu_list_get_last_stack(menu_list, &dir, &label, &menu_type);
menu_list_get_last_stack(menu_list, &dir,
&label, &menu_type, NULL);
menu_list_get_at_offset(menu_list->selection_buf, i, &path,
&entry_label, &type);
&entry_label, &type, NULL);
setting = menu_entry_get_setting(i);
@ -328,7 +330,7 @@ int menu_entry_pathdir_set_value(uint32_t i, const char *s)
menu_list_t *menu_list = menu_list_get_ptr();
menu_list_get_last_stack(menu_list,
&menu_path, &menu_label, NULL);
&menu_path, &menu_label, NULL, NULL);
setting = menu_setting_find(menu_label);
@ -408,14 +410,15 @@ void menu_entry_get(menu_entry_t *entry, size_t i,
if (!menu_list)
return;
menu_list_get_last_stack(menu_list, NULL, &label, NULL);
menu_list_get_last_stack(menu_list, NULL, &label, NULL, NULL);
list = userdata ? (file_list_t*)userdata : menu_list->selection_buf;
if (!list)
return;
menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type);
menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type,
NULL);
cbs = menu_list_get_actiondata_at_offset(list, i);
@ -492,7 +495,7 @@ int menu_entry_iterate(unsigned action)
cbs = (menu_file_list_cbs_t*)menu_list_get_last_stack_actiondata(menu_list);
menu_list_get_last_stack(menu_list, NULL, &label, NULL);
menu_list_get_last_stack(menu_list, NULL, &label, NULL, NULL);
if (cbs && cbs->action_iterate)
return cbs->action_iterate(label, action);

View File

@ -47,7 +47,7 @@ static INLINE bool menu_list_elem_is_dir(file_list_t *list,
const char *label = NULL;
unsigned type = 0;
menu_list_get_at_offset(list, offset, &path, &label, &type);
menu_list_get_at_offset(list, offset, &path, &label, &type, NULL);
return type != MENU_FILE_PLAIN;
}
@ -206,26 +206,27 @@ size_t menu_list_get_stack_size(menu_list_t *list)
}
void menu_list_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type)
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx)
{
file_list_get_at_offset(list, idx, path, label, file_type);
file_list_get_at_offset(list, idx, path, label, file_type, entry_idx);
}
void menu_list_get_last(const file_list_t *list,
const char **path, const char **label,
unsigned *file_type)
unsigned *file_type, size_t *entry_idx)
{
if (list)
file_list_get_last(list, path, label, file_type);
file_list_get_last(list, path, label, file_type, entry_idx);
}
void menu_list_get_last_stack(const menu_list_t *list,
const char **path, const char **label,
unsigned *file_type)
unsigned *file_type, size_t *entry_idx)
{
if (list)
file_list_get_last(list->menu_stack, path, label, file_type);
file_list_get_last(list->menu_stack, path, label, file_type, entry_idx);
}
menu_file_list_cbs_t *menu_list_get_actiondata_at_offset(const file_list_t *list, size_t idx)
@ -254,20 +255,21 @@ static int menu_list_flush_stack_type(
void menu_list_flush_stack(menu_list_t *list,
const char *needle, unsigned final_type)
{
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
size_t entry_idx = 0;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu || !list)
return;
menu_set_refresh();
file_list_get_last(list->menu_stack, &path, &label, &type);
file_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
while (menu_list_flush_stack_type(needle, label, type, final_type) != 0)
{
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
file_list_get_last(list->menu_stack, &path, &label, &type);
file_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
}
}
@ -289,21 +291,22 @@ void menu_list_pop_stack(menu_list_t *list)
void menu_list_pop_stack_by_needle(menu_list_t *list,
const char *needle)
{
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
const char *path = NULL;
const char *label = NULL;
unsigned type = 0;
size_t entry_idx = 0;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu || !list)
return;
menu_set_refresh();
file_list_get_last(list->menu_stack, &path, &label, &type);
file_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
while (strcmp(needle, label) == 0)
{
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
file_list_get_last(list->menu_stack, &path, &label, &type);
file_list_get_last(list->menu_stack, &path, &label, &type, &entry_idx);
}
}
@ -340,12 +343,13 @@ end:
void menu_list_push(file_list_t *list,
const char *path, const char *label,
unsigned type, size_t directory_ptr)
unsigned type, size_t directory_ptr,
size_t entry_idx)
{
if (!list || !label)
return;
file_list_push(list, path, label, type, directory_ptr);
file_list_push(list, path, label, type, directory_ptr, entry_idx);
menu_driver_list_insert(list, path, label, type, list->size - 1);
}

View File

@ -86,7 +86,8 @@ void menu_list_pop_stack_by_needle(menu_list_t *list,
const char *needle);
void menu_list_get_at_offset(const file_list_t *list, size_t idx,
const char **path, const char **label, unsigned *file_type);
const char **path, const char **label, unsigned *file_type,
size_t *entry_idx);
menu_file_list_cbs_t *menu_list_get_actiondata_at_offset(const file_list_t *list, size_t idx);
@ -98,17 +99,18 @@ void *menu_list_get_last_stack_actiondata(const menu_list_t *list);
void menu_list_get_last(const file_list_t *list,
const char **path, const char **label,
unsigned *file_type);
unsigned *file_type, size_t *entry_idx);
void menu_list_get_last_stack(const menu_list_t *list,
const char **path, const char **label,
unsigned *file_type);
unsigned *file_type, size_t *entry_idx);
void menu_list_clear(file_list_t *list);
void menu_list_push(file_list_t *list,
const char *path, const char *label,
unsigned type, size_t directory_ptr);
unsigned type, size_t directory_ptr,
size_t entry_idx);
void menu_list_get_alt_at_offset(const file_list_t *list, size_t idx,
const char **alt);