Improve scroll height calculation (#220)

This commit is contained in:
luk3yx 2022-12-31 09:43:46 +13:00 committed by GitHub
parent 31c35dcd59
commit 82cdf24045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -91,9 +91,10 @@ local function formspec_tab_buttons(player, formspec, style)
end
formspec[n] = "scroll_container_end[]"
if needs_scrollbar then
local total_rows = math.ceil(#filtered_inv_buttons / style.main_button_cols)
formspec[n+1] = ("scrollbaroptions[max=%i;arrows=hide]"):format(
-- This calculation is not 100% accurate but "good enough"
math.ceil((#filtered_inv_buttons - 1) / style.main_button_cols) * style.btn_spc * 5
(total_rows - style.main_button_rows) * style.btn_spc * 10
)
formspec[n+2] = ("scrollbar[%g,%g;0.4,%g;vertical;tabbtnscroll;0]"):format(
style.main_button_x + style.main_button_cols * style.btn_spc - 0.1, -- x pos