Skip to content

Commit

Permalink
同步与整合上游
Browse files Browse the repository at this point in the history
核心:
同步 --watch-later-dir --sub-ass-style-overrides --screenshot-dir
修正 --dscale

脚本:
osc_plus 修复 #378
uosc 同步上游

着色器:
新增 CfL_Prediction_Lite, MemeBilateral_Lite 由 https://github.com/deus0ww 创建
  • Loading branch information
hooke007 committed Oct 31, 2023
1 parent e7fb21f commit c4bef42
Show file tree
Hide file tree
Showing 16 changed files with 641 additions and 247 deletions.
8 changes: 4 additions & 4 deletions portable_config/mpv.conf
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
gpu-shader-cache = yes # 是否在本地存储GLSL着色器的编译缓存,可以提高启动性能,默认 yes
gpu-shader-cache-dir =
# 指定GLSL着色器的编译缓存目录(例值 "~~/_cache/shader"),Windows平台便携式设置下的默认实际为 "~~/cache"
watch-later-directory =
watch-later-dir =
# 稍后观看功能的缓存目录,其中的文件记录 --watch-later-options 指定的项。WIN平台默认为 "~~/watch_later"


Expand Down Expand Up @@ -179,7 +179,7 @@

cscale = # 色度还原算法。若不设定,则自动采用 --scale 的值
scale = lanczos # 放大算法,默认值 lanczos (追求最快算法可用 bilinear )
dscale = # 缩小算法。若不设定,则自动采用 --scale 的值
dscale = hermite # 缩小算法。默认值 hermite 。若设为空值,则自动采用 --scale 的值
##所有可用的内置算法参见手册 [06]

linear-upscaling = no # [须 --fbo-format 指定16位及以上的精度;与 --sigmoid-upscaling 不兼容] (对HDR内容无影响)默认 no
Expand Down Expand Up @@ -286,7 +286,7 @@
sub-ass-scale-with-window = no # 字幕随窗口缩放而不是随视频缩放,默认 no
embeddedfonts = yes # 是否使用mkv容器的内嵌字体,默认 yes
sub-ass-force-margins = no # [当 --blend-subtitles=yes/video 时无效] 是否使ASS字幕尽可能输出在黑边上,默认 no
sub-ass-force-style =
sub-ass-style-overrides =
# 使用自定义的参数以覆盖字幕文件内的预设。默认为空,例值(覆盖字幕内的所有字体) Fontname=LXGW WenKai

##⇘⇘模拟vsfilter相关
Expand Down Expand Up @@ -325,5 +325,5 @@
screenshot-template = "mpv-shot%n"
# 截图命名模板: https://mpv.io/manual/master/#options-screenshot-template
# 示例即默认值。可额外选填路径,例值 "~~desktop/MPV-%P-N%n"
screenshot-directory =
screenshot-dir =
# [若已在截图命名模板中设置路径,此时无需使用该选项 ] 默认为空,例值(保存截图在桌面) "~~desktop/"
3 changes: 2 additions & 1 deletion portable_config/script-opts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@

script-opts-append = uosc-menu_item_height=36 # 上下文菜单样式,示例即默认值
script-opts-append = uosc-menu_min_width=260
script-opts-append = uosc-menu_padding=4
script-opts-append = uosc-menu_type_to_search=yes # 是否启用菜单快速搜索(只需输入任何文本即可),否则使用按键 / 或 Ctrl+F 来激活搜索。
# 启用该项时,如果输入的是一个 Unicode 字符,就不能再使用相同的键位来关闭已打开的菜单

Expand Down Expand Up @@ -527,7 +528,7 @@
script-opts-append = uosc-text_border=1.2 # 控件元素的边框,默认 1.2


script-opts-append = uosc-border_radius=2 # 界面元素中圆角矩形的弧度,默认 2
script-opts-append = uosc-border_radius=4 # 界面元素中圆角矩形的弧度,默认 4

script-opts-append = uosc-color=
# 界面元素的颜色,多个值之间用半角逗号分隔。
Expand Down
5 changes: 3 additions & 2 deletions portable_config/script-opts/uosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ speed_persistency=idle,audio
# 上下文菜单样式,示例即默认值
menu_item_height=36
menu_min_width=260
menu_padding=4
# 是否启用菜单快速搜索(只需输入任何文本即可),否则使用按键 / 或 Ctrl+F 来激活搜索。启用该项时,如果输入的是一个 Unicode 字符,就不能再使用相同的键位来关闭已打开的菜单
menu_type_to_search=yes

