ebd1d1f245
In a number of places, background[] is misused to place the inventory backdrop images. Where appropriate, image[] is used instead, so that "ui_form_bg.png" actually serves as the one and only true background image. In so doing, I was able to remake the bag inventory images, making them only big as is actually needed to hold 1, 2, or 3 rows of inventory slots. This, in turn, allows a standardized main inventory image to occupy the lower part of the window, which allows for consistent inventory image positioning and sizing from one page to another. I also removed ui_misc_form.png. Nothing in UI uses it, and any external mods that used it can just use the standard inventory and its background. Lastly, I reduced the background image to 512x384 px. It was unnecessarily large before, considering it has no real detail. The larger inventory images are all 512px wide, and multiples of 64px in height. Before, they were oddly sized.
83 lines
2.1 KiB
Lua
83 lines
2.1 KiB
Lua
-- Unified Inventory for Minetest >= 0.4.16
|
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|
local worldpath = minetest.get_worldpath()
|
|
|
|
-- Data tables definitions
|
|
unified_inventory = {
|
|
activefilter = {},
|
|
active_search_direction = {},
|
|
alternate = {},
|
|
current_page = {},
|
|
current_searchbox = {},
|
|
current_index = {},
|
|
current_item = {},
|
|
current_craft_direction = {},
|
|
registered_craft_types = {},
|
|
crafts_for = {usage = {}, recipe = {} },
|
|
players = {},
|
|
items_list_size = 0,
|
|
items_list = {},
|
|
filtered_items_list_size = {},
|
|
filtered_items_list = {},
|
|
pages = {},
|
|
buttons = {},
|
|
|
|
-- Homepos stuff
|
|
home_pos = {},
|
|
home_filename = worldpath.."/unified_inventory_home.home",
|
|
|
|
-- Default inventory page
|
|
default = "craft",
|
|
|
|
-- "Lite" mode
|
|
lite_mode = minetest.settings:get_bool("unified_inventory_lite"),
|
|
|
|
-- Trash enabled
|
|
trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false),
|
|
|
|
pagecols = 8,
|
|
pagerows = 10,
|
|
page_y = 0,
|
|
formspec_y = 1,
|
|
main_button_x = 0,
|
|
main_button_y = 9,
|
|
craft_result_x = 0.3,
|
|
craft_result_y = 0.5,
|
|
form_header_y = 0,
|
|
standard_background = "background[-0.2,-0.2;1,1;ui_form_bg.png;true]", -- the 'true' scales to fill, overrides the 1,1
|
|
standard_inv = "list[current_player;main;0,YYY;8,4;]", -- the YYY's are placeholders which get
|
|
standard_inv_bg = "image[-0.1,YYY;10.05,4.70;ui_main_inventory.png]", -- replaced later by string.gsub()
|
|
}
|
|
|
|
-- Disable default creative inventory
|
|
local creative = rawget(_G, "creative") or rawget(_G, "creative_inventory")
|
|
if creative then
|
|
function creative.set_creative_formspec(player, start_i, pagenum)
|
|
return
|
|
end
|
|
end
|
|
|
|
-- Disable sfinv inventory
|
|
local sfinv = rawget(_G, "sfinv")
|
|
if sfinv then
|
|
sfinv.enabled = false
|
|
end
|
|
|
|
dofile(modpath.."/group.lua")
|
|
dofile(modpath.."/api.lua")
|
|
dofile(modpath.."/internal.lua")
|
|
dofile(modpath.."/callbacks.lua")
|
|
dofile(modpath.."/match_craft.lua")
|
|
dofile(modpath.."/register.lua")
|
|
|
|
if minetest.settings:get_bool("unified_inventory_bags") ~= false then
|
|
dofile(modpath.."/bags.lua")
|
|
end
|
|
|
|
dofile(modpath.."/item_names.lua")
|
|
|
|
if minetest.get_modpath("datastorage") then
|
|
dofile(modpath.."/waypoints.lua")
|
|
end
|