Skip to content

Commit

Permalink
脚本: uosc 改进菜单中的截屏功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hooke007 committed Oct 21, 2022
1 parent 11bdc23 commit 19b0666
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion portable_config/input_uosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# script-binding uosc/subtitles #! 导航 > ※ 字幕轨列表
# playlist-shuffle #! 导航 > 播放列表乱序重排

# screenshot window #! 截屏 当前画面
# script-binding uosc/shot #! ※ 截屏

# cycle-values hwdec "auto" "auto-copy" "no" #! 视频 > 切换 解码模式
# cycle deband #! 视频 > 切换 去色带状态
Expand Down
28 changes: 27 additions & 1 deletion portable_config/scripts/uosc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ local function create_default_menu()
{title = '※ 字幕轨列表', value = 'script-binding uosc/subtitles'},
{title = '播放列表乱序重排', value = 'playlist-shuffle'},
},},
{title = '截屏 当前画面', value = 'screenshot window'},
{title = '※ 截屏', value = 'script-binding uosc/shot'},
{title = '视频', items = {
{title = '切换 解码模式', value = 'cycle-values hwdec no auto auto-copy'},
{title = '切换 去色带状态', value = 'cycle deband'},
Expand Down Expand Up @@ -4773,6 +4773,32 @@ mp.add_key_binding(nil, 'open-config-directory', function()
msg.error('Couldn\'t serialize config path "' .. config_path .. '".')
end
end)
-- 菜单专用截屏
mp.add_key_binding(nil, 'shot', function()
if Menu:is_open() then
local bak_opt1, bak_opt2, bak_opt3, bak_opt4 = options.curtain_opacity, options.menu_opacity, options.menu_parent_opacity, options.pause_indicator
options.curtain_opacity, options.menu_opacity, options.menu_parent_opacity = 0, 0, 0
-- 并非所有元素支持透明
local paused = mp.get_property_bool('pause')
if paused then
mp.add_timeout(200 / 1000, function() -- 延迟过低可能产生闪烁
mp.command('screenshot window')
options.curtain_opacity, options.menu_opacity, options.menu_parent_opacity = bak_opt1, bak_opt2, bak_opt3
end)
else
options.pause_indicator = 'manual'
mp.set_property_bool('pause', true)
mp.add_timeout(200 / 1000, function()
mp.command('screenshot window')
mp.set_property_bool('pause', false)
options.pause_indicator = bak_opt4
options.curtain_opacity, options.menu_opacity, options.menu_parent_opacity = bak_opt1, bak_opt2, bak_opt3
end)
end
else
mp.command('screenshot window')
end
end)

-- 空闲自动弹出上下文菜单
if type(options.idle_call_menu) == 'number' then
Expand Down

0 comments on commit 19b0666

Please sign in to comment.