Expand Down Expand Up @@ -85,8 +86,8 @@ font_scale=1
font_bold=no
# 控件元素的边框,默认 1.2
text_border=1.2
# 界面元素中圆角矩形的弧度,默认 2
border_radius=2
# 界面元素中圆角矩形的弧度,默认 4
border_radius=4
# 界面元素的颜色,多个值之间用半角逗号分隔。
# 示例的默认值:foreground=ffffff,foreground_text=000000,background=000000,background_text=ffffff,curtain=000000,success=a5e075,error=ff616e
color=
Expand Down
2 changes: 1 addition & 1 deletion portable_config/scripts/osc_plus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2473,7 +2473,7 @@ function osc_init()
local property = user_opts.remaining_playtime and "playtime-remaining"
or "time-remaining"
if state.tc_ms then
return return (minus..mp.get_property_osd(property .. "/full"))
return (minus..mp.get_property_osd(property .. "/full"))
else
return (minus..mp.get_property_osd(property))
end
Expand Down
57 changes: 31 additions & 26 deletions portable_config/scripts/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ function Menu:init(data, callback, opts)
self.drag_last_y = nil
self.is_dragging = false

if utils.shared_script_property_set then
utils.shared_script_property_set('uosc-menu-type', self.type or 'undefined')
end
mp.set_property_native('user-data/uosc/menu/type', self.type or 'undefined')
self:update(data)

Expand All @@ -142,9 +139,6 @@ function Menu:destroy()
self:disable_key_bindings()
self.is_closed = true
if not self.is_being_replaced then Elements:maybe('curtain', 'unregister', self.id) end
if utils.shared_script_property_set then
utils.shared_script_property_set('uosc-menu-type', nil)
end
mp.set_property_native('user-data/uosc/menu/type', nil)
if self.opts.on_close then self.opts.on_close() end
end
Expand Down Expand Up @@ -276,7 +270,7 @@ function Menu:update_content_dimensions()
self.item_height = round(options.menu_item_height * state.scale)
self.min_width = round(options.menu_min_width * state.scale)
self.separator_size = round(1 * state.scale)
self.padding = round(2 * state.scale)
self.padding = round(options.menu_padding * state.scale)
self.gap = round(2 * state.scale)
self.font_size = round(self.item_height * 0.48 * options.font_scale)
self.font_size_hint = self.font_size - 1
Expand All @@ -288,7 +282,7 @@ function Menu:update_content_dimensions()

for _, menu in ipairs(self.all) do
title_opts.bold, title_opts.italic = true, false
local max_width = text_width(menu.title, title_opts) + 2 * self.item_padding
local max_width = text_width(menu.title, title_opts) + 2 * self.padding + 2 * self.item_padding

-- Estimate width of a widest item
for _, item in ipairs(menu.items) do
Expand All @@ -302,7 +296,7 @@ function Menu:update_content_dimensions()
if estimated_width > max_width then max_width = estimated_width end
end

menu.max_width = max_width
menu.max_width = max_width + 2 * self.padding
end

