Skip to content

Commit

Permalink
配置更新
Browse files Browse the repository at this point in the history
  • Loading branch information
dyphire committed Jan 7, 2024
1 parent d823abd commit f5be9ab
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 376 deletions.
2 changes: 1 addition & 1 deletion archive/script-opts/edition_list.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ indent=\h\h\h\h
##指定菜单每页的列表项数量
num_entries=16
##设置切断长列表名时的最大显示字符数,默认值:100
slice_longfilenames_amount=100
max_title_length=100
##是否循环滚动
wrap=yes
##打开菜单时重置光标导航
Expand Down
9 changes: 7 additions & 2 deletions archive/scripts/adevice-list.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
* adevice-list.lua v.2023-02-05
* adevice-list.lua v.2024-01-07
*
* AUTHORS: dyphire
* License: MIT
Expand Down Expand Up @@ -108,7 +108,7 @@ end
local function reset_cursor()
local adeviceList = mp.get_property_native('audio-device-list', {})
if current_name ~= nil and list.selected > 0 then
if string.match(adeviceList[list.selected].name, current_name) == nil then
if string.find(adeviceList[list.selected].name, current_name) == nil then
list.selected = 0
end
end
Expand Down Expand Up @@ -154,3 +154,8 @@ mp.observe_property('audio-device-list', 'string', function()
end)

mp.register_script_message("toggle-adevice-browser", function() list:toggle() end)

