summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2023-11-13 08:46:29 +0100
committerKacper Michajłow <kasper93@gmail.com>2024-04-17 23:47:55 +0200
commit51bd00c33a905c3e5de149870b897bc99843e0be (patch)
tree92bc0ab4637542d993e7e0979bd9ff4ec0ce71a8 /player/lua
parent75d899bcaff9a6becda6029440b635360d74698e (diff)
downloadmpv-51bd00c33a905c3e5de149870b897bc99843e0be.tar.bz2
mpv-51bd00c33a905c3e5de149870b897bc99843e0be.tar.xz
stats.lua: inherit OSD styles
Avoid having to configure both the OSD and the stats script opts when you change the OSD options, in particular avoid having to convert colors to BGR. Also document the shadow options. font_size, border_size and shadow offset defaults are kept because the same values look much bigger in the stats than in the corresponding OSD options. osd-back-color is now respected without extra checks until you explicitly set a shadow_color.
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/stats.lua35
1 files changed, 24 insertions, 11 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index 3d093c7e2e..d07e4dc123 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -47,15 +47,15 @@ local o = {
plot_color = "FFFFFF",
-- Text style
- font = "sans-serif",
+ font = "",
font_mono = "monospace", -- monospaced digits are sufficient
font_size = 8,
- font_color = "FFFFFF",
+ font_color = "",
border_size = 0.8,
- border_color = "262626",
+ border_color = "",
shadow_x_offset = 0.0,
shadow_y_offset = 0.0,
- shadow_color = "000000",
+ shadow_color = "",
alpha = "11",
-- Custom header for ASS tags to style the text output.
@@ -158,13 +158,26 @@ local function text_style()
if o.custom_header and o.custom_header ~= "" then
return o.custom_header
else
- local has_shadow = mp.get_property('osd-back-color'):sub(2, 3) == '00'
- return format("{\\r\\an7\\fs%d\\fn%s\\bord%f\\3c&H%s&" ..
- "\\1c&H%s&\\1a&H%s&\\3a&H%s&" ..
- (has_shadow and "\\4a&H%s&\\xshad%f\\yshad%f\\4c&H%s&}" or "}"),
- o.font_size, o.font, o.border_size,
- o.border_color, o.font_color, o.alpha, o.alpha, o.alpha,
- o.shadow_x_offset, o.shadow_y_offset, o.shadow_color)
+ local style = "{\\r\\an7\\fs" .. o.font_size .. "\\bord" .. o.border_size
+
+ if o.font ~= "" then
+ style = style .. "\\fn" .. o.font
+ end
+
+ if o.font_color ~= "" then
+ style = style .. "\\1c&H" .. o.font_color .. "&\\1a&H" .. o.alpha .. "&"
+ end
+
+ if o.border_color ~= "" then
+ style = style .. "\\3c&H" .. o.border_color .. "&\\3a&H" .. o.alpha .. "&"
+ end
+
+ if o.shadow_color ~= "" then
+ style = style .. "\\4c&H" .. o.shadow_color .. "&\\4a&H" .. o.alpha .. "&"
+ end
+
+ return style .. "\\xshad" .. o.shadow_x_offset ..
+ "\\yshad" .. o.shadow_y_offset .. "}"
end
end