mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 15:32:59 +00:00
(menu_explore.c) Cleanups
This commit is contained in:
parent
c7a3581ee5
commit
3517091a1e
@ -1160,11 +1160,11 @@ static int explore_action_ok_saveview(const char *path, const char *label, unsig
|
|||||||
|
|
||||||
static void explore_load_view(explore_state_t *state, const char* path)
|
static void explore_load_view(explore_state_t *state, const char* path)
|
||||||
{
|
{
|
||||||
unsigned cat;
|
|
||||||
rjson_t *json;
|
|
||||||
intfstream_t *file;
|
intfstream_t *file;
|
||||||
enum rjson_type type;
|
rjson_t* json;
|
||||||
uint8_t op = ((uint8_t)-1);
|
uint8_t op = ((uint8_t)-1);
|
||||||
|
unsigned cat;
|
||||||
|
enum rjson_type type;
|
||||||
|
|
||||||
state->view_levels = 0;
|
state->view_levels = 0;
|
||||||
state->view_search[0] = '\0';
|
state->view_search[0] = '\0';
|
||||||
@ -1185,19 +1185,18 @@ static void explore_load_view(explore_state_t *state, const char* path)
|
|||||||
if (depth == 1 && type == RJSON_STRING)
|
if (depth == 1 && type == RJSON_STRING)
|
||||||
{
|
{
|
||||||
const char* key = rjson_get_string(json, NULL);
|
const char* key = rjson_get_string(json, NULL);
|
||||||
if (string_is_equal(key, "filter_name")
|
if (string_is_equal(key, "filter_name") &&
|
||||||
&& rjson_next(json) == RJSON_STRING)
|
rjson_next(json) == RJSON_STRING)
|
||||||
strlcpy(state->view_search,
|
strlcpy(state->view_search,
|
||||||
rjson_get_string(json, NULL),
|
rjson_get_string(json, NULL), sizeof(state->view_search));
|
||||||
sizeof(state->view_search));
|
else if (string_is_equal(key, "filter_equal") &&
|
||||||
else if (string_is_equal(key, "filter_equal")
|
rjson_next(json) == RJSON_OBJECT)
|
||||||
&& rjson_next(json) == RJSON_OBJECT)
|
|
||||||
op = EXPLORE_OP_EQUAL;
|
op = EXPLORE_OP_EQUAL;
|
||||||
else if (string_is_equal(key, "filter_min")
|
else if (string_is_equal(key, "filter_min") &&
|
||||||
&& rjson_next(json) == RJSON_OBJECT)
|
rjson_next(json) == RJSON_OBJECT)
|
||||||
op = EXPLORE_OP_MIN;
|
op = EXPLORE_OP_MIN;
|
||||||
else if (string_is_equal(key, "filter_max")
|
else if (string_is_equal(key, "filter_max") &&
|
||||||
&& rjson_next(json) == RJSON_OBJECT)
|
rjson_next(json) == RJSON_OBJECT)
|
||||||
op = EXPLORE_OP_MAX;
|
op = EXPLORE_OP_MAX;
|
||||||
}
|
}
|
||||||
else if (depth == 2 && type == RJSON_STRING && op != ((uint8_t)-1))
|
else if (depth == 2 && type == RJSON_STRING && op != ((uint8_t)-1))
|
||||||
@ -1232,11 +1231,11 @@ static void explore_load_view(explore_state_t *state, const char* path)
|
|||||||
}
|
}
|
||||||
else if (value && entries)
|
else if (value && entries)
|
||||||
{
|
{
|
||||||
int cmp;
|
/* use existing qsort function for binary search */
|
||||||
/* Use existing qsort function for binary search */
|
|
||||||
explore_string_t *evalue = (explore_string_t *)
|
explore_string_t *evalue = (explore_string_t *)
|
||||||
(value - offsetof(explore_string_t, str));
|
(value - offsetof(explore_string_t, str));
|
||||||
uint32_t i, ifrom, ito, imax = (uint32_t)RBUF_LEN(entries);
|
uint32_t i, ifrom, ito, imax = (uint32_t)RBUF_LEN(entries);
|
||||||
|
int cmp;
|
||||||
int (*compare_func)(const void *, const void *) =
|
int (*compare_func)(const void *, const void *) =
|
||||||
(explore_by_info[cat].is_numeric
|
(explore_by_info[cat].is_numeric
|
||||||
? explore_qsort_func_nums
|
? explore_qsort_func_nums
|
||||||
@ -1262,15 +1261,13 @@ static void explore_load_view(explore_state_t *state, const char* path)
|
|||||||
{
|
{
|
||||||
state->view_idx_min[lvl] = (cmp ? i + 1 : i);
|
state->view_idx_min[lvl] = (cmp ? i + 1 : i);
|
||||||
valid_op = ((lvl != lvl_max && state->view_op[lvl] == EXPLORE_OP_MAX)
|
valid_op = ((lvl != lvl_max && state->view_op[lvl] == EXPLORE_OP_MAX)
|
||||||
? EXPLORE_OP_RANGE
|
? EXPLORE_OP_RANGE : EXPLORE_OP_MIN);
|
||||||
: EXPLORE_OP_MIN);
|
|
||||||
}
|
}
|
||||||
else if (op == EXPLORE_OP_MAX)
|
else if (op == EXPLORE_OP_MAX)
|
||||||
{
|
{
|
||||||
state->view_idx_max[lvl] = i;
|
state->view_idx_max[lvl] = i;
|
||||||
valid_op = ((lvl != lvl_max && state->view_op[lvl] == EXPLORE_OP_MIN)
|
valid_op = ((lvl != lvl_max && state->view_op[lvl] == EXPLORE_OP_MIN)
|
||||||
? EXPLORE_OP_RANGE
|
? EXPLORE_OP_RANGE : EXPLORE_OP_MAX);
|
||||||
: EXPLORE_OP_MAX);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (valid_op != ((uint8_t)-1))
|
if (valid_op != ((uint8_t)-1))
|
||||||
@ -1278,14 +1275,15 @@ static void explore_load_view(explore_state_t *state, const char* path)
|
|||||||
state->view_op [lvl] = valid_op;
|
state->view_op [lvl] = valid_op;
|
||||||
state->view_cats [lvl] = cat;
|
state->view_cats [lvl] = cat;
|
||||||
state->view_use_split[lvl] = explore_by_info[cat].use_split;
|
state->view_use_split[lvl] = explore_by_info[cat].use_split;
|
||||||
if (lvl == lvl_max)
|
if (lvl == lvl_max) state->view_levels++;
|
||||||
state->view_levels++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (depth == 1 && type == RJSON_OBJECT_END)
|
else if (depth == 1 && type == RJSON_OBJECT_END)
|
||||||
|
{
|
||||||
op = ((uint8_t)-1);
|
op = ((uint8_t)-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rjson_free(json);
|
rjson_free(json);
|
||||||
intfstream_close(file);
|
intfstream_close(file);
|
||||||
free(file);
|
free(file);
|
||||||
@ -1302,21 +1300,17 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
|
|||||||
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
|
file_list_t *menu_stack = MENU_LIST_GET(menu_list, 0);
|
||||||
struct item_file *stack_top = menu_stack->list;
|
struct item_file *stack_top = menu_stack->list;
|
||||||
size_t depth = menu_stack->size;
|
size_t depth = menu_stack->size;
|
||||||
unsigned current_type = 0;
|
unsigned current_type = (depth > 0 ? stack_top[depth - 1].type : 0);
|
||||||
unsigned previous_type = 0;
|
unsigned previous_type = (depth > 1 ? stack_top[depth - 2].type : 0);
|
||||||
|
unsigned current_cat = current_type - EXPLORE_TYPE_FIRSTCATEGORY;
|
||||||
|
|
||||||
if (depth > 0)
|
|
||||||
{
|
|
||||||
current_type = stack_top[depth - 1].type;
|
|
||||||
/* Overwrite the menu title function with our custom one */
|
|
||||||
/* Depth 1 is never popped so we can only do this on sub menus */
|
|
||||||
if (depth > 1)
|
if (depth > 1)
|
||||||
{
|
{
|
||||||
previous_type = stack_top[depth - 2].type;
|
/* overwrite the menu title function with our custom one */
|
||||||
|
/* depth 1 is never popped so we can only do this on sub menus */
|
||||||
((menu_file_list_cbs_t*)stack_top[depth - 1].actiondata)
|
((menu_file_list_cbs_t*)stack_top[depth - 1].actiondata)
|
||||||
->action_get_title = explore_action_get_title;
|
->action_get_title = explore_action_get_title;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
{
|
{
|
||||||
@ -1330,10 +1324,10 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
|
|||||||
msg_hash_to_str(MENU_ENUM_LABEL_EXPLORE_INITIALISING_LIST),
|
msg_hash_to_str(MENU_ENUM_LABEL_EXPLORE_INITIALISING_LIST),
|
||||||
MENU_ENUM_LABEL_EXPLORE_INITIALISING_LIST,
|
MENU_ENUM_LABEL_EXPLORE_INITIALISING_LIST,
|
||||||
FILE_TYPE_NONE, 0, 0, NULL);
|
FILE_TYPE_NONE, 0, 0, NULL);
|
||||||
|
|
||||||
|
return (unsigned)list->size;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned current_cat = current_type - EXPLORE_TYPE_FIRSTCATEGORY;
|
|
||||||
/* check if we are opening a saved view */
|
/* check if we are opening a saved view */
|
||||||
if (current_type == MENU_SETTING_HORIZONTAL_MENU || current_type == MENU_EXPLORE_TAB)
|
if (current_type == MENU_SETTING_HORIZONTAL_MENU || current_type == MENU_EXPLORE_TAB)
|
||||||
{
|
{
|
||||||
@ -1440,24 +1434,23 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
|
|||||||
&& !explore_by_info[cat].is_boolean
|
&& !explore_by_info[cat].is_boolean
|
||||||
&& RBUF_LEN(state->by[cat]) > 1))
|
&& RBUF_LEN(state->by[cat]) > 1))
|
||||||
{
|
{
|
||||||
strlcpy(tmp, msg_hash_to_str(explore_by_info[cat].by_enum),
|
size_t tmplen = strlcpy(tmp,
|
||||||
sizeof(tmp));
|
msg_hash_to_str(explore_by_info[cat].by_enum), sizeof(tmp));
|
||||||
|
|
||||||
if (is_top)
|
if (is_top)
|
||||||
{
|
{
|
||||||
size_t tmplen = strlcat(tmp, " (", sizeof(tmp));
|
|
||||||
if (explore_by_info[cat].is_numeric)
|
if (explore_by_info[cat].is_numeric)
|
||||||
{
|
snprintf(tmp + tmplen, sizeof(tmp) - tmplen, " (%s - %s)",
|
||||||
strlcat(tmp, entries[0]->str, sizeof(tmp));
|
entries[0]->str, entries[RBUF_LEN(entries) - 1]->str);
|
||||||
strlcat(tmp, " - ", sizeof(tmp));
|
|
||||||
strlcat(tmp, entries[RBUF_LEN(entries) - 1]->str, sizeof(tmp));
|
|
||||||
}
|
|
||||||
else if (!explore_by_info[cat].is_boolean)
|
else if (!explore_by_info[cat].is_boolean)
|
||||||
|
{
|
||||||
|
strlcat(tmp, " (", sizeof(tmp));
|
||||||
snprintf(tmp + tmplen + 2, sizeof(tmp) - tmplen - 2,
|
snprintf(tmp + tmplen + 2, sizeof(tmp) - tmplen - 2,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_ITEMS_COUNT),
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_ITEMS_COUNT),
|
||||||
(unsigned)RBUF_LEN(entries));
|
(unsigned)RBUF_LEN(entries));
|
||||||
strlcat(tmp, ")", sizeof(tmp));
|
strlcat(tmp, ")", sizeof(tmp));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (i != state->view_levels)
|
else if (i != state->view_levels)
|
||||||
{
|
{
|
||||||
strlcat(tmp, " (", sizeof(tmp));
|
strlcat(tmp, " (", sizeof(tmp));
|
||||||
@ -1522,15 +1515,19 @@ unsigned menu_displaylist_explore(file_list_t *list, settings_t *settings)
|
|||||||
size_t first_list_entry;
|
size_t first_list_entry;
|
||||||
|
|
||||||
if (is_show_all)
|
if (is_show_all)
|
||||||
|
{
|
||||||
explore_append_title(state,
|
explore_append_title(state,
|
||||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_ALL));
|
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_EXPLORE_ALL));
|
||||||
|
}
|
||||||
|
|
||||||
if (is_filtered_category)
|
if (is_filtered_category)
|
||||||
{
|
{
|
||||||
/* List filtered items in a selected explore by category */
|
/* List filtered items in a selected explore by category */
|
||||||
if (!view_levels || view_cats[view_levels - 1] != current_cat)
|
if (!view_levels || view_cats[view_levels - 1] != current_cat)
|
||||||
|
{
|
||||||
explore_append_title(state, " / %s",
|
explore_append_title(state, " / %s",
|
||||||
msg_hash_to_str(explore_by_info[current_cat].by_enum));
|
msg_hash_to_str(explore_by_info[current_cat].by_enum));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* List all items again when setting a range filter */
|
/* List all items again when setting a range filter */
|
||||||
@ -1661,12 +1658,13 @@ SKIP_ENTRY:;
|
|||||||
{
|
{
|
||||||
menu_displaylist_info_t info;
|
menu_displaylist_info_t info;
|
||||||
const struct playlist_entry* pl_first = NULL;
|
const struct playlist_entry* pl_first = NULL;
|
||||||
playlist_t *pl = state->playlists[pl_idx];
|
playlist_t *pl =
|
||||||
|
state->playlists[pl_idx];
|
||||||
|
|
||||||
playlist_get_index(pl, 0, &pl_first);
|
playlist_get_index(pl, 0, &pl_first);
|
||||||
|
|
||||||
if ( (pl_entry < pl_first)
|
if ( pl_entry < pl_first ||
|
||||||
|| (pl_entry >= pl_first + playlist_size(pl)))
|
pl_entry >= pl_first + playlist_size(pl))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Fake all the state so the content screen
|
/* Fake all the state so the content screen
|
||||||
@ -1682,7 +1680,6 @@ SKIP_ENTRY:;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (unsigned)list->size;
|
return (unsigned)list->size;
|
||||||
}
|
}
|
||||||
@ -1690,27 +1687,22 @@ SKIP_ENTRY:;
|
|||||||
uintptr_t menu_explore_get_entry_icon(unsigned type)
|
uintptr_t menu_explore_get_entry_icon(unsigned type)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
explore_entry_t *e;
|
if (!explore_state || !explore_state->show_icons
|
||||||
if ( !explore_state
|
|
||||||
|| !explore_state->show_icons
|
|
||||||
|| type < EXPLORE_TYPE_FIRSTITEM)
|
|| type < EXPLORE_TYPE_FIRSTITEM)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
i = (type - EXPLORE_TYPE_FIRSTITEM);
|
i = (type - EXPLORE_TYPE_FIRSTITEM);
|
||||||
|
if (explore_state->show_icons == EXPLORE_ICONS_CONTENT)
|
||||||
switch (explore_state->show_icons)
|
|
||||||
{
|
{
|
||||||
case EXPLORE_ICONS_CONTENT:
|
explore_entry_t* e = &explore_state->entries[i];
|
||||||
e = &explore_state->entries[i];
|
|
||||||
if (e < RBUF_END(explore_state->entries))
|
if (e < RBUF_END(explore_state->entries))
|
||||||
return explore_state->icons[e->by[EXPLORE_BY_SYSTEM]->idx];
|
return explore_state->icons[e->by[EXPLORE_BY_SYSTEM]->idx];
|
||||||
break;
|
}
|
||||||
case EXPLORE_ICONS_SYSTEM_CATEGORY:
|
else if (explore_state->show_icons == EXPLORE_ICONS_SYSTEM_CATEGORY)
|
||||||
|
{
|
||||||
if (i < RBUF_LEN(explore_state->icons))
|
if (i < RBUF_LEN(explore_state->icons))
|
||||||
return explore_state->icons[i];
|
return explore_state->icons[i];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user