mp.register_event('end-file', function()
list:close()
mp.unobserve_property(adevice_list)
end)
10 changes: 7 additions & 3 deletions archive/scripts/edition-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ local o = {
--amount of entries to show before slicing. Optimal value depends on font/video size etc.
num_entries = 16,
--slice long filenames, and how many chars to show
slice_longfilenames_amount = 100,
max_title_length = 100,
-- wrap the cursor around the top and bottom of the list
wrap = true,
-- reset cursor navigation when open the list
Expand Down Expand Up @@ -146,8 +146,8 @@ function edition_list(curr_edition)
local item = {}
local title = edition_list[i].title
if not title then title = "Edition " .. string.format("%02.f", i) end
if title and title:len() > o.slice_longfilenames_amount + 5 then
title = title:sub(1, o.slice_longfilenames_amount) .. " ..."
if o.max_title_length > 0 and title:len() > o.max_title_length + 5 then
title = title:sub(1, o.max_title_length) .. " ..."
end
if (i - 1 == curr_edition) then
list.selected = curr_edition + 1
Expand Down Expand Up @@ -216,3 +216,7 @@ mp.observe_property('edition-list', 'native', function()
end)

mp.register_event('file-loaded', main)
mp.register_event('end-file', function()
list:close()
mp.unobserve_property(edition_list)
end)
57 changes: 1 addition & 56 deletions archive/scripts/open_dialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,65 +135,10 @@ local function append_sid()
end
end

local function append_vfSub()
local was_ontop = mp.get_property_native("ontop")
if was_ontop then mp.set_property_native("ontop", false) end
local res = utils.subprocess({
args = { 'powershell', '-NoProfile', '-Command', [[& {
Trap {
Write-Error -ErrorRecord $_
Exit 1
}
Add-Type -AssemblyName PresentationFramework
$u8 = [System.Text.Encoding]::UTF8
$out = [Console]::OpenStandardOutput()
$ofd = New-Object -TypeName Microsoft.Win32.OpenFileDialog
$ofd.Multiselect = $false
If ($ofd.ShowDialog() -eq $true) {
ForEach ($filename in $ofd.FileNames) {
$u8filename = $u8.GetBytes("$filename")
$out.Write($u8filename, 0, $u8filename.Length)
}
}
}]] },
cancellable = false,
})
if was_ontop then mp.set_property_native("ontop", true) end
if (res.status ~= 0) then return end
for filename in string.gmatch(res.stdout, '[^\n]+') do
local vfSub = "vf append ``@open_dialog-sub:subtitles=filename=\"" .. res.stdout .. "\"``"
mp.command(vfSub)
end
end

local function filter_state(label, key, value)
local filters = mp.get_property_native("vf")
for _, filter in pairs(filters) do
if filter["label"] == label and (not key or key and filter[key] == value) then return true end
end
return false
end

local function toggle_vfSub()
local vfSub = "vf toggle @open_dialog-sub"
if filter_state("open_dialog-sub") then mp.command(vfSub) end
end

local function remove_vfSub()
local vfSub = "vf remove @open_dialog-sub"
if filter_state("open_dialog-sub") then
mp.msg.info("Cleanup @open_dialog-sub.")
mp.command(vfSub)
mp.msg.info("Done.")
end
end

mp.register_event("end-file", remove_vfSub)

mp.register_script_message('import_files', import_files)
mp.register_script_message('import_url', import_url)
mp.register_script_message('append_aid', append_aid)
mp.register_script_message('append_sid', append_sid)
mp.register_script_message('append_vfSub', append_vfSub)
mp.register_script_message('toggle_vfSub', toggle_vfSub)
mp.register_script_message('remove_vfSub', remove_vfSub)

10 changes: 4 additions & 6 deletions input.conf
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,10 @@ CTRL+g cycle gamut-mapping-mode ;show-text 色域映射模式:${gamut-
# ignore #menu: ---

##⇘⇘menu 一级菜单:轨道
# ignore #menu: 轨道 > 视频 #@tracks/video
# ignore #menu: 轨道 > 音频 #@tracks/audio
# ignore #menu: 轨道 > 字幕 #@tracks/sub
# ignore #menu: 轨道 > 次字幕 #@tracks/sub-secondary
# ignore #menu: 轨道 > 章节列表 #@chapters
# ignore #menu: 轨道 > 版本列表 #@editions
# ignore #menu: 菜单 > 轨道 #@tracks
# ignore #menu: 菜单 > 次字幕 #@tracks/sub-secondary
# ignore #menu: 菜单 > 章节列表 #@chapters
# ignore #menu: 菜单 > 版本列表 #@editions
# ignore #menu: ---

##⇘⇘uosc 一级菜单:视频
Expand Down
2 changes: 1 addition & 1 deletion script-opts/chapter_list.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ indent=\h\h\h\h
##指定菜单每页的列表项数量
num_entries=16
##设置切断长列表名时的最大显示字符数,默认值:100
slice_longfilenames_amount=100
max_title_length=100
##是否循环滚动
wrap=yes
##打开菜单时重置光标导航
Expand Down
2 changes: 1 addition & 1 deletion script-opts/track_list.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ indent=\h\h\h\h
##指定菜单每页的列表项数量
num_entries=16
##设置切断长列表名时的最大显示字符数,默认值:100
slice_longfilenames_amount=100
max_title_length=100
##是否循环滚动
wrap=yes
##菜单打开时绑定的按键
Expand Down
11 changes: 8 additions & 3 deletions scripts/chapter-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local o = {
--amount of entries to show before slicing. Optimal value depends on font/video size etc.
num_entries = 16,
--slice long filenames, and how many chars to show
slice_longfilenames_amount = 100,
max_title_length = 100,
-- wrap the cursor around the top and bottom of the list
wrap = true,
-- reset cursor navigation when open the list
Expand Down Expand Up @@ -99,8 +99,8 @@ function chapter_list(curr_chapter)
if not title or title == '(unnamed)' or title == '' then
title = "Chapter " .. string.format("%02.f", i)
end
if title and title:len() > o.slice_longfilenames_amount + 5 then
title = title:sub(1, o.slice_longfilenames_amount) .. " ..."
if o.max_title_length > 0 and title:len() > o.max_title_length + 5 then
title = title:sub(1, o.max_title_length) .. " ..."
end
if time < 0 then time = 0
else time = math.floor(time) end
Expand Down Expand Up @@ -233,3 +233,8 @@ end)
if user_input_module then
mp.add_hook("on_unload", 50, function() input.cancel_user_input() end)
end

mp.register_event('end-file', function()
list:close()
mp.unobserve_property(chapter_list)
end)
Binary file modified scripts/menu.dll
Binary file not shown.
Loading

0 comments on commit f5be9ab

Please sign in to comment.