style: let language server handle code formatting
This is not complete, as I currently can't get the formatter to recognize `.editorconfig` file. Or at least it seems to ignore most of the options in it, so a lot of formatting doesn't adhere to the config. Will need another pass when that gets fixed.
This commit is contained in:
78
.editorconfig
Normal file
78
.editorconfig
Normal file
@@ -0,0 +1,78 @@
|
||||
[*.lua]
|
||||
# see https://github.com/CppCXY/EmmyLuaCodeStyle
|
||||
|
||||
# [basic]
|
||||
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
# none/single/double
|
||||
quote_style = single
|
||||
continuation_indent_size = 4
|
||||
max_line_length = 120
|
||||
# crlf/lf/cr/auto
|
||||
end_of_line = lf
|
||||
detect_end_of_line = false
|
||||
insert_final_newline = true
|
||||
|
||||
# [function]
|
||||
|
||||
# true/false/only_after_more_indention_statement/only_not_exist_cross_row_expression
|
||||
align_call_args = false
|
||||
align_function_define_params = true
|
||||
remove_expression_list_finish_comma = true
|
||||
# keep/remove/remove_table_only/remove_string_only/unambiguous_remove_string_only
|
||||
call_arg_parentheses = keep
|
||||
|
||||
# [table]
|
||||
|
||||
# none/comma/semicolon
|
||||
table_separator_style = comma
|
||||
# keep/never/always/smart
|
||||
trailing_table_separator = smart
|
||||
# align equal signs in tables
|
||||
continuous_assign_table_field_align_to_equal_sign = false
|
||||
# if true "local t = { 1, 2, 3 }"
|
||||
keep_one_space_between_table_and_bracket = false
|
||||
|
||||
# [statement]
|
||||
|
||||
align_chained_expression_statement = false
|
||||
max_continuous_line_distance = 1
|
||||
# align equal signs in value assignments
|
||||
continuous_assign_statement_align_to_equal_sign = false
|
||||
if_condition_align_with_each_other = false
|
||||
local_assign_continuation_align_to_first_expression = false
|
||||
statement_inline_comment_space = 1
|
||||
|
||||
# [indentation]
|
||||
|
||||
# labels (e.g.::continue::) will not be intended
|
||||
label_no_indent = false
|
||||
# no indentation for do statement
|
||||
do_statement_no_indent = false
|
||||
# no indentation for conditions of an if statement when on new line
|
||||
if_condition_no_continuation_indent = false
|
||||
if_branch_comments_after_block_no_indent = false
|
||||
|
||||
# [space]
|
||||
|
||||
# if true, t[#t+1] will not space wrapper '+'
|
||||
table_append_expression_no_space = false
|
||||
long_chain_expression_allow_one_space_after_colon = false
|
||||
remove_empty_header_and_footer_lines_in_function = true
|
||||
space_before_function_open_parenthesis = false
|
||||
space_before_open_square_bracket = false
|
||||
# format like this "local t <const> = 1"
|
||||
keep_one_space_between_namedef_and_attribute = false
|
||||
|
||||
# [row_layout]
|
||||
# Each can be: minLine:${n}, keepLine, keepLine:${n}, maxLine:${n}
|
||||
|
||||
keep_line_after_if_statement = keepLine
|
||||
keep_line_after_do_statement = keepLine
|
||||
keep_line_after_while_statement = keepLine
|
||||
keep_line_after_repeat_statement = keepLine
|
||||
keep_line_after_for_statement = keepLine
|
||||
keep_line_after_local_or_assign_statement = keepLine
|
||||
keep_line_after_function_define_statement = keepLine
|
||||
keep_line_after_expression_statement = keepLine
|
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,8 +1,4 @@
|
||||
{
|
||||
"Lua.diagnostics.disable": [
|
||||
"lowercase-global"
|
||||
],
|
||||
"Lua.diagnostics.globals": [
|
||||
"mp"
|
||||
]
|
||||
"Lua.diagnostics.disable": ["lowercase-global"],
|
||||
"Lua.diagnostics.globals": ["mp"]
|
||||
}
|
||||
|
196
uosc.lua
196
uosc.lua
@@ -294,10 +294,12 @@ function tween(from, to, setter, speed, callback)
|
||||
callback = speed
|
||||
speed = 0.3
|
||||
end
|
||||
|
||||
local timeout
|
||||
local getTo = type(to) == 'function' and to or function() return to end
|
||||
local cutoff = math.abs(getTo() - from) * 0.01
|
||||
function tick()
|
||||
|
||||
local function tick()
|
||||
from = from + ((getTo() - from) * speed)
|
||||
local is_end = math.abs(getTo() - from) <= cutoff
|
||||
setter(is_end and getTo() or from)
|
||||
@@ -308,8 +310,10 @@ function tween(from, to, setter, speed, callback)
|
||||
timeout:resume()
|
||||
end
|
||||
end
|
||||
|
||||
timeout = mp.add_timeout(0.016, tick)
|
||||
tick()
|
||||
|
||||
return function()
|
||||
timeout:kill()
|
||||
call_me_maybe(callback)
|
||||
@@ -359,7 +363,7 @@ function get_point_to_rectangle_proximity(point, rect)
|
||||
end
|
||||
|
||||
function text_width_estimate(text, font_size)
|
||||
if not text or text == "" then return 0 end
|
||||
if not text or text == '' then return 0 end
|
||||
local text_width = 0
|
||||
for _, _, width in utf8_iter(text) do
|
||||
text_width = text_width + width
|
||||
@@ -549,7 +553,9 @@ function serialize_path(path)
|
||||
local working_path = normal_path:sub(#normal_path) == '\\' and normal_path:sub(1, #normal_path - 1) or normal_path
|
||||
local parts = split(working_path, '[\\/]+')
|
||||
local basename = parts and parts[#parts] or working_path
|
||||
local dirname = #parts > 1 and table.concat(itable_slice(parts, 1, #parts - 1), state.os == 'windows' and '\\' or '/') or nil
|
||||
local dirname = #parts > 1
|
||||
and table.concat(itable_slice(parts, 1, #parts - 1), state.os == 'windows' and '\\' or '/')
|
||||
or nil
|
||||
local dot_split = split(basename, '%.')
|
||||
|
||||
return {
|
||||
@@ -593,10 +599,14 @@ function get_adjacent_file(file_path, direction, allowed_types)
|
||||
if current_file.basename == file then
|
||||
if direction == 'forward' then
|
||||
if files[index + 1] then return utils.join_path(current_file.dirname, files[index + 1]) end
|
||||
if options.directory_navigation_loops and files[1] then return utils.join_path(current_file.dirname, files[1]) end
|
||||
if options.directory_navigation_loops and files[1] then
|
||||
return utils.join_path(current_file.dirname, files[1])
|
||||
end
|
||||
else
|
||||
if files[index - 1] then return utils.join_path(current_file.dirname, files[index - 1]) end
|
||||
if options.directory_navigation_loops and files[#files] then return utils.join_path(current_file.dirname, files[#files]) end
|
||||
if options.directory_navigation_loops and files[#files] then
|
||||
return utils.join_path(current_file.dirname, files[#files])
|
||||
end
|
||||
end
|
||||
|
||||
-- This is the only file in directory
|
||||
@@ -609,7 +619,13 @@ end
|
||||
-- Returns `result, error`, result is table of `status:number(<0=error), stdout, stderr, error_string, killed_by_us:boolean`
|
||||
function delete_file(file_path)
|
||||
local args = state.os == 'windows' and {'cmd', '/C', 'del', file_path} or {'rm', file_path}
|
||||
return mp.command_native({name = 'subprocess', args = args, playback_only = false, capture_stdout = true, capture_stderr = true})
|
||||
return mp.command_native({
|
||||
name = 'subprocess',
|
||||
args = args,
|
||||
playback_only = false,
|
||||
capture_stdout = true,
|
||||
capture_stderr = true
|
||||
})
|
||||
end
|
||||
|
||||
-- Ensures chapters are in chronological order
|
||||
@@ -638,11 +654,11 @@ Signature:
|
||||
{
|
||||
-- element rectangle coordinates
|
||||
ax = 0, ay = 0, bx = 0, by = 0,
|
||||
-- cursor<>element relative proximity as a 0-1 floating number
|
||||
-- cursor<->element relative proximity as a 0-1 floating number
|
||||
-- where 0 = completely away, and 1 = touching/hovering
|
||||
-- so it's easy to work with and throw into equations
|
||||
proximity = 0,
|
||||
-- raw cursor<>element proximity in pixels
|
||||
-- raw cursor<->element proximity in pixels
|
||||
proximity_raw = infinity,
|
||||
-- called when element is created
|
||||
?init = function(this),
|
||||
@@ -681,6 +697,7 @@ function Element.new(props)
|
||||
end
|
||||
|
||||
function Element:init() end
|
||||
|
||||
function Element:destroy() end
|
||||
|
||||
-- Call method if it exists
|
||||
@@ -690,8 +707,11 @@ end
|
||||
|
||||
-- Tween helpers
|
||||
function Element:tween(...) tween_element(self, ...) end
|
||||
|
||||
function Element:tween_property(...) tween_element_property(self, ...) end
|
||||
|
||||
function Element:tween_stop() tween_element_stop(self) end
|
||||
|
||||
function Element:is_tweening() tween_element_is_tweening(self) end
|
||||
|
||||
-- Event listeners
|
||||
@@ -704,11 +724,13 @@ function Element:on(name, handler)
|
||||
self._eventListeners[name][#self._eventListeners[name] + 1] = handler
|
||||
end
|
||||
end
|
||||
|
||||
function Element:off(name, handler)
|
||||
if self._eventListeners[name] == nil then return end
|
||||
local index = itable_find(self._eventListeners, handler)
|
||||
if index then table.remove(self._eventListeners, index) end
|
||||
end
|
||||
|
||||
function Element:trigger(name, ...)
|
||||
self:maybe('on_' .. name, ...)
|
||||
if self._eventListeners[name] == nil then return end
|
||||
@@ -762,6 +784,7 @@ function Elements:trigger(name, ...)
|
||||
end
|
||||
|
||||
function Elements:has(name) return self[name] ~= nil end
|
||||
|
||||
function Elements:ipairs() return ipairs(self.itable) end
|
||||
|
||||
-- MENU
|
||||
@@ -895,7 +918,7 @@ function Menu:open(items, open_item, opts)
|
||||
end
|
||||
|
||||
-- Also check menu title
|
||||
local menu_title = this.title and this.title or ""
|
||||
local menu_title = this.title and this.title or ''
|
||||
local estimated_menu_title_width = text_width_estimate(menu_title, this.font_size)
|
||||
if estimated_menu_title_width > estimated_max_width then
|
||||
estimated_max_width = estimated_menu_title_width
|
||||
@@ -1206,7 +1229,7 @@ function Menu:close(immediate, callback)
|
||||
if type(immediate) ~= 'boolean' then callback = immediate end
|
||||
|
||||
if elements:has('menu') and not menu.is_closing then
|
||||
function close()
|
||||
local function close()
|
||||
elements.menu:maybe('on_close')
|
||||
elements.menu:destroy()
|
||||
elements:remove('menu')
|
||||
@@ -1280,8 +1303,8 @@ end
|
||||
function icons._volume(muted, pos_x, pos_y, size)
|
||||
local ass = assdraw.ass_new()
|
||||
local scale = size / 200
|
||||
function x(number) return pos_x + (number * scale) end
|
||||
function y(number) return pos_y + (number * scale) end
|
||||
local function x(number) return pos_x + (number * scale) end
|
||||
local function y(number) return pos_y + (number * scale) end
|
||||
ass:move_to(x(-85), y(-35))
|
||||
ass:line_to(x(-50), y(-35))
|
||||
ass:line_to(x(-5), y(-75))
|
||||
@@ -1289,27 +1312,41 @@ function icons._volume(muted, pos_x, pos_y, size)
|
||||
ass:line_to(x(-50), y(35))
|
||||
ass:line_to(x(-85), y(35))
|
||||
if muted then
|
||||
ass:move_to(x(76), y(-35)) ass:line_to(x(50), y(-9)) ass:line_to(x(24), y(-35))
|
||||
ass:line_to(x(15), y(-26)) ass:line_to(x(41), y(0)) ass:line_to(x(15), y(26))
|
||||
ass:line_to(x(24), y(35)) ass:line_to(x(50), y(9)) ass:line_to(x(76), y(35))
|
||||
ass:line_to(x(85), y(26)) ass:line_to(x(59), y(0)) ass:line_to(x(85), y(-26))
|
||||
ass:move_to(x(76), y(-35))
|
||||
ass:line_to(x(50), y(-9))
|
||||
ass:line_to(x(24), y(-35))
|
||||
ass:line_to(x(15), y(-26))
|
||||
ass:line_to(x(41), y(0))
|
||||
ass:line_to(x(15), y(26))
|
||||
ass:line_to(x(24), y(35))
|
||||
ass:line_to(x(50), y(9))
|
||||
ass:line_to(x(76), y(35))
|
||||
ass:line_to(x(85), y(26))
|
||||
ass:line_to(x(59), y(0))
|
||||
ass:line_to(x(85), y(-26))
|
||||
else
|
||||
ass:move_to(x(20), y(-30)) ass:line_to(x(20), y(30))
|
||||
ass:line_to(x(35), y(30)) ass:line_to(x(35), y(-30))
|
||||
ass:move_to(x(20), y(-30))
|
||||
ass:line_to(x(20), y(30))
|
||||
ass:line_to(x(35), y(30))
|
||||
ass:line_to(x(35), y(-30))
|
||||
|
||||
ass:move_to(x(55), y(-60)) ass:line_to(x(55), y(60))
|
||||
ass:line_to(x(70), y(60)) ass:line_to(x(70), y(-60))
|
||||
ass:move_to(x(55), y(-60))
|
||||
ass:line_to(x(55), y(60))
|
||||
ass:line_to(x(70), y(60))
|
||||
ass:line_to(x(70), y(-60))
|
||||
end
|
||||
return ass.text
|
||||
end
|
||||
|
||||
function icons.volume(pos_x, pos_y, size) return icons._volume(false, pos_x, pos_y, size) end
|
||||
|
||||
function icons.volume_muted(pos_x, pos_y, size) return icons._volume(true, pos_x, pos_y, size) end
|
||||
|
||||
function icons.menu_button(pos_x, pos_y, size)
|
||||
local ass = assdraw.ass_new()
|
||||
local scale = size / 100
|
||||
function x(number) return pos_x + (number * scale) end
|
||||
function y(number) return pos_y + (number * scale) end
|
||||
local function x(number) return pos_x + (number * scale) end
|
||||
local function y(number) return pos_y + (number * scale) end
|
||||
local line_height = 14
|
||||
local line_spacing = 18
|
||||
for i = -1, 1 do
|
||||
@@ -1325,8 +1362,8 @@ end
|
||||
function icons.arrow_right(pos_x, pos_y, size)
|
||||
local ass = assdraw.ass_new()
|
||||
local scale = size / 200
|
||||
function x(number) return pos_x + (number * scale) end
|
||||
function y(number) return pos_y + (number * scale) end
|
||||
local function x(number) return pos_x + (number * scale) end
|
||||
local function y(number) return pos_y + (number * scale) end
|
||||
ass:move_to(x(-22), y(-80))
|
||||
ass:line_to(x(-45), y(-57))
|
||||
ass:line_to(x(12), y(0))
|
||||
@@ -1339,7 +1376,7 @@ end
|
||||
-- STATE UPDATES
|
||||
|
||||
function update_display_dimensions()
|
||||
local dpi_scale = mp.get_property_native("display-hidpi-scale", 1.0)
|
||||
local dpi_scale = mp.get_property_native('display-hidpi-scale', 1.0)
|
||||
dpi_scale = dpi_scale * options.ui_scale
|
||||
|
||||
local width, height, aspect = mp.get_osd_size()
|
||||
@@ -1362,7 +1399,8 @@ function update_element_cursor_proximity(element)
|
||||
else
|
||||
local range = options.proximity_out - options.proximity_in
|
||||
element.proximity_raw = get_point_to_rectangle_proximity(cursor, element)
|
||||
element.proximity = menu:is_open() and 0 or 1 - (math.min(math.max(element.proximity_raw - options.proximity_in, 0), range) / range)
|
||||
element.proximity = menu:is_open() and 0 or
|
||||
1 - (math.min(math.max(element.proximity_raw - options.proximity_in, 0), range) / range)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1682,13 +1720,16 @@ function render_timeline(this)
|
||||
local elapsed_x = bax + spacing
|
||||
local elapsed_y = fay + (size / 2)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H'..options.color_foreground_text..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'\\clip('..foreground_coordinates..')')
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H' .. options.color_foreground_text .. '\\fn' .. config.font ..
|
||||
'\\fs' .. this.font_size .. bold_tag .. '\\clip(' .. foreground_coordinates .. ')')
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1), text_opacity))
|
||||
ass:pos(elapsed_x, elapsed_y)
|
||||
ass:an(4)
|
||||
ass:append(state.time_human)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H'..options.color_background_text..'\\4c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'\\iclip('..foreground_coordinates..')')
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H' .. options.color_background_text ..
|
||||
'\\4c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size ..
|
||||
bold_tag .. '\\iclip(' .. foreground_coordinates .. ')')
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1), text_opacity))
|
||||
ass:pos(elapsed_x, elapsed_y)
|
||||
ass:an(4)
|
||||
@@ -1700,13 +1741,16 @@ function render_timeline(this)
|
||||
local end_x = bbx - spacing
|
||||
local end_y = fay + (size / 2)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H'..options.color_foreground_text..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'\\clip('..foreground_coordinates..')')
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H' .. options.color_foreground_text .. '\\fn' .. config.font ..
|
||||
'\\fs' .. this.font_size .. bold_tag .. '\\clip(' .. foreground_coordinates .. ')')
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1), text_opacity))
|
||||
ass:pos(end_x, end_y)
|
||||
ass:an(6)
|
||||
ass:append(state.duration_or_remaining_time_human)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H'..options.color_background_text..'\\4c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'\\iclip('..foreground_coordinates..')')
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H' .. options.color_background_text ..
|
||||
'\\4c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size ..
|
||||
bold_tag .. '\\iclip(' .. foreground_coordinates .. ')')
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1), text_opacity))
|
||||
ass:pos(end_x, end_y)
|
||||
ass:an(6)
|
||||
@@ -1752,13 +1796,15 @@ function render_timeline(this)
|
||||
local margin_time = text_width_estimate(time_formatted, this.font_size) / 2
|
||||
local margin_title = chapter_title_width * this.font_size * options.font_height_to_letter_width_ratio / 2
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H'..options.color_background_text..'\\3c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..'\\b1')
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H' .. options.color_background_text ..
|
||||
'\\3c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size .. '\\b1')
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1)))
|
||||
ass:pos(math.min(math.max(cursor.x, margin_title), display.width - margin_title), fay - this.font_size * 1.5)
|
||||
ass:an(2)
|
||||
ass:append(chapter_title)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H'..options.color_background_text..'\\3c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag)
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H' .. options.color_background_text ..
|
||||
'\\3c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size .. bold_tag)
|
||||
ass:append(ass_opacity(math.min(options.timeline_opacity + 0.1, 1)))
|
||||
ass:pos(math.min(math.max(cursor.x, margin_time), display.width - margin_time), fay)
|
||||
ass:an(2)
|
||||
@@ -1766,7 +1812,8 @@ function render_timeline(this)
|
||||
|
||||
-- Cursor line
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\xshad-1\\yshad0\\1c&H'..options.color_foreground..'\\4c&H'..options.color_background..'}')
|
||||
ass:append('{\\blur0\\bord0\\xshad-1\\yshad0\\1c&H' .. options.color_foreground ..
|
||||
'\\4c&H' .. options.color_background .. '}')
|
||||
ass:append(ass_opacity(0.2))
|
||||
ass:pos(0, 0)
|
||||
ass:draw_start()
|
||||
@@ -1863,7 +1910,8 @@ function render_top_bar(this)
|
||||
local clip_coordinates = this.ax .. ',' .. this.ay .. ',' .. (this.title_bx - this.spacing) .. ',' .. this.by
|
||||
|
||||
ass:new_event()
|
||||
ass:append('{\\q2\\blur0\\bord1\\shad0\\1c&HFFFFFF\\3c&H000000\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'\\clip('..clip_coordinates..')')
|
||||
ass:append('{\\q2\\blur0\\bord1\\shad0\\1c&HFFFFFF\\3c&H000000\\fn' ..
|
||||
config.font .. '\\fs' .. this.font_size .. bold_tag .. '\\clip(' .. clip_coordinates .. ')')
|
||||
ass:append(ass_opacity(1, opacity))
|
||||
ass:pos(this.ax + this.spacing, this.ay + (this.size / 2))
|
||||
ass:an(4)
|
||||
@@ -1894,7 +1942,8 @@ function render_volume(this)
|
||||
-- Foreground bar coordinates
|
||||
local height_without_border = slider.height - (options.volume_border * 2)
|
||||
local fax = slider.ax + options.volume_border
|
||||
local fay = slider.ay + (height_without_border * (1 - math.min(state.volume / state.volume_max, 1))) + options.volume_border
|
||||
local fay = slider.ay + (height_without_border * (1 - math.min(state.volume / state.volume_max, 1))) +
|
||||
options.volume_border
|
||||
local fbx = slider.bx - options.volume_border
|
||||
local fby = slider.by - options.volume_border
|
||||
|
||||
@@ -1936,7 +1985,8 @@ function render_volume(this)
|
||||
|
||||
-- Background
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\1c&H'..options.color_background..'\\iclip('..fpath.scale..', '..fpath.text..')}')
|
||||
ass:append('{\\blur0\\bord0\\1c&H' .. options.color_background ..
|
||||
'\\iclip(' .. fpath.scale .. ', ' .. fpath.text .. ')}')
|
||||
ass:append(ass_opacity(math.max(options.volume_opacity - 0.1, 0), opacity))
|
||||
ass:pos(0, 0)
|
||||
ass:draw_start()
|
||||
@@ -1972,7 +2022,8 @@ function render_volume(this)
|
||||
local font_size = round(((this.width * 0.6) - (#volume_string * (this.width / 20))) * options.volume_font_scale)
|
||||
if fay < slider.by - slider.spacing then
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H'..options.color_foreground_text..'\\fn'..config.font..'\\fs'..font_size..bold_tag..'\\clip('..fpath.scale..', '..fpath.text..')}')
|
||||
ass:append('{\\blur0\\bord0\\shad0\\1c&H' .. options.color_foreground_text .. '\\fn' .. config.font ..
|
||||
'\\fs' .. font_size .. bold_tag .. '\\clip(' .. fpath.scale .. ', ' .. fpath.text .. ')}')
|
||||
ass:append(ass_opacity(math.min(options.volume_opacity + 0.1, 1), opacity))
|
||||
ass:pos(slider.ax + (slider.width / 2), slider.by - slider.spacing)
|
||||
ass:an(2)
|
||||
@@ -1980,7 +2031,9 @@ function render_volume(this)
|
||||
end
|
||||
if fay > slider.by - slider.spacing - font_size then
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H'..options.color_background_text..'\\4c&H'..options.color_background..'\\fn'..config.font..'\\fs'..font_size..bold_tag..'\\iclip('..fpath.scale..', '..fpath.text..')}')
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H' .. options.color_background_text ..
|
||||
'\\4c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. font_size .. bold_tag ..
|
||||
'\\iclip(' .. fpath.scale .. ', ' .. fpath.text .. ')}')
|
||||
ass:append(ass_opacity(math.min(options.volume_opacity + 0.1, 1), opacity))
|
||||
ass:pos(slider.ax + (slider.width / 2), slider.by - slider.spacing)
|
||||
ass:an(2)
|
||||
@@ -2076,7 +2129,8 @@ function render_speed(this)
|
||||
-- Speed value
|
||||
local speed_text = (round(state.speed * 100) / 100) .. 'x'
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H'..options.color_background_text..'\\3c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..'}')
|
||||
ass:append('{\\blur0\\bord1\\shad0\\1c&H' .. options.color_background_text ..
|
||||
'\\3c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size .. bold_tag .. '}')
|
||||
ass:append(ass_opacity(options.speed_opacity, opacity))
|
||||
ass:pos(half_x, ay)
|
||||
ass:an(8)
|
||||
@@ -2125,7 +2179,9 @@ function render_menu(this)
|
||||
|
||||
-- Title
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad1\\b1\\1c&H'..options.color_background_text..'\\4c&H'..options.color_background..'\\fn'..config.font..'\\fs'..this.font_size..'\\q2\\clip('..this.ax..','..this.ay - this.item_height..','..this.bx..','..this.ay..')}')
|
||||
ass:append('{\\blur0\\bord0\\shad1\\b1\\1c&H' .. options.color_background_text ..
|
||||
'\\4c&H' .. options.color_background .. '\\fn' .. config.font .. '\\fs' .. this.font_size ..
|
||||
'\\q2\\clip(' .. this.ax .. ',' .. this.ay - this.item_height .. ',' .. this.bx .. ',' .. this.ay .. ')}')
|
||||
ass:append(ass_opacity(options.menu_opacity, this.opacity))
|
||||
ass:pos(display.width / 2, this.ay - (this.item_height * 0.5))
|
||||
ass:an(5)
|
||||
@@ -2187,11 +2243,14 @@ function render_menu(this)
|
||||
|
||||
-- Title
|
||||
if item.title then
|
||||
item.ass_save_title = item.ass_save_title or item.title:gsub("([{}])","\\%1")
|
||||
item.ass_save_title = item.ass_save_title or item.title:gsub('([{}])', '\\%1')
|
||||
local title_clip_x = (this.bx - hint_width - this.item_content_spacing)
|
||||
local title_clip = '\\clip('..this.ax..','..math.max(item_ay, this.ay)..','..title_clip_x..','..math.min(item_by, this.by)..')'
|
||||
local title_clip = '\\clip(' ..
|
||||
this.ax .. ',' .. math.max(item_ay, this.ay) .. ',' ..
|
||||
title_clip_x .. ',' .. math.min(item_by, this.by) .. ')'
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H'..font_color..'\\4c&H'..background_color..'\\fn'..config.font..'\\fs'..this.font_size..bold_tag..title_clip..'\\q2}')
|
||||
ass:append('{\\blur0\\bord0\\shad1\\1c&H' .. font_color .. '\\4c&H' .. background_color ..
|
||||
'\\fn' .. config.font .. '\\fs' .. this.font_size .. bold_tag .. title_clip .. '\\q2}')
|
||||
ass:append(ass_opacity(options.menu_opacity, this.opacity))
|
||||
ass:pos(this.ax + this.item_content_spacing, item_ay + (this.item_height / 2))
|
||||
ass:an(4)
|
||||
@@ -2200,9 +2259,10 @@ function render_menu(this)
|
||||
|
||||
-- Hint
|
||||
if item.hint then
|
||||
item.ass_save_hint = item.ass_save_hint or item.hint:gsub("([{}])","\\%1")
|
||||
item.ass_save_hint = item.ass_save_hint or item.hint:gsub('([{}])', '\\%1')
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0'..ass_shadow..'\\1c&H'..font_color..''..ass_shadow_color..'\\fn'..config.font..'\\fs'..this.font_size_hint..bold_tag..item_clip..'}')
|
||||
ass:append('{\\blur0\\bord0' .. ass_shadow .. '\\1c&H' .. font_color .. '' .. ass_shadow_color ..
|
||||
'\\fn' .. config.font .. '\\fs' .. this.font_size_hint .. bold_tag .. item_clip .. '}')
|
||||
ass:append(ass_opacity(options.menu_opacity * (has_submenu and 1 or 0.5), this.opacity))
|
||||
ass:pos(this.bx - this.item_content_spacing, item_ay + (this.item_height / 2))
|
||||
ass:an(6)
|
||||
@@ -2294,14 +2354,16 @@ elements:add('window_border', Element.new({
|
||||
this:update_size();
|
||||
end,
|
||||
update_size = function(this)
|
||||
this.size = options.window_border_size > 0 and not state.fullormaxed and not state.border and options.window_border_size or 0
|
||||
this.size = options.window_border_size > 0 and not state.fullormaxed and not state.border and
|
||||
options.window_border_size or 0
|
||||
end,
|
||||
on_prop_border = function(this) this:update_size() end,
|
||||
on_prop_fullormaxed = function(this) this:update_size() end,
|
||||
render = function(this)
|
||||
if this.size > 0 then
|
||||
local ass = assdraw.ass_new()
|
||||
local clip_coordinates = this.size..','..this.size..','..(display.width - this.size)..','..(display.height - this.size)
|
||||
local clip_coordinates = this.size ..
|
||||
',' .. this.size .. ',' .. (display.width - this.size) .. ',' .. (display.height - this.size)
|
||||
ass:new_event()
|
||||
ass:append('{\\blur0\\bord0\\1c&H' .. options.color_background .. '\\iclip(' .. clip_coordinates .. ')}')
|
||||
ass:append(ass_opacity(options.window_border_opacity))
|
||||
@@ -2651,7 +2713,8 @@ if itable_find({'center', 'bottom-bar'}, options.menu_button) then
|
||||
if options.menu_button == 'bottom-bar' then
|
||||
this.ax = 15
|
||||
this.bx = this.ax + this.width
|
||||
this.by = display.height - 10 - elements.window_border.size - elements.timeline.size_max - elements.timeline.top_border
|
||||
this.by = display.height - 10 - elements.window_border.size - elements.timeline.size_max -
|
||||
elements.timeline.top_border
|
||||
this.ay = this.by - this.height
|
||||
else
|
||||
this.ax = round((display.width - this.width) / 2)
|
||||
@@ -2689,6 +2752,7 @@ if options.speed then
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elements:add('speed', Element.new({
|
||||
dragging = nil,
|
||||
width = 0,
|
||||
@@ -2810,7 +2874,10 @@ elements:add('curtain', Element.new({
|
||||
|
||||
-- Parse `chapter_ranges` option into workable data structure
|
||||
for _, definition in ipairs(split(options.chapter_ranges, ' *,+ *')) do
|
||||
local start_patterns, color, opacity, end_patterns = string.match(definition, '([^<]+)<(%x%x%x%x%x%x):(%d?%.?%d*)>([^>]+)')
|
||||
local start_patterns, color, opacity, end_patterns = string.match(
|
||||
definition,
|
||||
'([^<]+)<(%x%x%x%x%x%x):(%d?%.?%d*)>([^>]+)'
|
||||
)
|
||||
|
||||
-- Valid definition
|
||||
if start_patterns then
|
||||
@@ -2841,13 +2908,13 @@ for _, definition in ipairs(split(options.chapter_ranges, ' *,+ *')) do
|
||||
-- eof is only used when last range is missing end
|
||||
local bof_used = false
|
||||
|
||||
function start_range(chapter)
|
||||
local function start_range(chapter)
|
||||
-- If there is already a range started, should we append or overwrite?
|
||||
-- I chose overwrite here.
|
||||
current_range = {['start'] = chapter}
|
||||
end
|
||||
|
||||
function end_range(chapter)
|
||||
local function end_range(chapter)
|
||||
current_range['end'] = chapter
|
||||
chapter_range.ranges[#chapter_range.ranges + 1] = current_range
|
||||
-- Mark both chapter objects
|
||||
@@ -3001,7 +3068,7 @@ function update_cursor_position()
|
||||
cursor.y = infinity
|
||||
end
|
||||
|
||||
local dpi_scale = mp.get_property_native("display-hidpi-scale", 1.0)
|
||||
local dpi_scale = mp.get_property_native('display-hidpi-scale', 1.0)
|
||||
dpi_scale = dpi_scale * options.ui_scale
|
||||
|
||||
cursor.x = cursor.x / dpi_scale
|
||||
@@ -3054,19 +3121,19 @@ function handle_mouse_move()
|
||||
end
|
||||
|
||||
function navigate_directory(direction)
|
||||
local path = mp.get_property_native("path")
|
||||
local path = mp.get_property_native('path')
|
||||
|
||||
if not path or is_protocol(path) then return end
|
||||
|
||||
local next_file = get_adjacent_file(path, direction, options.media_types)
|
||||
|
||||
if next_file then
|
||||
mp.commandv("loadfile", utils.join_path(serialize_path(path).dirname, next_file))
|
||||
mp.commandv('loadfile', utils.join_path(serialize_path(path).dirname, next_file))
|
||||
end
|
||||
end
|
||||
|
||||
function load_file_in_current_directory(index)
|
||||
local path = mp.get_property_native("path")
|
||||
local path = mp.get_property_native('path')
|
||||
|
||||
if not path or is_protocol(path) then return end
|
||||
|
||||
@@ -3077,7 +3144,7 @@ function load_file_in_current_directory(index)
|
||||
if index < 0 then index = #files + index + 1 end
|
||||
|
||||
if files[index] then
|
||||
mp.commandv("loadfile", utils.join_path(dirname, files[index]))
|
||||
mp.commandv('loadfile', utils.join_path(dirname, files[index]))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3335,7 +3402,7 @@ function open_drives_menu(handle_select, menu_options)
|
||||
|
||||
if process.status == 0 then
|
||||
for _, value in ipairs(split(process.stdout, '\n')) do
|
||||
local drive = string.match(value, "Name=([A-Z]:)")
|
||||
local drive = string.match(value, 'Name=([A-Z]:)')
|
||||
if drive then
|
||||
local drive_path = normalize_path(drive)
|
||||
items[#items + 1] = {title = drive, hint = 'Drive', value = drive_path}
|
||||
@@ -3358,7 +3425,8 @@ end
|
||||
-- VALUE SERIALIZATION/NORMALIZATION
|
||||
|
||||
options.proximity_out = math.max(options.proximity_out, options.proximity_in + 1)
|
||||
options.timeline_chapters = itable_find({'dots', 'lines', 'lines-top', 'lines-bottom'}, options.timeline_chapters) and options.timeline_chapters or 'never'
|
||||
options.timeline_chapters = itable_find({'dots', 'lines', 'lines-top', 'lines-bottom'}, options.timeline_chapters) and
|
||||
options.timeline_chapters or 'never'
|
||||
options.media_types = split(options.media_types, ' *, *')
|
||||
options.subtitle_types = split(options.subtitle_types, ' *, *')
|
||||
options.stream_quality_options = split(options.stream_quality_options, ' *, *')
|
||||
@@ -3490,7 +3558,7 @@ mp.enable_key_bindings('mouse_movement', 'allow-vo-dragging+allow-hide-cursor')
|
||||
-- Context based key bind groups
|
||||
|
||||
forced_key_bindings = (function()
|
||||
function create_mouse_event_dispatcher(name)
|
||||
local function create_mouse_event_dispatcher(name)
|
||||
return function(...)
|
||||
for _, element in pairs(elements) do
|
||||
if element.proximity_raw == 0 then
|
||||
@@ -3566,12 +3634,10 @@ end)
|
||||
mp.add_key_binding(nil, 'decide-pause-indicator', function()
|
||||
elements.pause_indicator:decide()
|
||||
end)
|
||||
function menu_key_binding()
|
||||
toggle_menu_with_items(state.context_menu_items)
|
||||
end
|
||||
function menu_key_binding() toggle_menu_with_items(state.context_menu_items) end
|
||||
mp.add_key_binding(nil, 'menu', menu_key_binding)
|
||||
mp.register_script_message('show-submenu', function(name)
|
||||
local path = split(name, " *>+ *")
|
||||
local path = split(name, ' *>+ *')
|
||||
local items = state.context_menu_items
|
||||
local last_menu_title = nil
|
||||
|
||||
@@ -3609,7 +3675,7 @@ mp.add_key_binding(nil, 'load-subtitles', function()
|
||||
end
|
||||
end
|
||||
if not path then
|
||||
path = os.getenv("HOME") --[[@as string]]
|
||||
path = os.getenv('HOME') --[[@as string]]
|
||||
end
|
||||
open_file_navigation_menu(
|
||||
path,
|
||||
@@ -3776,7 +3842,7 @@ mp.add_key_binding(nil, 'open-file', function()
|
||||
end
|
||||
|
||||
-- Update selected file in directory navigation menu
|
||||
function handle_file_loaded()
|
||||
local function handle_file_loaded()
|
||||
if menu:is_open('open-file') then
|
||||
local path = normalize_path(mp.get_property_native('path'))
|
||||
elements.menu:activate_value(path)
|
||||
|
Reference in New Issue
Block a user