Place les boutons d'inventaires sur 2 lignes

This commit is contained in:
sys4-fr 2018-11-20 22:04:24 +01:00
parent 77c3de08ce
commit 264833ed41

View File

@ -99,17 +99,21 @@ function unified_inventory.get_formspec(player, page)
end end
end end
local j = 1 --Modif NALC (sys4 20/11/2018) 12 buttons max by row
for i, def in pairs(filtered_inv_buttons) do for i, def in pairs(filtered_inv_buttons) do
if draw_lite_mode and i > 4 then if draw_lite_mode and i > 4 then
button_row = 1 button_row = 1
button_col = 1 button_col = 1
elseif not draw_lite_mode and j > 12 then
button_row = 1
j = 1
end end
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) == true) then
formspec[n] = "image_button[" formspec[n] = "image_button["
formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4) formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (j - 1) - button_col * 0.65 * 4) -- Modif NALC
formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;" formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;"
formspec[n+3] = F(def.image)..";" formspec[n+3] = F(def.image)..";"
formspec[n+4] = F(def.name)..";]" formspec[n+4] = F(def.name)..";]"
@ -118,13 +122,14 @@ function unified_inventory.get_formspec(player, page)
n = n+7 n = n+7
else else
formspec[n] = "image[" formspec[n] = "image["
formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4) formspec[n+1] = ( ui_peruser.main_button_x + 0.65 * (j - 1) - button_col * 0.65 * 4) -- Modif NALC
formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;" formspec[n+2] = ","..(ui_peruser.main_button_y + button_row * 0.7)..";0.8,0.8;"
formspec[n+3] = F(def.image).."^[colorize:#808080:alpha]" formspec[n+3] = F(def.image).."^[colorize:#808080:alpha]"
n = n+4 n = n+4
end end
end end
j = j + 1 -- Modif NALC
end end
if fsdata.draw_inventory ~= false then if fsdata.draw_inventory ~= false then