diff --git a/api.lua b/api.lua index 64efe0b..1609217 100644 --- a/api.lua +++ b/api.lua @@ -151,7 +151,7 @@ minetest.after(0.01, function() -- Step 2: Find all matching items for the given spec (groups) local function get_matching_spec_items(specname) if specname:sub(1,6) ~= "group:" then - return { specname } + return { [specname] = true } end local accepted = {} @@ -177,6 +177,7 @@ minetest.after(0.01, function() end for _, recipes in pairs(ui.crafts_for.recipe) do + -- List of crafts that return this item string (variable "_") for _, recipe in ipairs(recipes) do local ingredient_items = {} for _, spec in pairs(recipe.items) do diff --git a/callbacks.lua b/callbacks.lua index e92175d..fa6d03a 100644 --- a/callbacks.lua +++ b/callbacks.lua @@ -19,14 +19,12 @@ minetest.register_on_joinplayer(function(player) unified_inventory.items_list unified_inventory.activefilter[player_name] = "" unified_inventory.active_search_direction[player_name] = "nochange" - unified_inventory.apply_filter(player, "", "nochange") unified_inventory.current_searchbox[player_name] = "" unified_inventory.current_category[player_name] = "all" unified_inventory.current_category_scroll[player_name] = 0 unified_inventory.alternate[player_name] = 1 unified_inventory.current_item[player_name] = nil unified_inventory.current_craft_direction[player_name] = "recipe" - unified_inventory.set_inventory_formspec(player, unified_inventory.default) -- Refill slot local refill = minetest.create_detached_inventory(player_name.."refill", { @@ -48,6 +46,14 @@ minetest.register_on_joinplayer(function(player) refill:set_size("main", 1) end) +minetest.register_on_mods_loaded(function() + minetest.register_on_joinplayer(function(player) + -- After everything is initialized, set up the formspec + ui.apply_filter(player, "", "nochange") + ui.set_inventory_formspec(player, unified_inventory.default) + end) +end) + local function apply_new_filter(player, search_text, new_dir) local player_name = player:get_player_name() diff --git a/init.lua b/init.lua index 12a14ed..8bb2360 100644 --- a/init.lua +++ b/init.lua @@ -50,7 +50,7 @@ unified_inventory = { trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false), imgscale = 1.25, list_img_offset = 0.13, - standard_background = "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]", version = 4 } diff --git a/internal.lua b/internal.lua index b264d22..938ca19 100644 --- a/internal.lua +++ b/internal.lua @@ -115,9 +115,9 @@ local function formspec_add_categories(player, formspec, ui_peruser) ui_peruser.form_header_y - (ui_peruser.is_lite_mode and 0 or 0.2) } - formspec[n] = string.format("background9[%f,%f;%f,%f;%s;false;3]", - ui_peruser.page_x-0.1, categories_scroll_pos[2], - (ui_peruser.btn_spc * ui_peruser.pagecols) + 0.13, 1.4 + (ui_peruser.is_lite_mode and 0 or 0.2), + formspec[n] = string.format("background9[%f,%f;%f,%f;%s;false;16]", + ui_peruser.page_x-0.15, categories_scroll_pos[2], + (ui_peruser.btn_spc * ui_peruser.pagecols) + 0.2, 1.4 + (ui_peruser.is_lite_mode and 0 or 0.2), "ui_smallbg_9_sliced.png") n = n + 1 @@ -256,8 +256,14 @@ local function formspec_add_item_browser(player, formspec, ui_peruser) ui_peruser.btn_size, ui_peruser.btn_size, name, button_name ) + local tooltip = item.description + if item.mod_origin then + -- "mod_origin" may not be specified for items that were + -- registered in a callback (during or before ServerEnv init) + tooltip = tooltip .. " [" .. item.mod_origin .. "]" + end formspec[n + 1] = ("tooltip[%s;%s]"):format( - button_name, minetest.formspec_escape(item.description) + button_name, minetest.formspec_escape(tooltip) ) n = n + 2 list_index = list_index + 1 diff --git a/screenshot.png b/screenshot.png index 972cbb4..bf9e6be 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/textures/ui_formbg_9_sliced.png b/textures/ui_formbg_9_sliced.png index 0b8463c..817ced5 100644 Binary files a/textures/ui_formbg_9_sliced.png and b/textures/ui_formbg_9_sliced.png differ diff --git a/textures/ui_smallbg_9_sliced.png b/textures/ui_smallbg_9_sliced.png index 865e0c9..916b146 100644 Binary files a/textures/ui_smallbg_9_sliced.png and b/textures/ui_smallbg_9_sliced.png differ