diff options
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -472,6 +472,12 @@ local function set_menu_sort(menu, bool) menu.sorted = bool end +-- refresh options when navigating up the stack to a previous favourites menu. +-- existing menu options are never removed, even if unfavourited. if the order +-- of still-favourited items is unchanged and no new favourites have been added +-- before the last still-favourited item, the existing order is kept and all +-- new favourites are appended to the end of the menu. otherwise, the new order +-- is used and any unfavourited options are moved to the end. local function refresh_favourites_menu() local menu = menus[depth] local opt = menu.options[menu.cursor] @@ -485,12 +491,32 @@ local function refresh_favourites_menu() for _, v in ipairs(options) do seen[v.id] = true end + + local same = true + local ind = 1 for _, v in ipairs(menu.options) do - if not seen[v.id] then - options[#options+1] = v + if seen[v.id] then + if v.id == options[ind].id then + ind = ind + 1 + else + same = false + break + end end end - menu.options = options + + if same then + for i = ind, #options do + menu.options[#menu.options+1] = options[i] + end + else + for _, v in ipairs(menu.options) do + if not seen[v.id] then + options[#options+1] = v + end + end + menu.options = options + end if sorted then set_menu_sort(menu, true) |
