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