From 89c42e4481c03b70422d5c8c30449325a9d7ad7f Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 10 Jan 2025 12:20:09 +0100 Subject: [PATCH] console.lua: deduplicate y position calculation in update() This deduplicates the calculation of the y position by assigning it to a y variable, which will also be used in the next commit. margin_x is also renamed to x for consistency. --- player/lua/console.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/player/lua/console.lua b/player/lua/console.lua index 049b95ef35..32336aa2cf 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -547,8 +547,8 @@ local function update() local osd_w, osd_h = get_scaled_osd_dimensions() - local margin_x = get_margin_x() - local margin_y = get_margin_y() + local x = get_margin_x() + local y = osd_h * (1 - global_margins.b) - get_margin_y() local coordinate_top = math.floor(global_margins.t * osd_h + 0.5) local clipping_coordinates = '0,' .. coordinate_top .. ',' .. @@ -589,7 +589,7 @@ local function update() -- libass/ass_render.c:ass_render_event() subtracts --osd-margin-x from -- the maximum text width twice. local width_max = math.floor( - (osd_w - margin_x - mp.get_property_native('osd-margin-x') * 2 / scale_factor()) + (osd_w - x - mp.get_property_native('osd-margin-x') * 2 / scale_factor()) / opts.font_size * get_font_hw_ratio()) local suggestions, rows = format_table(suggestion_buffer, width_max, max_lines) @@ -608,7 +608,7 @@ local function update() ass:new_event() ass:an(1) - ass:pos(margin_x, osd_h - margin_y - global_margins.b * osd_h) + ass:pos(x, y) ass:append(log_ass .. '\\N') ass:append(suggestion_ass) ass:append(style .. ass_escape(prompt) .. ' ' .. before_cur) @@ -619,7 +619,7 @@ local function update() -- cursor appear in front of the text. ass:new_event() ass:an(1) - ass:pos(margin_x, osd_h - margin_y - global_margins.b * osd_h) + ass:pos(x, y) ass:append(style .. '{\\alpha&HFF&}' .. ass_escape(prompt) .. ' ' .. before_cur) ass:append(cglyph) ass:append(style .. '{\\alpha&HFF&}' .. after_cur)