(Menu) Refactor file_list_push and associated setting related functionality

This commit is contained in:
twinaphex 2014-08-30 01:56:12 +02:00
parent c1dead999a
commit c6b8732e3a
8 changed files with 304 additions and 488 deletions

View File

@ -138,11 +138,11 @@ typedef struct menu_ctx_driver_backend
void (*shader_manager_set_preset)(struct gfx_shader *, unsigned, const char*);
void (*shader_manager_save_preset)(const char *, bool);
unsigned (*shader_manager_get_type)(const struct gfx_shader *);
int (*shader_manager_setting_toggle)(unsigned, unsigned, rarch_setting_t *);
int (*shader_manager_setting_toggle)(unsigned, unsigned);
unsigned (*type_is)(unsigned);
int (*core_setting_toggle)(unsigned, unsigned);
int (*setting_toggle)(unsigned, unsigned, unsigned, rarch_setting_t*);
int (*setting_set)(unsigned, unsigned, rarch_setting_t *);
int (*setting_toggle)(unsigned, unsigned, unsigned);
int (*setting_set)(unsigned, unsigned);
void (*setting_set_label)(char *, size_t, unsigned *, unsigned,unsigned);
void (*defer_decision_automatic)(void);
void (*defer_decision_manual)(void);

View File

@ -25,8 +25,7 @@
void file_list_push(file_list_t *list,
const char *path, const char *label,
unsigned type, size_t directory_ptr,
void *setting_list)
unsigned type, size_t directory_ptr)
{
if (list->size >= list->capacity)
{
@ -40,20 +39,7 @@ void file_list_push(file_list_t *list,
driver.menu_ctx->list_insert(list, path, label, list->size);
list->list[list->size].label = strdup(label);
list->list[list->size].setting = NULL;
rarch_setting_t *setting_data = (rarch_setting_t *)setting_list;
if (setting_data)
list->list[list->size].setting = (rarch_setting_t*)
setting_data_find_setting(setting_data, label);
if (list->list[list->size].setting)
list->list[list->size].path = strdup(
list->list[list->size].setting->short_description);
else
list->list[list->size].path = strdup(path);
list->list[list->size].path = strdup(path);
list->list[list->size].alt = NULL;
list->list[list->size].type = type;
list->list[list->size].directory_ptr = directory_ptr;
@ -148,24 +134,23 @@ void file_list_sort_on_alt(file_list_t *list)
}
void file_list_get_at_offset(const file_list_t *list, size_t index,
const char **path, unsigned *file_type, rarch_setting_t *setting)
const char **path, unsigned *file_type)
{
if (path)
*path = list->list[index].path;
if (file_type)
*file_type = list->list[index].type;
if (setting)
setting = list->list[index].setting;
}
void file_list_get_last(const file_list_t *list,
const char **path, unsigned *file_type, rarch_setting_t *setting)
const char **path, unsigned *file_type)
{
if (list->size)
file_list_get_at_offset(list, list->size - 1, path, file_type, setting);
file_list_get_at_offset(list, list->size - 1, path, file_type);
}
void *file_list_get_last_setting(const file_list_t *list, int index, void *settings)
void *file_list_get_last_setting(const file_list_t *list, int index,
void *settings)
{
if (settings)
return (rarch_setting_t*)setting_data_find_setting(settings,

View File

@ -31,7 +31,6 @@ struct item_file
char *alt;
unsigned type;
size_t directory_ptr;
struct rarch_setting_t *setting;
};
typedef struct file_list
@ -46,19 +45,18 @@ typedef struct file_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,
void *setting_list);
const char *label, unsigned type, size_t current_directory_ptr);
void file_list_pop(file_list_t *list, size_t *directory_ptr);
void file_list_clear(file_list_t *list);
void file_list_get_last(const file_list_t *list,
const char **path, unsigned *type, rarch_setting_t *setting);
const char **path, unsigned *type);
size_t file_list_get_size(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, unsigned *type, rarch_setting_t *setting);
const char **path, unsigned *type);
void file_list_set_alt_at_offset(file_list_t *list, size_t index,
const char *alt);

File diff suppressed because it is too large Load Diff

View File

@ -263,7 +263,6 @@ static void rgui_render_messagebox(const char *message)
static void rgui_render(void)
{
size_t begin, end;
rarch_setting_t *setting = NULL;
if (driver.menu->need_refresh &&
(g_extern.lifecycle_state & (1ULL << MODE_MENU))
@ -287,7 +286,7 @@ static void rgui_render(void)
const char *dir = NULL;
unsigned menu_type = 0;
unsigned menu_type_is = 0;
file_list_get_last(driver.menu->menu_stack, &dir, &menu_type, setting);
file_list_get_last(driver.menu->menu_stack, &dir, &menu_type);
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type);
@ -447,8 +446,9 @@ static void rgui_render(void)
char message[256], type_str[256];
const char *path = 0;
unsigned type = 0;
rarch_setting_t *setting = NULL;
file_list_get_at_offset(driver.menu->selection_buf, i, &path, &type, setting);
file_list_get_at_offset(driver.menu->selection_buf, i, &path, &type);
rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
setting_data_get_list(), driver.menu->selection_buf->list[i].label);
unsigned w = 19;
if (menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS)

