Skip to content

Commit

Permalink
fix: display proper capitalization and selected index in track menus (#…
Browse files Browse the repository at this point in the history
…902)

mpv upstream commit mpv-player/mpv@ab3b174 has introduced support for BCP 47 language tags,
and now track lang has uppercase and lowercase content.

Also avoids showing the selection status of secondary subtitle in the subtitle menu at the same time.
  • Loading branch information
dyphire authored May 6, 2024
1 parent e15523a commit 8936009
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit 8936009

Please sign in to comment.