From c83aeb823cf367a144d5eb70282b76d50adf2181 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 10 Jan 2025 12:26:55 +0100 Subject: [PATCH] console.lua: improved the hovered item calculation Currently determine_hovered_item() assumes that each item is opts.font_size pixels tall, which usually works well. This breaks with fonts that get drawn taller than that, such as Japanese text, which makes the calculation inaccurate for the top items and clips the counter. A couple of users reported that it is inaccurate for them for the top items even with ASCII characters, though I can't reproduce it. To fix this place each selectable item in its own ASS event positioned like determine_hovered_item() expects. --- player/lua/console.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/player/lua/console.lua b/player/lua/console.lua index 32336aa2cfb06..6be5cf85e5f3b 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -602,8 +602,16 @@ local function update() local log_ass = '' local log_buffer = log_buffers[id] for i = #log_buffer - math.min(max_lines, #log_buffer) + 1, #log_buffer do - log_ass = log_ass .. style .. log_buffer[i].style .. - ass_escape(log_buffer[i].text) .. '\\N' + local log_item = style .. log_buffer[i].style .. ass_escape(log_buffer[i].text) + + if selectable_items then + ass:new_event() + ass:an(1) + ass:pos(x, y - 1.5 * opts.font_size - (#log_buffer - i) * opts.font_size) + ass:append(log_item) + else + log_ass = log_ass .. log_item .. '\\N' + end end ass:new_event()