diff --git a/init.lua b/init.lua index 1b962da..4a09b32 100644 --- a/init.lua +++ b/init.lua @@ -52,6 +52,8 @@ unified_inventory = { list_img_offset = 0.13, 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 } diff --git a/internal.lua b/internal.lua index 3fbf5b7..a765e18 100644 --- a/internal.lua +++ b/internal.lua @@ -1,6 +1,7 @@ local S = minetest.get_translator("unified_inventory") local F = minetest.formspec_escape local ui = unified_inventory +local hide_disabled_buttons = ui.hide_disabled_buttons -- This pair of encoding functions is used where variable text must go in -- button names, where the text might contain formspec metacharacters. @@ -65,8 +66,9 @@ local function formspec_tab_buttons(player, formspec, style) style.main_button_cols * style.btn_spc, style.main_button_rows -- size ) n = n + 1 + local i = 1 - for i, def in pairs(filtered_inv_buttons) do + for _, def in pairs(filtered_inv_buttons) do 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 @@ -78,11 +80,14 @@ local function formspec_tab_buttons(player, formspec, style) F(def.name)) formspec[n+1] = "tooltip["..F(def.name)..";"..(def.tooltip or "").."]" n = n+2 - else + i = i + 1 + + elseif not hide_disabled_buttons then formspec[n] = string.format("image[%g,%g;%g,%g;%s^[colorize:#808080:alpha]", pos_x, pos_y, style.btn_size, style.btn_size, def.image) n = n+1 + i = i + 1 end end end diff --git a/settingtypes.txt b/settingtypes.txt index 27768ac..5ab7f84 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -10,5 +10,8 @@ unified_inventory_bags (Enable bags) bool true #and the give privilege. 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 \ No newline at end of file + +unified_inventory_automatic_categorization (Items automatically added to categories) bool true