don't mess up scrollbar calculation
This commit is contained in:
parent
43e50ee7d1
commit
fcebcf17d8
13
internal.lua
13
internal.lua
|
@ -53,11 +53,13 @@ local function formspec_tab_buttons(player, formspec, style)
|
||||||
|
|
||||||
local filtered_inv_buttons = {}
|
local filtered_inv_buttons = {}
|
||||||
|
|
||||||
for i, def in pairs(ui.buttons) do
|
for _, def in pairs(ui.buttons) do
|
||||||
if not (style.is_lite_mode and def.hide_lite) then
|
if not (style.is_lite_mode and def.hide_lite) then
|
||||||
|
if (def.condition == nil or def.condition(player) or not hide_disabled_buttons) then
|
||||||
table.insert(filtered_inv_buttons, def)
|
table.insert(filtered_inv_buttons, def)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local needs_scrollbar = #filtered_inv_buttons > style.main_button_cols * style.main_button_rows
|
local needs_scrollbar = #filtered_inv_buttons > style.main_button_cols * style.main_button_rows
|
||||||
|
|
||||||
|
@ -66,28 +68,25 @@ local function formspec_tab_buttons(player, formspec, style)
|
||||||
style.main_button_cols * style.btn_spc, style.main_button_rows -- size
|
style.main_button_cols * style.btn_spc, style.main_button_rows -- size
|
||||||
)
|
)
|
||||||
n = n + 1
|
n = n + 1
|
||||||
local i = 1
|
|
||||||
|
|
||||||
for _, def in pairs(filtered_inv_buttons) do
|
for i, def in pairs(filtered_inv_buttons) do
|
||||||
local pos_x = ((i - 1) % style.main_button_cols) * style.btn_spc
|
local pos_x = ((i - 1) % style.main_button_cols) * style.btn_spc
|
||||||
local pos_y = math.floor((i - 1) / style.main_button_cols) * style.btn_spc
|
local pos_y = math.floor((i - 1) / style.main_button_cols) * style.btn_spc
|
||||||
|
|
||||||
if def.type == "image" then
|
if def.type == "image" then
|
||||||
if (def.condition == nil or def.condition(player) == true) then
|
if (def.condition == nil or def.condition(player)) then
|
||||||
formspec[n] = string.format("image_button[%g,%g;%g,%g;%s;%s;]",
|
formspec[n] = string.format("image_button[%g,%g;%g,%g;%s;%s;]",
|
||||||
pos_x, pos_y, style.btn_size, style.btn_size,
|
pos_x, pos_y, style.btn_size, style.btn_size,
|
||||||
F(def.image),
|
F(def.image),
|
||||||
F(def.name))
|
F(def.name))
|
||||||
formspec[n+1] = "tooltip["..F(def.name)..";"..(def.tooltip or "").."]"
|
formspec[n+1] = "tooltip["..F(def.name)..";"..(def.tooltip or "").."]"
|
||||||
n = n+2
|
n = n+2
|
||||||
i = i + 1
|
|
||||||
|
|
||||||
elseif not hide_disabled_buttons then
|
else
|
||||||
formspec[n] = string.format("image[%g,%g;%g,%g;%s^[colorize:#808080:alpha]",
|
formspec[n] = string.format("image[%g,%g;%g,%g;%s^[colorize:#808080:alpha]",
|
||||||
pos_x, pos_y, style.btn_size, style.btn_size,
|
pos_x, pos_y, style.btn_size, style.btn_size,
|
||||||
def.image)
|
def.image)
|
||||||
n = n+1
|
n = n+1
|
||||||
i = i + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue