Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menus.lua: tweaks and fixes the display of the track menu #902

Merged
merged 2 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function create_select_tracklist_type_menu_opener(menu_title, track_type, track_
items[#items].separator = true
end

local track_prop_index = tonumber(mp.get_property(track_prop))
local first_item_index = #items + 1
local active_index = nil
local disabled_item = nil
Expand All @@ -126,9 +127,10 @@ function create_select_tracklist_type_menu_opener(menu_title, track_type, track_
for _, track in ipairs(tracklist) do
if track.type == track_type then
local hint_values = {}
local track_selected = track.selected and track.id == track_prop_index
local function h(value) hint_values[#hint_values + 1] = value end

if track.lang then h(track.lang:upper()) end
if track.lang then h(track.lang) end
if track['demux-h'] then
h(track['demux-w'] and (track['demux-w'] .. 'x' .. track['demux-h']) or (track['demux-h'] .. 'p'))
end
Expand All @@ -148,10 +150,10 @@ function create_select_tracklist_type_menu_opener(menu_title, track_type, track_
title = (track.title and track.title or t('Track %s', track.id)),
hint = table.concat(hint_values, ', '),
value = track.id,
active = track.selected,
active = track_selected,
}

if track.selected then
if track_selected then
if disabled_item then disabled_item.active = false end
active_index = #items
end
Expand Down