mirror of
https://github.com/minetest-mods/unified_inventory.git
synced 2024-11-15 23:00:17 +01:00
Add setting to hide disabled buttons (#217)
This commit is contained in:
parent
db1c3c10b8
commit
826d5f4683
2
init.lua
2
init.lua
|
@ -52,6 +52,8 @@ unified_inventory = {
|
||||||
list_img_offset = 0.13,
|
list_img_offset = 0.13,
|
||||||
standard_background = "bgcolor[#0000]background9[0,0;1,1;ui_formbg_9_sliced.png;true;16]",
|
standard_background = "bgcolor[#0000]background9[0,0;1,1;ui_formbg_9_sliced.png;true;16]",
|
||||||
|
|
||||||
|
hide_disabled_buttons = minetest.settings:get_bool("unified_inventory_hide_disabled_buttons", false),
|
||||||
|
|
||||||
version = 4
|
version = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,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 ui.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
|
||||||
|
|
||||||
|
@ -71,13 +73,14 @@ local function formspec_tab_buttons(player, formspec, style)
|
||||||
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
|
||||||
|
|
||||||
else
|
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,
|
||||||
|
|
|
@ -10,5 +10,8 @@ unified_inventory_bags (Enable bags) bool true
|
||||||
#and the give privilege.
|
#and the give privilege.
|
||||||
unified_inventory_trash (Enable trash) bool true
|
unified_inventory_trash (Enable trash) bool true
|
||||||
|
|
||||||
|
#If enabled, disabled buttons will be hidden instead of grayed out.
|
||||||
|
unified_inventory_hide_disabled_buttons (Hide disabled buttons) bool false
|
||||||
|
|
||||||
|
|
||||||
unified_inventory_automatic_categorization (Items automatically added to categories) bool true
|
unified_inventory_automatic_categorization (Items automatically added to categories) bool true
|
Loading…
Reference in New Issue
Block a user