This commit is contained in:
libretroadmin 2023-05-10 19:03:16 +02:00
parent 1ad253e81a
commit 3706c4e464
3 changed files with 43 additions and 56 deletions

View File

@ -4609,14 +4609,23 @@ static void ozone_sidebar_goto(
static void ozone_sidebar_entries_build_scroll_indices(ozone_handle_t *ozone) static void ozone_sidebar_entries_build_scroll_indices(ozone_handle_t *ozone)
{ {
size_t i = 0; size_t i = 0;
int current = menu_entries_elem_get_first_char(&ozone->horizontal_list, 0); const char *path = ozone->horizontal_list.list[0].alt
? ozone->horizontal_list.list[0].alt
: ozone->horizontal_list.list[0].path;
int ret = path ? TOLOWER((int)*path) : 0;
int current = ELEM_GET_FIRST_CHAR(ret);
ozone->sidebar_index_list[0] = 0; ozone->sidebar_index_list[0] = 0;
ozone->sidebar_index_size = 1; ozone->sidebar_index_size = 1;
for (i = 1; i < ozone->horizontal_list.size; i++) for (i = 1; i < ozone->horizontal_list.size; i++)
{ {
int first = menu_entries_elem_get_first_char(&ozone->horizontal_list, (unsigned)i); int first;
path = ozone->horizontal_list.list[i].alt
? ozone->horizontal_list.list[i].alt
: ozone->horizontal_list.list[i].path;
ret = path ? TOLOWER((int)*path) : 0;
first = ELEM_GET_FIRST_CHAR(ret);
if (first != current) if (first != current)
{ {
@ -4626,7 +4635,7 @@ static void ozone_sidebar_entries_build_scroll_indices(ozone_handle_t *ozone)
ozone->sidebar_index_size++; ozone->sidebar_index_size++;
} }
current = first; current = first;
} }
/* Add scroll index */ /* Add scroll index */

View File

@ -1031,7 +1031,8 @@ int menu_entries_get_title(char *s, size_t len)
unsigned menu_type = 0; unsigned menu_type = 0;
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
struct menu_state *menu_st = &menu_driver_state; struct menu_state *menu_st = &menu_driver_state;
menu_handle_t *menu = menu_st->driver_data;
const file_list_t *list = menu_st->entries.list ? const file_list_t *list = menu_st->entries.list ?
MENU_LIST_GET(menu_st->entries.list, 0) : NULL; MENU_LIST_GET(menu_st->entries.list, 0) : NULL;
menu_file_list_cbs_t *cbs = list menu_file_list_cbs_t *cbs = list
@ -1060,13 +1061,11 @@ int menu_entries_get_title(char *s, size_t len)
/* Show playlist entry instead of "Quick Menu" */ /* Show playlist entry instead of "Quick Menu" */
if (string_is_equal(label, "deferred_rpl_entry_actions")) if (string_is_equal(label, "deferred_rpl_entry_actions"))
{ {
const struct playlist_entry *entry = NULL; playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (playlist) if (playlist)
{ {
menu_handle_t *menu = menu_state_get_ptr()->driver_data; const struct playlist_entry *entry = NULL;
playlist_get_index(playlist, menu->rpl_entry_selection_ptr, &entry); playlist_get_index(playlist, menu->rpl_entry_selection_ptr, &entry);
if (entry) if (entry)
strlcpy(s, strlcpy(s,
!string_is_empty(entry->label) ? entry->label : entry->path, !string_is_empty(entry->label) ? entry->label : entry->path,
@ -1092,34 +1091,31 @@ int menu_entries_get_title(char *s, size_t len)
* behaviour... */ * behaviour... */
static void menu_input_pointer_close_messagebox(struct menu_state *menu_st) static void menu_input_pointer_close_messagebox(struct menu_state *menu_st)
{ {
const char *label = NULL; const file_list_t *list = MENU_LIST_GET(menu_st->entries.list, 0);
const file_list_t *list = MENU_LIST_GET(menu_st->entries.list, 0); const char *label = list->list[list->size - 1].label;
#ifdef HAVE_AUDIOMIXER
/* Determine whether this is a help or info /* Determine whether this is a help or info
* message box */ * message box */
if (list && list->size) if (list && list->size)
{ {
label = list->list[list->size - 1].label;
/* Play sound for closing the info box */ /* Play sound for closing the info box */
#ifdef HAVE_AUDIOMIXER settings_t *settings = config_get_ptr();
{ bool audio_enable_menu = settings->bools.audio_enable_menu;
settings_t *settings = config_get_ptr(); bool audio_enable_menu_notice = settings->bools.audio_enable_menu_notice;
bool audio_enable_menu = settings->bools.audio_enable_menu; if (audio_enable_menu && audio_enable_menu_notice)
bool audio_enable_menu_notice = settings->bools.audio_enable_menu_notice; audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK);
if (audio_enable_menu && audio_enable_menu_notice)
audio_driver_mixer_play_menu_sound(AUDIO_MIXER_SYSTEM_SLOT_NOTICE_BACK);
}
#endif
} }
#endif
/* Pop stack, if required */ /* Pop stack, if required */
if (menu_should_pop_stack(label)) if (menu_should_pop_stack(label))
{ {
size_t selection = menu_st->selection_ptr; size_t selection = menu_st->selection_ptr;
size_t new_selection = selection; size_t new_selection = selection;
menu_entries_pop_stack(&new_selection, 0, 0); menu_entries_pop_stack(&new_selection, 0, 0);
menu_st->selection_ptr = selection; menu_st->selection_ptr = selection;
} }
} }
@ -3782,40 +3778,17 @@ static void menu_input_set_pointer_visibility(
} }
} }
/**
* menu_entries_elem_get_first_char:
* @list : File list handle.
* @offset : Offset index of element.
*
* Gets the first character of an element in the
* file list.
*
* Returns: first character of element in file list.
**/
int menu_entries_elem_get_first_char(
file_list_t *list, unsigned offset)
{
const char *path = list->list[offset].alt
? list->list[offset].alt
: list->list[offset].path;
int ret = path ? TOLOWER((int)*path) : 0;
/* "Normalize" non-alphabetical entries so they
* are lumped together for purposes of jumping. */
if (ret < 'a')
return ('a' - 1);
else if (ret > 'z')
return ('z' + 1);
return ret;
}
void menu_entries_build_scroll_indices( void menu_entries_build_scroll_indices(
struct menu_state *menu_st, struct menu_state *menu_st,
file_list_t *list) file_list_t *list)
{ {
bool current_is_dir = false; bool current_is_dir = false;
size_t i = 0; size_t i = 0;
int current = menu_entries_elem_get_first_char(list, 0); const char *path = list->list[0].alt
? list->list[0].alt
: list->list[0].path;
int ret = path ? TOLOWER((int)*path) : 0;
int current = ELEM_GET_FIRST_CHAR(ret);
unsigned type = list->list[0].type; unsigned type = list->list[0].type;
menu_st->scroll.index_list[0] = 0; menu_st->scroll.index_list[0] = 0;
@ -3826,14 +3799,18 @@ void menu_entries_build_scroll_indices(
for (i = 1; i < list->size; i++) for (i = 1; i < list->size; i++)
{ {
int first = menu_entries_elem_get_first_char(list, (unsigned)i); int first;
bool is_dir = false; bool is_dir = false;
unsigned idx = (unsigned)i; unsigned idx = (unsigned)i;
path = list->list[i].alt
? list->list[i].alt
: list->list[i].path;
ret = path ? TOLOWER((int)*path) : 0;
first = ELEM_GET_FIRST_CHAR(ret);
type = list->list[idx].type; type = list->list[idx].type;
if (type == FILE_TYPE_DIRECTORY) if (type == FILE_TYPE_DIRECTORY)
is_dir = true; is_dir = true;
if ((current_is_dir && !is_dir) || (first != current)) if ((current_is_dir && !is_dir) || (first != current))
{ {

View File

@ -716,8 +716,9 @@ enum action_iterate_type
int generic_menu_entry_action(void *userdata, menu_entry_t *entry, size_t i, enum menu_action action); int generic_menu_entry_action(void *userdata, menu_entry_t *entry, size_t i, enum menu_action action);
int menu_entries_elem_get_first_char( /* "Normalize" non-alphabetical entries so they
file_list_t *list, unsigned offset); * are lumped together for purposes of jumping. */
#define ELEM_GET_FIRST_CHAR(ret) ((ret < 'a') ? ('a' - 1) : (ret > 'z') ? ('z' + 1) : ret)
void menu_entries_build_scroll_indices( void menu_entries_build_scroll_indices(
struct menu_state *menu_st, struct menu_state *menu_st,