menu: remembered selections stay inside their arrays

RGUI remembers a selection per playlist in playlist_selection[], indexed
by the playlist's row in the Playlists screen, and XMB and Ozone one per
tab in tab_selection[], indexed by the tab, which counts one per
playlist. A row or tab past the array is neither remembered nor
restored, as materialui already does with its own slots: with more
playlists than slots, the writes went into the fields after the array -
in RGUI the History and Favorites selections - and the restores read
from them.
This commit is contained in:
libretroadmin committed 2026-10-05 08:36:49 +02:00
1 parent 6d5d0ed006
commit 8997645db0
3 files changed
+25 -10

No files matched your search

+13 -5
View File
@@ -4419,8 +4419,10 @@ static void ozone_go_to_sidebar(ozone_handle_t *ozone,
if (menu_show_sublabels && menu_current_sel_only)
ozone->flags |= OZONE_FLAG_NEED_COMPUTE;
/* Remember last selection per tab */
ozone->tab_selection[ozone->categories_selection_ptr] = ozone->selection;
/* Remember last selection per tab, for as many tabs as the array
* holds */
if (ozone->categories_selection_ptr < ARRAY_SIZE(ozone->tab_selection))
ozone->tab_selection[ozone->categories_selection_ptr] = ozone->selection;
ozone_sidebar_update_collapse(ozone, ozone_collapse_sidebar, true);
@@ -4667,7 +4669,10 @@ static void ozone_tab_set_selection(void *data)
if ( ozone
&& !(ozone->flags2 & OZONE_FLAG2_LAST_POINTER_IN_SIDEBAR))
{
size_t tab_selection = ozone->tab_selection[ozone->categories_selection_ptr];
size_t tab_selection =
(ozone->categories_selection_ptr < ARRAY_SIZE(ozone->tab_selection))
? ozone->tab_selection[ozone->categories_selection_ptr]
: 0;
if (tab_selection)
{
struct menu_state *menu_st = menu_state_get_ptr();
@@ -9043,7 +9048,9 @@ static enum menu_action ozone_parse_menu_entry_action(
NULL,
MENU_ENUM_LABEL_PLAYLIST_MANAGER_SETTINGS_STR,
MENU_SETTING_ACTION,
ozone->tab_selection[ozone->categories_selection_ptr],
(ozone->categories_selection_ptr < ARRAY_SIZE(ozone->tab_selection))
? ozone->tab_selection[ozone->categories_selection_ptr]
: 0,
0,
ACTION_OK_DL_PLAYLIST_MANAGER_SETTINGS);
@@ -9471,7 +9478,8 @@ static enum menu_action ozone_parse_menu_entry_action(
else
{
/* Jump to first item on Main Menu */
ozone->tab_selection[ozone->categories_selection_ptr] = 0;
if (ozone->categories_selection_ptr < ARRAY_SIZE(ozone->tab_selection))
ozone->tab_selection[ozone->categories_selection_ptr] = 0;
menu_st->selection_ptr = 0;
}
+3 -2
View File
@@ -8190,7 +8190,8 @@ static void rgui_navigation_set(void *data, bool scroll)
rgui->playlist_mainmenu_selection[RGUI_MAINMENU_HISTORY] = selection;
else if (string_is_equal(rgui->menu_title, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB)))
rgui->playlist_mainmenu_selection[RGUI_MAINMENU_FAVORITES] = selection;
else
/* one slot per playlist, for as many as the array holds */
else if (rgui->playlist_selection_ptr < ARRAY_SIZE(rgui->playlist_selection))
rgui->playlist_selection[rgui->playlist_selection_ptr] = selection;
}
else if (rgui->flags & RGUI_FLAG_IS_PLAYLISTS_TAB)
@@ -8385,7 +8386,7 @@ static void rgui_populate_entries(
menu_st->selection_ptr = rgui->playlist_mainmenu_selection[RGUI_MAINMENU_HISTORY];
else if (string_is_equal(rgui->menu_title, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES_TAB)))
menu_st->selection_ptr = rgui->playlist_mainmenu_selection[RGUI_MAINMENU_FAVORITES];
else
else if (rgui->playlist_selection_ptr < ARRAY_SIZE(rgui->playlist_selection))
menu_st->selection_ptr = rgui->playlist_selection[rgui->playlist_selection_ptr];
}
}
+9 -3
View File
@@ -3325,7 +3325,11 @@ static void xmb_tab_set_selection(void *data)
if (xmb)
{
size_t tab_selection = xmb->tab_selection[xmb->categories_selection_ptr];
/* one slot per tab, for as many tabs as the array holds */
size_t tab_selection =
(xmb->categories_selection_ptr < ARRAY_SIZE(xmb->tab_selection))
? xmb->tab_selection[xmb->categories_selection_ptr]
: 0;
if (tab_selection)
{
struct menu_state *menu_st = menu_state_get_ptr();
@@ -10750,8 +10754,10 @@ static void xmb_list_cache(void *data, enum menu_list_type type,
case MENU_LIST_HORIZONTAL:
xmb->categories_selection_ptr_old = xmb->categories_selection_ptr;
/* Remember last selection per tab */
xmb->tab_selection[xmb->categories_selection_ptr] = selection;
/* Remember last selection per tab, for as many tabs as the
* array holds */
if (xmb->categories_selection_ptr < ARRAY_SIZE(xmb->tab_selection))
xmb->tab_selection[xmb->categories_selection_ptr] = selection;
switch (action)
{