summaryrefslogtreecommitdiff
path: root/osd.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-21 14:34:52 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-21 14:34:52 -0800
commit302d1dd609837535f3cf4024ae8d8513223fbeae (patch)
tree00cf356cc78331e4dfe9bc200928f552eee9de08 /osd.lua
parent15198eb77727b4277d5b5d80fb3ae4b25b3c8ef8 (diff)
downloadmpv-iptv-menu-302d1dd609837535f3cf4024ae8d8513223fbeae.tar.gz
mpv-iptv-menu-302d1dd609837535f3cf4024ae8d8513223fbeae.tar.xz
move icons/symbols to config
Diffstat (limited to 'osd.lua')
-rw-r--r--osd.lua63
1 files changed, 32 insertions, 31 deletions
diff --git a/osd.lua b/osd.lua
index 981d824..93f9f3f 100644
--- a/osd.lua
+++ b/osd.lua
@@ -8,16 +8,17 @@ local osd = {}
local mt = {}
mt.__index = mt
-local colours = {}
-for k, v in pairs(config.colours) do
+local colour = {}
+for k, v in pairs(config.colour) do
-- constructed backwards as ASS colour tags expect BGR but we configure
-- them as RGB
tag = '&}'
for byte in v:gmatch('..') do
tag = byte:upper() .. tag
end
- colours[k] = '{\\c&H' .. tag
+ colour[k] = '{\\c&H' .. tag
end
+local icon = config.icon
local bgra_file = mp_utils.join_path(
config.tmp_dir,
@@ -86,7 +87,7 @@ function mt:resize(w, h)
self.height = h
self.scale = h > 0 and h/720 or 1
- local sz = self.padding + self:measure_width('»') - 2
+ local sz = self.padding + self:measure_width(icon.title) - 2
local coords = {
x1 = 2,
y1 = self.padding + ((config.font_size - sz) / 2),
@@ -97,10 +98,10 @@ function mt:resize(w, h)
self.menu_btn_coords = coords
self.menu_btn.data =
'{\\pos(' .. coords.x1 .. ',' .. coords.y1 .. ')}' ..
- colours.menu_btn_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
+ colour.menu_btn_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
'{\\q2\\fs' .. sz .. '\\bord0\\an5\\pos(' ..
coords.x1 + sz/2 .. ',' .. coords.y1 + sz/2 ..')}' ..
- colours.menu_btn_fg .. '≡'
+ colour.menu_btn_fg .. icon.menu_btn
self.menu_btn:update()
end
@@ -141,9 +142,9 @@ function mt:status_line()
return ''
end
- local col = self.status_level == 'error' and colours.status_error or
- colours.status_info
- return col .. '🞸 {\\i1}' .. asscape(self.status_msg)
+ local col = self.status_level == 'error' and colour.status_error or
+ colour.status_info
+ return col .. icon.status .. ' {\\i1}' .. asscape(self.status_msg)
end
function mt:menu_lines(state)
@@ -153,7 +154,7 @@ end
function mt:menu_title(menu)
local str = asscape(menu.title)
- local col = menu.search_active and colours.selected or colours.title
+ local col = menu.search_active and colour.selected or colour.title
if menu.type == 'search' then
str = str:gsub('<text>', asscape(menu.search_text))
@@ -167,53 +168,53 @@ function mt:menu_title(menu)
menu.search_cursor)))
end
- str = str:gsub('<colours.info>', colours.info)
+ str = str:gsub('<colour.info>', colour.info)
str = str:gsub('<num_matches>', #menu.options)
str = str:gsub('<num_total>', #menu.search_options)
end
if menu.sorted then
- str = colours.icon_sorted .. '⇅ ' .. col .. str
+ str = colour.icon_sorted .. icon.sorted .. ' ' .. col .. str
end
- return col .. '» ' .. str
+ return col .. icon.title .. ' ' .. str
end
function mt:option_icons(opt, info)
local str = ''
if info.selected then
- str = colours.selected .. '› '
+ str = colour.selected .. icon.cursor .. ' '
end
if info.playing then
- str = str .. colours.icon_playing .. '\226\143\186 '
+ str = str .. colour.icon_playing .. icon.playing .. ' '
end
if info.favourited then
- str = str .. colours.icon_favourite .. '★ '
+ str = str .. colour.icon_favourite .. icon.favourite .. ' '
end
if opt.active then
- str = str .. colours.icon_active .. '\226\143\186 '
+ str = str .. colour.icon_active .. icon.active .. ' '
end
if opt.missing then
- str = str .. colours.icon_missing .. '!!!MISSING!!! '
+ str = str .. colour.icon_missing .. icon.missing .. ' '
end
return str
end
function mt:option_text(opt, info)
local str = opt.name
- local col = colours.option
+ local col = colour.option
if info.selected then
- col = info.empty and colours.selected_empty or colours.selected
+ col = info.empty and colour.selected_empty or colour.selected
elseif info.empty then
- col = colours.group_empty
+ col = colour.group_empty
elseif opt.type == 'group' then
- col = colours.group
+ col = colour.group
end
if opt.matches then
local buf = ''
- local hl_col = info.empty and colours.search_hl_empty or
- colours.search_hl
+ local hl_col = info.empty and colour.search_hl_empty or
+ colour.search_hl
local n = 0
for _, match in ipairs(opt.matches) do
@@ -233,7 +234,7 @@ function mt:option_text(opt, info)
end
if opt.info and #opt.info > 0 then
- str = str .. colours.info .. ' (' .. asscape(opt.info) .. ')'
+ str = str .. colour.info .. ' (' .. asscape(opt.info) .. ')'
end
return str
@@ -244,8 +245,8 @@ function mt:option_path(opt, info)
return ''
end
- local str = info.empty and colours.search_path_empty or
- colours.search_path
+ local str = info.empty and colour.search_path_empty or
+ colour.search_path
for i = #opt.path, 1, -1 do
str = str .. ' « ' .. asscape(opt.path[i].name)
end
@@ -449,10 +450,10 @@ function mt:render_bg()
local sb = self.out.scrollbar
if sb then
local hover = self.mstate and self.mstate.target == 'scrollbar'
- local fg = hover and colours.scrollbar_fg_hover or
- colours.scrollbar_fg
- local bg = hover and colours.scrollbar_bg_hover or
- colours.scrollbar_bg
+ local fg = hover and colour.scrollbar_fg_hover or
+ colour.scrollbar_fg
+ local bg = hover and colour.scrollbar_bg_hover or
+ colour.scrollbar_bg
self.bg.data = self.bg.data .. '\n' ..
-- bg