Merge remote-tracking branch 'github/master'

This commit is contained in:
bri cassa 2021-11-26 21:45:26 +01:00
commit 1ac54a017d
2 changed files with 9 additions and 3 deletions

View File

@ -157,7 +157,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- Check clicked item image button -- Check clicked item image button
local clicked_item local clicked_item
for name, value in pairs(fields) do for name, value in pairs(fields) do
local new_dir, mangled_item = string.match(name, "^item_button_([a-z]+)_(.*)$") local new_dir, mangled_item = string.match(name, "^[0-9]*_?item_button_([a-z]+)_(.*)$")
if new_dir and mangled_item then if new_dir and mangled_item then
clicked_item = unified_inventory.demangle_for_formspec(mangled_item) clicked_item = unified_inventory.demangle_for_formspec(mangled_item)
if string.sub(clicked_item, 1, 6) == "group:" then if string.sub(clicked_item, 1, 6) == "group:" then

View File

@ -159,8 +159,10 @@ ui.register_page("craft", {
local function stack_image_button(x, y, w, h, buttonname_prefix, item) local function stack_image_button(x, y, w, h, buttonname_prefix, item)
local name = item:get_name() local name = item:get_name()
local count = item:get_count() local count = item:get_count()
local wear = item:get_wear()
local description = item:get_meta():get_string("description")
local show_is_group = false local show_is_group = false
local displayitem = name.." "..count local displayitem = name.." "..count.." "..wear
local selectitem = name local selectitem = name
if name:sub(1, 6) == "group:" then if name:sub(1, 6) == "group:" then
local group_name = name:sub(7) local group_name = name:sub(7)
@ -170,7 +172,9 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
selectitem = group_item.sole and displayitem or name selectitem = group_item.sole and displayitem or name
end end
local label = show_is_group and "G" or "" local label = show_is_group and "G" or ""
local buttonname = F(buttonname_prefix..ui.mangle_for_formspec(selectitem)) -- Unique id to prevent tooltip being overridden
local id = string.format("%i%i_", x*10, y*10)
local buttonname = F(id..buttonname_prefix..ui.mangle_for_formspec(selectitem))
local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]", local button = string.format("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
x, y, w, h, x, y, w, h,
F(displayitem), buttonname, label) F(displayitem), buttonname, label)
@ -186,6 +190,8 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
if andcount >= 1 then if andcount >= 1 then
button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip) button = button .. string.format("tooltip[%s;%s]", buttonname, grouptip)
end end
elseif description ~= "" then
button = button .. string.format("tooltip[%s;%s]", buttonname, F(description))
end end
return button return button
end end