8 Commits

Author SHA1 Message Date
d1a4396fbe Fix bags backwards compatibility breakage since 4403b69 (#167) 2021-03-09 11:12:50 +01:00
fbbf786caf Tweak spacing between bags page top row and bag's inv 2021-03-01 18:57:50 +01:00
ae124b02c2 Tweak trash can icon 2021-03-01 18:57:50 +01:00
ebd1d1f245 Improve consistency of inventory (and alike) imagery
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.
2021-03-01 18:57:50 +01:00
0f756a5d33 Update translation for zh_CN and zh_TW (#161) 2020-12-15 19:17:10 +01:00
341a438267 Search items by English and translated description (#156)
This works only with Minetest version >= 5.3.0, nothing is changed for
older versions.
2020-07-15 20:21:06 +02:00
d86592841e Remove unused 0.4.x files, multiline description 2020-07-11 19:51:42 +02:00
f25426911d Fix teleport sounds when teleport fails (#155) 2020-07-10 21:58:45 +02:00
23 changed files with 48 additions and 37 deletions

View File

@ -188,7 +188,9 @@ function unified_inventory.go_home(player)
local pos = unified_inventory.home_pos[player:get_player_name()]
if pos then
player:set_pos(pos)
return true
end
return false
end
-- register_craft

View File

@ -7,22 +7,24 @@ License: GPLv3
local S = minetest.get_translator("unified_inventory")
local F = minetest.formspec_escape
local bags_inv_bg_prefix = "image[-0.1,1.0;10.05,"
unified_inventory.register_page("bags", {
get_formspec = function(player)
local player_name = player:get_player_name()
return { formspec = table.concat({
"background[0.06,0.99;7.92,7.52;ui_bags_main_form.png]",
string.gsub(unified_inventory.standard_inv_bg, "YYY", "4.4"),
bags_inv_bg_prefix.."1.175;ui_bags_header.png]",
"label[0,0;" .. F(S("Bags")) .. "]",
"button[0,2;2,0.5;bag1;" .. F(S("Bag @1", 1)) .. "]",
"button[2,2;2,0.5;bag2;" .. F(S("Bag @1", 2)) .. "]",
"button[4,2;2,0.5;bag3;" .. F(S("Bag @1", 3)) .. "]",
"button[6,2;2,0.5;bag4;" .. F(S("Bag @1", 4)) .. "]",
"button[0,2.2;2,0.5;bag1;" .. F(S("Bag @1", 1)) .. "]",
"button[2,2.2;2,0.5;bag2;" .. F(S("Bag @1", 2)) .. "]",
"button[4,2.2;2,0.5;bag3;" .. F(S("Bag @1", 3)) .. "]",
"button[6,2.2;2,0.5;bag4;" .. F(S("Bag @1", 4)) .. "]",
"listcolors[#00000000;#00000000]",
"list[detached:" .. F(player_name) .. "_bags;bag1;0.5,1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag2;2.5,1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag3;4.5,1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag4;6.5,1;1,1;]"
"list[detached:" .. F(player_name) .. "_bags;bag1;0.5,1.1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag2;2.5,1.1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag3;4.5,1.1;1,1;]",
"list[detached:" .. F(player_name) .. "_bags;bag4;6.5,1.1;1,1;]"
}) }
end,
})
@ -47,26 +49,27 @@ for bag_i = 1, 4 do
local stack = get_player_bag_stack(player, bag_i)
local image = stack:get_definition().inventory_image
local fs = {
string.gsub(unified_inventory.standard_inv_bg, "YYY", "4.4"),
"image[7,0;1,1;" .. image .. "]",
"label[0,0;" .. F(S("Bag @1", bag_i)) .. "]",
"listcolors[#00000000;#00000000]",
"list[current_player;bag" .. bag_i .. "contents;0,1;8,3;]",
"list[current_player;bag" .. bag_i .. "contents;0,1.1;8,3;]",
"listring[current_name;bag" .. bag_i .. "contents]",
"listring[current_player;main]"
"listring[current_player;main]",
}
local slots = stack:get_definition().groups.bagslots
if slots == 8 then
fs[#fs + 1] = "background[0.06,0.99;7.92,7.52;ui_bags_sm_form.png]"
fs[#fs + 1] = bags_inv_bg_prefix.."1.175;ui_bags_inv_small.png]"
elseif slots == 16 then
fs[#fs + 1] = "background[0.06,0.99;7.92,7.52;ui_bags_med_form.png]"
fs[#fs + 1] = bags_inv_bg_prefix.."2.35;ui_bags_inv_medium.png]"
elseif slots == 24 then
fs[#fs + 1] = "background[0.06,0.99;7.92,7.52;ui_bags_lg_form.png]"
fs[#fs + 1] = bags_inv_bg_prefix.."3.525;ui_bags_inv_large.png]"
end
local player_name = player:get_player_name() -- For if statement.
if unified_inventory.trash_enabled
or unified_inventory.is_creative(player_name)
or minetest.get_player_privs(player_name).give then
fs[#fs + 1] = "background[6.06,0;0.92,0.92;ui_bags_trash.png]"
fs[#fs + 1] = "image[5.91,-0.06;1.21,1.15;ui_bags_trash.png]"
.. "list[detached:trash;main;6,0.1;1,1;]"
end
local inv = player:get_inventory()
@ -132,7 +135,7 @@ end
local function load_bags_metadata(player, bags_inv)
local player_inv = player:get_inventory()
local meta = player:get_meta()
local bags_meta = meta:get_string("unified_inventory:bags")
local bags_meta = meta:get("unified_inventory:bags")
local bags = bags_meta and minetest.deserialize(bags_meta) or {}
local dirty_meta = false
if not bags_meta then

View File

@ -1,5 +0,0 @@
default
creative?
sfinv?
datastorage?
farming?

View File

@ -1 +0,0 @@
Unified Inventory replaces the default survival and creative inventory. It adds a nicer interface and a number of features, such as a crafting guide.

View File

@ -44,7 +44,10 @@ unified_inventory = {
main_button_y = 9,
craft_result_x = 0.3,
craft_result_y = 0.5,
form_header_y = 0
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

View File

@ -65,13 +65,13 @@ function unified_inventory.get_formspec(player, page)
local formspec = {
"size[14,10]",
pagedef.formspec_prepend and "" or "no_prepend[]",
"background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]" -- Background
unified_inventory.standard_background -- Background
}
local n = 4
if draw_lite_mode then
formspec[1] = "size[11,7.7]"
formspec[3] = "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]"
formspec[3] = unified_inventory.standard_background
end
if unified_inventory.is_creative(player_name)
@ -130,7 +130,7 @@ function unified_inventory.get_formspec(player, page)
if fsdata.draw_inventory ~= false then
-- Player inventory
formspec[n] = "listcolors[#00000000;#00000000]"
formspec[n+1] = "list[current_player;main;0,"..(ui_peruser.formspec_y + 3.5)..";8,4;]"
formspec[n+1] = string.gsub(unified_inventory.standard_inv, "YYY", ui_peruser.formspec_y + 3.5)
n = n+2
end
@ -290,10 +290,14 @@ function unified_inventory.apply_filter(player, filter, search_dir)
return true
end
else
local lang = minetest.get_player_information(player_name).lang_code
ffilter = function(name, def)
local lname = string.lower(name)
local ldesc = string.lower(def.description)
local llocaldesc = minetest.get_translated_string
and string.lower(minetest.get_translated_string(lang, def.description))
return string.find(lname, lfilter, 1, true) or string.find(ldesc, lfilter, 1, true)
or llocaldesc and string.find(llocaldesc, lfilter, 1, true)
end
end
unified_inventory.filtered_items_list[player_name]={}

View File

@ -73,6 +73,7 @@ World position=世界位置
Name=名称
HUD text color=HUD文本颜色
#new
Reset search and display everything=重置搜索并显示所有物品
Any item belonging to the @1 group=属于@1组的任何项目
Any item belonging to the groups @1=属于组@1的任何项目

View File

@ -73,6 +73,7 @@ World position=世界位置
Name=名稱
HUD text color=HUD文本顏色
#new
Reset search and display everything=重置搜索並顯示所有物品
Any item belonging to the @1 group=屬於@1組的任何項目
Any item belonging to the groups @1=屬於組@1的任何項目

View File

@ -1,4 +1,7 @@
name = unified_inventory
depends = default
optional_depends = creative, sfinv, datastorage, farming
description = Unified Inventory replaces the default survival and creative inventory. It adds a nicer interface and a number of features, such as a crafting guide.
description = """
Unified Inventory replaces the default survival and creative inventory.
It adds a nicer interface and a number of features, such as a crafting guide.
"""

View File

@ -76,9 +76,9 @@ unified_inventory.register_button("home_gui_go", {
action = function(player)
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {home=true}) then
minetest.sound_play("teleport",
{to_player=player:get_player_name(), gain = 1.0})
unified_inventory.go_home(player)
if unified_inventory.go_home(player) then
minetest.sound_play("teleport", {to_player = player_name})
end
else
minetest.chat_send_player(player_name,
S("You don't have the \"home\" privilege!"))
@ -171,7 +171,7 @@ unified_inventory.register_page("craft", {
local player_name = player:get_player_name()
local formspec = "background[2,"..formspecy..";6,3;ui_crafting_form.png]"
formspec = formspec.."background[0,"..(formspecy + 3.5)..";8,4;ui_main_inventory.png]"
formspec = formspec..string.gsub(unified_inventory.standard_inv_bg, "YYY", (formspecy + 3.4))
formspec = formspec.."label[0,"..formheadery..";" ..F(S("Crafting")).."]"
formspec = formspec.."listcolors[#00000000;#00000000]"
formspec = formspec.."list[current_player;craftpreview;6,"..formspecy..";1,1;]"
@ -268,7 +268,7 @@ unified_inventory.register_page("craftguide", {
local player_name = player:get_player_name()
local player_privs = minetest.get_player_privs(player_name)
local fs = {
"background[0,"..(formspecy + 3.5)..";8,4;ui_main_inventory.png]",
string.gsub(unified_inventory.standard_inv_bg, "YYY", (formspecy + 3.4)),
"label[0,"..formheadery..";" .. F(S("Crafting Guide")) .. "]",
"listcolors[#00000000;#00000000]"
}

BIN
textures/ui_bags_header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -23,7 +23,7 @@ unified_inventory.register_page("waypoints", {
if not waypoints_temp[player_name] then waypoints_temp[player_name] = {hud = 1} end
local waypoints = datastorage.get(player_name, "waypoints")
local formspec = "background[0,4.5;8,4;ui_main_inventory.png]" ..
local formspec = string.gsub(unified_inventory.standard_inv_bg, "YYY", "4.4") ..
"image[0,0;1,1;ui_waypoints_icon.png]" ..
"label[1,0;" .. F(S("Waypoints")) .. "]"