self:update_dimensions()
Expand All @@ -320,7 +314,7 @@ function Menu:update_dimensions()
for _, menu in ipairs(self.all) do
local width = math.max(menu.search and menu.search.max_width or 0, menu.max_width)
menu.width = round(clamp(min_width, width, width_available))
local title_height = (menu.is_root and menu.title or menu.search) and self.scroll_step or 0
local title_height = (menu.is_root and menu.title or menu.search) and self.scroll_step + self.padding or 0
local max_height = height_available - title_height
local content_height = self.scroll_step * #menu.items
menu.height = math.min(content_height - self.item_spacing, max_height)
Expand Down Expand Up @@ -818,7 +812,7 @@ function Menu:search_backspace(event, word_mode)
local word_pat, other_pat = '[^%c%s%p]+$', '[%c%s%p]+$'
local init_pat = old_query:sub(#old_query):match(word_pat) and word_pat or other_pat
-- First we match all same type consecutive chars at the end
local tail = old_query:match(init_pat)
local tail = old_query:match(init_pat) or ''
-- If there's only one, we extend the tail with opposite type chars
if tail and #tail == 1 then
tail = tail .. old_query:sub(1, #old_query - #tail):match(init_pat == word_pat and other_pat or word_pat)
Expand Down Expand Up @@ -1101,15 +1095,17 @@ function Menu:render()
local end_index = math.ceil((menu.scroll_y + menu.height) / self.scroll_step)
local menu_rect = {
ax = ax,
ay = ay - (draw_title and self.scroll_step or 0) - self.padding,
ay = ay - (draw_title and self.scroll_step + self.padding or 0) - self.padding,
bx = bx,
by = by + self.padding,
}
local blur_selected_index = is_current and self.mouse_nav

-- Background
ass:rect(menu_rect.ax, menu_rect.ay, menu_rect.bx, menu_rect.by, {
color = bg, opacity = menu_opacity * config.opacity.menu, radius = state.radius + self.padding,
color = bg,
opacity = menu_opacity * config.opacity.menu,
radius = state.radius > 0 and state.radius + self.padding or 0,
})

if is_parent then
Expand All @@ -1135,8 +1131,8 @@ function Menu:render()
local item_by = item_ay + self.item_height
local item_center_y = item_ay + (self.item_height / 2)
local item_clip = (item_ay < ay or item_by > by) and scroll_clip or nil
local content_ax, content_bx = ax + spacing, bx - spacing
local is_selected = menu.selected_index == index or item.active
local content_ax, content_bx = ax + self.padding + spacing, bx - self.padding - spacing
local is_selected = menu.selected_index == index

-- Select hovered item
if is_current and self.mouse_nav and item.selectable ~= false then
Expand All @@ -1152,28 +1148,32 @@ function Menu:render()
if submenu_is_hovered or get_point_to_rectangle_proximity(cursor, item_rect_hitbox) == 0 then
blur_selected_index = false
menu.selected_index = index
if not is_selected then request_render() end
end
end
end

local has_background = is_selected or item.active
local next_item = menu.items[index + 1]
local next_is_active = next_item and next_item.active
local next_is_highlighted = menu.selected_index == index + 1 or next_is_active
local next_has_background = menu.selected_index == index + 1 or next_is_active
local font_color = item.active and fgt or bgt

-- Separator
local separator_ay = item.separator and item_by - 1 or item_by
local separator_by = item_by + (item.separator and 2 or 1)
if is_selected then separator_ay = item_by + 1 end
if next_is_highlighted then separator_by = item_by end
if separator_by - separator_ay > 0 and item_by < by then
ass:rect(ax + spacing / 2, separator_ay, bx - spacing / 2, separator_by, {
color = fg, opacity = menu_opacity * (item.separator and 0.08 or 0.06),
if item_by < by and ((not has_background and not next_has_background) or item.separator) then
local separator_ay, separator_by = item_by, item_by + 1
if has_background then
separator_ay, separator_by = separator_ay + 1, separator_by + 1
elseif next_has_background then
separator_ay, separator_by = separator_ay - 1, separator_by - 1
end
ass:rect(ax + spacing, separator_ay, bx - spacing, separator_by, {
color = fg, opacity = menu_opacity * (item.separator and 0.13 or 0.04),
})
end

-- Highlight
local highlight_opacity = 0 + (item.active and 0.8 or 0) + (menu.selected_index == index and 0.15 or 0)
-- Background
local highlight_opacity = 0 + (item.active and 0.8 or 0) + (is_selected and 0.15 or 0)
if not is_submenu and highlight_opacity > 0 then
ass:rect(ax + self.padding, item_ay, bx - self.padding, item_by, {
radius = state.radius,
Expand Down Expand Up @@ -1243,7 +1243,12 @@ function Menu:render()
-- Menu title
if draw_title then
local requires_submit = menu.search_debounce == 'submit'
local rect = {ax = ax + spacing, ay = ay - self.scroll_step, bx = bx - spacing, by = math.min(by, ay - 2)}
local rect = {
ax = ax + spacing / 2 + self.padding,
ay = ay - self.scroll_step - self.padding * 2,
bx = bx - spacing / 2 - self.padding,
by = math.min(by, ay - self.padding),
}
rect.cx, rect.cy = rect.ax + (rect.bx - rect.ax) / 2, rect.ay + (rect.by - rect.ay) / 2 -- centers

if menu.title and not menu.ass_safe_title then
Expand Down
12 changes: 8 additions & 4 deletions portable_config/scripts/uosc/elements/Timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ function Timeline:on_prop_fullormaxed()
self:update_dimensions()
end
function Timeline:on_display() self:update_dimensions() end
function Timeline:on_options() self:update_dimensions() end
function Timeline:on_options()
self:decide_progress_size()
self:update_dimensions()
end
function Timeline:handle_cursor_up()
if self.pressed then
mp.set_property_native('pause', self.pressed.pause)
Expand Down Expand Up @@ -350,19 +353,20 @@ function Timeline:render()

-- Time values
if text_opacity > 0 then
local time_opts = {size = self.font_size, opacity = text_opacity, border = 2}
local time_opts = {size = self.font_size, opacity = text_opacity, border = 2 * state.scale}
-- Upcoming cache time
if buffered_playtime and options.buffered_time_threshold > 0
and buffered_playtime < options.buffered_time_threshold then
local x, align = fbx + 5, 4
local margin = 5 * state.scale
local x, align = fbx + margin, 4
local cache_opts = {
size = self.font_size * 0.8, opacity = text_opacity * 0.6, border = options.text_border * state.scale,
}
local human = round(math.max(buffered_playtime, 0)) .. 's'
local width = text_width(human, cache_opts)
local time_width = timestamp_width(state.time_human, time_opts)
local time_width_end = timestamp_width(state.destination_time_human, time_opts)
local min_x, max_x = bax + spacing + 5 + time_width, bbx - spacing - 5 - time_width_end
local min_x, max_x = bax + spacing + margin + time_width, bbx - spacing - margin - time_width_end
if x < min_x then x = min_x elseif x + width > max_x then x, align = max_x, 6 end
draw_timeline_text(x, fcy, align, human, cache_opts)
end
Expand Down
2 changes: 1 addition & 1 deletion portable_config/scripts/uosc/elements/Volume.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function VolumeSlider:init(props)
end

function VolumeSlider:update_dimensions()
self.border_size = math.max(1, round(options.volume_border * state.scale))
self.border_size = math.max(0, round(options.volume_border * state.scale))
end

function VolumeSlider:get_visibility() return Elements.volume:get_visibility(self) end
Expand Down
9 changes: 7 additions & 2 deletions portable_config/scripts/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,14 @@ function open_open_file_menu()
)
end

---@param opts {name: string; prop: string; allowed_types: string[]}
---@param opts {name: 'subtitles'|'audio'|'video'; prop: string; allowed_types: string[]}
function create_track_loader_menu_opener(opts)
local menu_type = 'load-' .. opts.name
local title = ({
subtitles = lang._import_id_menu .. lang._sid_menu,
audio = lang._import_id_menu .. lang._aid_menu,
video = lang._import_id_menu .. lang._vid_menu,
})[opts.name]

return function()
if Menu:is_open(menu_type) then
Expand All @@ -537,7 +542,7 @@ function create_track_loader_menu_opener(opts)
open_file_navigation_menu(
path,
function(path) mp.commandv(opts.prop .. '-add', path) end,
{type = menu_type, title = lang._import_id_menu .. opts.name, allowed_types = opts.allowed_types}
{type = menu_type, title = title, allowed_types = opts.allowed_types}
)
end
end
11 changes: 4 additions & 7 deletions portable_config/scripts/uosc/main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--[[
SOURCE_ https://github.com/tomasklaen/uosc/tree/main/scripts/uosc
COMMIT_ 6e19bee95591e3c7653ba1d887d09e7708544eac
SOURCE_ https://github.com/tomasklaen/uosc/tree/main/dist/scripts/uosc
COMMIT_ bf7f97029544f01c7a2c5447e41c357402a5e1fe
文档_ https://github.com/hooke007/MPV_lazy/discussions/186
极简主义设计驱动的多功能界面脚本群组,兼容 thumbfast 新缩略图引擎
Expand Down Expand Up @@ -52,6 +52,7 @@ defaults = {

menu_item_height = 36,
menu_min_width = 260,
menu_padding = 4,
menu_type_to_search = true,

top_bar = 'no-border',
Expand All @@ -74,7 +75,7 @@ defaults = {
font_scale = 1,
font_bold = false,
text_border = 1.2,
border_radius = 2,
border_radius = 4,
color = '',
opacity = '',
animation_duration = 100,
Expand Down Expand Up @@ -495,9 +496,6 @@ function update_margins()
state.margin_left = left
state.margin_right = right

if utils.shared_script_property_set then
utils.shared_script_property_set('osc-margins', string.format('%f,%f,%f,%f', 0, 0, top, bottom))
end
mp.set_property_native('user-data/osc/margins', {l = left, r = right, t = top, b = bottom})

if not options.adjust_osd_margins then return end
Expand Down Expand Up @@ -1124,7 +1122,6 @@ if options.idlescreen then
mp.register_script_message('osc-idlescreen', function(mode, no_osd)
if mode == 'cycle' then mode = state.idlescreen and 'no' or 'yes' end
set_state('idlescreen', mode == 'yes')
utils.shared_script_property_set('osc-idlescreen', mode)
mp.set_property_native('user-data/osc', { idlescreen = state.idlescreen })

if not no_osd and mp.get_property_number('osd-level', 1) >= 1 then
Expand Down
Loading

0 comments on commit c4bef42

Please sign in to comment.