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.
23
bags.lua
@ -7,17 +7,19 @@ License: GPLv3
|
||||
|
||||
local S = minetest.get_translator("unified_inventory")
|
||||
local F = minetest.formspec_escape
|
||||
local bags_inv_bg_prefix = "image[-0.1,0.9;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.1;2,0.5;bag1;" .. F(S("Bag @1", 1)) .. "]",
|
||||
"button[2,2.1;2,0.5;bag2;" .. F(S("Bag @1", 2)) .. "]",
|
||||
"button[4,2.1;2,0.5;bag3;" .. F(S("Bag @1", 3)) .. "]",
|
||||
"button[6,2.1;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;]",
|
||||
@ -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;]",
|
||||
"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[6,0;1,1;ui_bags_trash.png]"
|
||||
.. "list[detached:trash;main;6,0.1;1,1;]"
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
|
5
init.lua
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
After Width: | Height: | Size: 1.2 KiB |
BIN
textures/ui_bags_inv_large.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
textures/ui_bags_inv_medium.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
textures/ui_bags_inv_small.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1003 B |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.7 KiB |
@ -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")) .. "]"
|
||||
|
||||
|