Skip to content

Commit

Permalink
console.lua: center selectable items around the default item
Browse files Browse the repository at this point in the history
  • Loading branch information
guidocella committed Oct 9, 2024
1 parent bc71d24 commit 804f703
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion player/lua/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,13 @@ mp.register_script_message('get-input', function (script_name, args)
matches = {}
selected_match = args.default_item or 1
default_item = args.default_item
first_match_to_print = 1

local max_lines = calculate_max_log_lines()
first_match_to_print = math.max(1, selected_match - math.floor(max_lines / 2) + 2)
if first_match_to_print > #selectable_items - max_lines + 2 then
first_match_to_print = math.max(1, #selectable_items - max_lines + 2)
end

for i, item in ipairs(selectable_items) do
matches[i] = { index = i, text = item }
end
Expand Down

0 comments on commit 804f703

Please sign in to comment.