View File

@ -151,8 +151,7 @@ static void rmenu_render(void)
const char *dir = NULL;
unsigned menu_type = 0;
unsigned menu_type_is = 0;
rarch_setting_t *setting = NULL;
file_list_get_last(menu->menu_stack, &dir, &menu_type, setting);
file_list_get_last(menu->menu_stack, &dir, &menu_type);
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type);
@ -322,8 +321,7 @@ static void rmenu_render(void)
{
const char *path = 0;
unsigned type = 0;
rarch_setting_t *setting = NULL;
file_list_get_at_offset(menu->selection_buf, i, &path, &type, setting);
file_list_get_at_offset(menu->selection_buf, i, &path, &type);
char message[256];
char type_str[256];

View File

@ -379,7 +379,6 @@ static void rmenu_xui_render(void)
const char *dir = NULL;
unsigned menu_type = 0;
unsigned menu_type_is = 0;
rarch_setting_t *setting = NULL;
if (!driver.menu || driver.menu->need_refresh &&
(g_extern.lifecycle_state & (1ULL << MODE_MENU))
@ -391,7 +390,7 @@ static void rmenu_xui_render(void)
rmenu_xui_render_background();
file_list_get_last(driver.menu->menu_stack, &dir, &menu_type, setting);
file_list_get_last(driver.menu->menu_stack, &dir, &menu_type);
if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->type_is)
menu_type_is = driver.menu_ctx->backend->type_is(menu_type);
@ -548,7 +547,7 @@ static void rmenu_xui_render(void)
{
const char *path = 0;
unsigned type = 0;
file_list_get_at_offset(driver.menu->selection_buf, i, &path, &type, setting);
file_list_get_at_offset(driver.menu->selection_buf, i, &path, &type);
char message[256];
char type_str[256];

View File

@ -259,7 +259,7 @@ void *menu_init(const void *data)
#ifdef HAVE_SHADER_MANAGER
menu->shader = (struct gfx_shader*)calloc(1, sizeof(struct gfx_shader));
#endif
file_list_push(menu->menu_stack, "", "", MENU_SETTINGS, 0, NULL);
file_list_push(menu->menu_stack, "", "", MENU_SETTINGS, 0);
menu_clear_navigation(menu);
menu->push_start_screen = g_settings.menu_show_start_screen;
g_settings.menu_show_start_screen = false;
@ -374,11 +374,11 @@ void menu_flush_stack_type(unsigned final_type)
return;
driver.menu->need_refresh = true;
file_list_get_last(driver.menu->menu_stack, NULL, &type, setting);
file_list_get_last(driver.menu->menu_stack, NULL, &type);
while (type != final_type)
{
file_list_pop(driver.menu->menu_stack, &driver.menu->selection_ptr);
file_list_get_last(driver.menu->menu_stack, NULL, &type, setting);
file_list_get_last(driver.menu->menu_stack, NULL, &type);
}
}
@ -390,7 +390,6 @@ bool menu_iterate(void)
uint64_t input_state = 0;
int32_t input_entry_ret = 0;
int32_t ret = 0;
rarch_setting_t *setting = NULL;
if (!driver.menu)
return false;
@ -506,12 +505,12 @@ bool menu_iterate(void)
if (ret < 0)
{
unsigned type = 0;
file_list_get_last(driver.menu->menu_stack, NULL, &type, setting);
file_list_get_last(driver.menu->menu_stack, NULL, &type);
while (type != MENU_SETTINGS)
{
file_list_pop(driver.menu->menu_stack, &driver.menu->selection_ptr);
file_list_get_last(driver.menu->menu_stack, NULL, &type, setting);
file_list_get_last(driver.menu->menu_stack, NULL, &type);
}
}
@ -650,11 +649,10 @@ static inline int menu_list_get_first_char(file_list_t *buf, unsigned offset)
static inline bool menu_list_elem_is_dir(file_list_t *buf,
unsigned offset)
{
rarch_setting_t *setting = NULL;
const char *path = NULL;
unsigned type = 0;
file_list_get_at_offset(buf, offset, &path, &type, setting);
file_list_get_at_offset(buf, offset, &path, &type);
return type != MENU_FILE_PLAIN;
}
@ -694,5 +692,5 @@ void menu_build_scroll_indices(file_list_t *buf)
void menu_push_info_screen(void)
{
file_list_push(driver.menu->menu_stack, "", "", MENU_START_SCREEN, 0, NULL);
file_list_push(driver.menu->menu_stack, "", "", MENU_START_SCREEN, 0);
}