Random selector Explore View fix (#17518)

This commit is contained in:
sonninnos 2025-02-04 21:29:20 +02:00 committed by GitHub
parent ea22c7c16c
commit 94d5223880
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 91 deletions

View File

@ -9352,29 +9352,7 @@ static enum menu_action materialui_parse_menu_entry_action(
else if ((mui->flags & MUI_FLAG_IS_PLAYLIST)
|| (mui->flags & MUI_FLAG_IS_EXPLORE_LIST))
{
struct menu_state *menu_st = menu_state_get_ptr();
size_t selection_start = 0;
size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0;
size_t selection = menu_st->selection_ptr;
size_t new_selection = selection;
/* Skip header items (Search Name + Add Additional Filter + Save as View) */
if (mui->flags & MUI_FLAG_IS_EXPLORE_LIST)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
menu_entry_get(&entry, 0, 0, NULL, true);
if (entry.type == MENU_SETTINGS_LAST + 1)
selection_start = 1;
else if (entry.type == FILE_TYPE_RDB)
selection_start = 2;
}
new_selection = random_range(selection_start, selection_total - 1);
while (new_selection == selection && selection_start != selection_total - 1)
new_selection = random_range(selection_start, selection_total - 1);
size_t new_selection = menu_playlist_random_selection(selection, mui->flags & MUI_FLAG_IS_EXPLORE_LIST);
if (new_selection != selection)
{

View File

@ -8218,27 +8218,9 @@ static enum menu_action ozone_parse_menu_entry_action(
else if ((ozone->flags & OZONE_FLAG_IS_PLAYLIST)
|| (ozone->flags & OZONE_FLAG_IS_EXPLORE_LIST))
{
size_t selection_start = 0;
size_t new_selection = menu_playlist_random_selection(selection, ozone->flags & OZONE_FLAG_IS_EXPLORE_LIST);
/* Skip header items (Search Name + Add Additional Filter + Save as View) */
if (ozone->flags & OZONE_FLAG_IS_EXPLORE_LIST)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
menu_entry_get(&entry, 0, 0, NULL, true);
if (entry.type == MENU_SETTINGS_LAST + 1)
selection_start = 1;
else if (entry.type == FILE_TYPE_RDB)
selection_start = 2;
}
new_selection = random_range(selection_start, selection_total - 1);
while (new_selection == (int)selection && selection_start != selection_total - 1)
new_selection = random_range(selection_start, selection_total - 1);
if (new_selection != (int)selection)
if (new_selection != selection)
{
menu_st->selection_ptr = new_selection;
ozone_selection_changed(ozone, false);
@ -8248,7 +8230,7 @@ static enum menu_action ozone_parse_menu_entry_action(
new_action = MENU_ACTION_NOOP;
#ifdef HAVE_AUDIOMIXER
if (new_selection != (int)selection)
if (new_selection != selection)
audio_driver_mixer_play_scroll_sound(true);
#endif
break;

View File

@ -7989,6 +7989,7 @@ static enum menu_action rgui_parse_menu_entry_action(
menu_entry_t *entry,
enum menu_action action)
{
struct menu_state *menu_st = menu_state_get_ptr();
enum menu_action new_action = action;
/* Scan user inputs */
@ -8056,7 +8057,6 @@ static enum menu_action rgui_parse_menu_entry_action(
if (string_is_equal(rgui->menu_title, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MAIN_MENU)))
{
struct menu_state *menu_st = menu_state_get_ptr();
/* Jump to first item on Main Menu */
menu_st->selection_ptr = 0;
new_action = MENU_ACTION_NOOP;
@ -8112,7 +8112,6 @@ static enum menu_action rgui_parse_menu_entry_action(
case MENU_ACTION_SCAN:
if (rgui->flags & RGUI_FLAG_IS_PLAYLISTS_TAB)
{
struct menu_state *menu_st = menu_state_get_ptr();
size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0;
size_t selection = menu_st->selection_ptr;
size_t new_selection = random_range(0, selection_total - 1);
@ -8145,29 +8144,8 @@ static enum menu_action rgui_parse_menu_entry_action(
else if ((rgui->flags & RGUI_FLAG_IS_PLAYLIST)
|| (rgui->flags & RGUI_FLAG_IS_EXPLORE_LIST))
{
struct menu_state *menu_st = menu_state_get_ptr();
size_t selection_start = 0;
size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0;
size_t selection = menu_st->selection_ptr;
size_t new_selection = selection;
/* Skip header items (Search Name + Add Additional Filter + Save as View) */
if (rgui->flags & RGUI_FLAG_IS_EXPLORE_LIST)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
menu_entry_get(&entry, 0, 0, NULL, true);
if (entry.type == MENU_SETTINGS_LAST + 1)
selection_start = 1;
else if (entry.type == FILE_TYPE_RDB)
selection_start = 2;
}
new_selection = random_range(selection_start, selection_total - 1);
while (new_selection == selection && selection_start != selection_total - 1)
new_selection = random_range(selection_start, selection_total - 1);
size_t selection = menu_st->selection_ptr;
size_t new_selection = menu_playlist_random_selection(selection, rgui->flags & RGUI_FLAG_IS_EXPLORE_LIST);
if (new_selection != selection)
{

View File

@ -5591,28 +5591,8 @@ static enum menu_action xmb_parse_menu_entry_action(
else if ((xmb->is_playlist)
|| (xmb->is_explore_list))
{
size_t selection_start = 0;
size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0;
size_t selection = menu_st->selection_ptr;
size_t new_selection = selection;
/* Skip header items (Search Name + Add Additional Filter + Save as View) */
if (xmb->is_explore_list)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
menu_entry_get(&entry, 0, 0, NULL, true);
if (entry.type == MENU_SETTINGS_LAST + 1)
selection_start = 1;
else if (entry.type == FILE_TYPE_RDB)
selection_start = 2;
}
new_selection = random_range(selection_start, selection_total - 1);
while (new_selection == selection && selection_start != selection_total - 1)
new_selection = random_range(selection_start, selection_total - 1);
size_t selection = menu_st->selection_ptr;
size_t new_selection = menu_playlist_random_selection(selection, xmb->is_explore_list);
if (new_selection != selection)
{

View File

@ -21,6 +21,7 @@
#endif
#include <retro_timers.h>
#include <retro_math.h>
#include <file/file_path.h>
#include <lists/dir_list.h>
#include <string/stdstring.h>
@ -8106,3 +8107,32 @@ void menu_update_runahead_mode(void)
menu_st->runahead_mode = MENU_RUNAHEAD_MODE_OFF;
}
#endif
/* Common method for ignoring specifics while picking random playlist items. */
size_t menu_playlist_random_selection(size_t selection, bool is_explore_list)
{
struct menu_state *menu_st = menu_state_get_ptr();
size_t selection_start = 0;
size_t selection_total = menu_st->entries.list ? MENU_LIST_GET_SELECTION(menu_st->entries.list, 0)->size : 0;
size_t new_selection = selection;
/* Skip header items (Search Name + Add Additional Filter + Save as View + Delete this View) */
if (is_explore_list)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);
menu_entry_get(&entry, 0, 0, NULL, true);
if (entry.type == MENU_SETTINGS_LAST + 1 || entry.type == FILE_TYPE_PLAIN)
selection_start = 1;
else if (entry.type == FILE_TYPE_RDB)
selection_start = 2;
}
new_selection = random_range(selection_start, selection_total - 1);
while (new_selection == selection && selection_start != selection_total - 1)
new_selection = random_range(selection_start, selection_total - 1);
return new_selection;
}

View File

@ -745,6 +745,9 @@ bool menu_input_key_bind_set_mode(
void menu_update_runahead_mode(void);
#endif
size_t menu_playlist_random_selection(
size_t selection, bool is_explore_list);
extern const menu_ctx_driver_t *menu_ctx_drivers[];
extern menu_ctx_driver_t menu_ctx_ozone;