re-arrange a few elements in the crafting guide to eliminate text overlap
Also make sure to chech if lite mode before assuming 4x2 "tab" button layout.
This commit is contained in:
parent
0a70d8edef
commit
16e40a2e22
4
init.lua
4
init.lua
@ -43,7 +43,7 @@ unified_inventory = {
|
|||||||
main_button_x = 0,
|
main_button_x = 0,
|
||||||
main_button_y = 9,
|
main_button_y = 9,
|
||||||
craft_result_x = 0.3,
|
craft_result_x = 0.3,
|
||||||
craft_result_y = 0.6,
|
craft_result_y = 0.5,
|
||||||
form_header_y = 0
|
form_header_y = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ if unified_inventory.lite_mode then
|
|||||||
unified_inventory.formspec_y = 0.47
|
unified_inventory.formspec_y = 0.47
|
||||||
unified_inventory.main_button_x = 8.2
|
unified_inventory.main_button_x = 8.2
|
||||||
unified_inventory.main_button_y = 6.5
|
unified_inventory.main_button_y = 6.5
|
||||||
unified_inventory.craft_result_x = 2.3
|
unified_inventory.craft_result_x = 2.8
|
||||||
unified_inventory.craft_result_y = 3.4
|
unified_inventory.craft_result_y = 3.4
|
||||||
unified_inventory.form_header_y = -0.1
|
unified_inventory.form_header_y = -0.1
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
-- Main buttons
|
-- Main buttons
|
||||||
for i, def in pairs(unified_inventory.buttons) do
|
for i, def in pairs(unified_inventory.buttons) do
|
||||||
|
|
||||||
if i > 4 then
|
if unified_inventory.lite_mode and i > 4 then
|
||||||
button_row = 1
|
button_row = 1
|
||||||
button_col = 1
|
button_col = 1
|
||||||
end
|
end
|
||||||
|
22
register.lua
22
register.lua
@ -166,7 +166,7 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
|
|||||||
displayitem = group_item.item or "unknown"
|
displayitem = group_item.item or "unknown"
|
||||||
selectitem = group_item.sole and displayitem or name
|
selectitem = group_item.sole and displayitem or name
|
||||||
end
|
end
|
||||||
local label = string.format("\n\n%s%7d", show_is_group and "G" or " ", count):gsub(" 1$", " .")
|
local label = string.format("\n\n%s%7d", show_is_group and " G\n" or " ", count):gsub(" 1$", " .")
|
||||||
if label == "\n\n ." then label = "" end
|
if label == "\n\n ." then label = "" end
|
||||||
return string.format("item_image_button[%f,%f;%u,%u;%s;%s;%s]",
|
return string.format("item_image_button[%f,%f;%u,%u;%s;%s;%s]",
|
||||||
x, y, w, h,
|
x, y, w, h,
|
||||||
@ -215,17 +215,17 @@ unified_inventory.register_page("craftguide", {
|
|||||||
craft = crafts[alternate]
|
craft = crafts[alternate]
|
||||||
end
|
end
|
||||||
|
|
||||||
formspec = formspec.."background[0,"..unified_inventory.formspec_y..";8,3;ui_craftguide_form.png]"
|
formspec = formspec.."background[0.5,"..(unified_inventory.formspec_y + 0.2)..";8,3;ui_craftguide_form.png]"
|
||||||
formspec = formspec.."textarea["..unified_inventory.craft_result_x..","..unified_inventory.craft_result_y
|
formspec = formspec.."textarea["..unified_inventory.craft_result_x..","..unified_inventory.craft_result_y
|
||||||
..";10,1;;"..minetest.formspec_escape(role_text[dir]..": "..item_name)..";]"
|
..";10,1;;"..minetest.formspec_escape(role_text[dir]..": "..item_name)..";]"
|
||||||
formspec = formspec..stack_image_button(0, unified_inventory.formspec_y, 1.1, 1.1, "item_button_"
|
formspec = formspec..stack_image_button(0, unified_inventory.formspec_y, 1.1, 1.1, "item_button_"
|
||||||
.. rdir .. "_", ItemStack(item_name))
|
.. rdir .. "_", ItemStack(item_name))
|
||||||
|
|
||||||
if not craft then
|
if not craft then
|
||||||
formspec = formspec.."label[6,"..(unified_inventory.formspec_y + 2.35)..";"
|
formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 2.35)..";"
|
||||||
..minetest.formspec_escape(no_recipe_text[dir]).."]"
|
..minetest.formspec_escape(no_recipe_text[dir]).."]"
|
||||||
local no_pos = dir == "recipe" and 4 or 6
|
local no_pos = dir == "recipe" and 4.5 or 6.5
|
||||||
local item_pos = dir == "recipe" and 6 or 4
|
local item_pos = dir == "recipe" and 6.5 or 4.5
|
||||||
formspec = formspec.."image["..no_pos..","..unified_inventory.formspec_y..";1.1,1.1;ui_no.png]"
|
formspec = formspec.."image["..no_pos..","..unified_inventory.formspec_y..";1.1,1.1;ui_no.png]"
|
||||||
formspec = formspec..stack_image_button(item_pos, unified_inventory.formspec_y, 1.1, 1.1, "item_button_"
|
formspec = formspec..stack_image_button(item_pos, unified_inventory.formspec_y, 1.1, 1.1, "item_button_"
|
||||||
..other_dir[dir].."_", ItemStack(item_name))
|
..other_dir[dir].."_", ItemStack(item_name))
|
||||||
@ -241,16 +241,16 @@ unified_inventory.register_page("craftguide", {
|
|||||||
local craft_type = unified_inventory.registered_craft_types[craft.type] or
|
local craft_type = unified_inventory.registered_craft_types[craft.type] or
|
||||||
unified_inventory.craft_type_defaults(craft.type, {})
|
unified_inventory.craft_type_defaults(craft.type, {})
|
||||||
if craft_type.icon then
|
if craft_type.icon then
|
||||||
formspec = formspec..string.format(" image[%f,%f;%f,%f;%s]",5.2,(unified_inventory.formspec_y - 0.15),0.5,0.5,craft_type.icon)
|
formspec = formspec..string.format(" image[%f,%f;%f,%f;%s]",5.7,(unified_inventory.formspec_y + 0.05),0.5,0.5,craft_type.icon)
|
||||||
end
|
end
|
||||||
formspec = formspec.."label[5,"..(unified_inventory.formspec_y + 0.5)..";" .. minetest.formspec_escape(craft_type.description).."]"
|
formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 1)..";" .. minetest.formspec_escape(craft_type.description).."]"
|
||||||
formspec = formspec..stack_image_button(6, unified_inventory.formspec_y, 1.1, 1.1, "item_button_usage_", ItemStack(craft.output))
|
formspec = formspec..stack_image_button(6.5, unified_inventory.formspec_y, 1.1, 1.1, "item_button_usage_", ItemStack(craft.output))
|
||||||
local display_size = craft_type.dynamic_display_size and craft_type.dynamic_display_size(craft) or { width = craft_type.width, height = craft_type.height }
|
local display_size = craft_type.dynamic_display_size and craft_type.dynamic_display_size(craft) or { width = craft_type.width, height = craft_type.height }
|
||||||
local craft_width = craft_type.get_shaped_craft_width and craft_type.get_shaped_craft_width(craft) or display_size.width
|
local craft_width = craft_type.get_shaped_craft_width and craft_type.get_shaped_craft_width(craft) or display_size.width
|
||||||
|
|
||||||
-- This keeps recipes aligned to the right,
|
-- This keeps recipes aligned to the right,
|
||||||
-- so that they're close to the arrow.
|
-- so that they're close to the arrow.
|
||||||
local xoffset = 1 + (3 - display_size.width)
|
local xoffset = 1.5 + (3 - display_size.width)
|
||||||
for y = 1, display_size.height do
|
for y = 1, display_size.height do
|
||||||
for x = 1, display_size.width do
|
for x = 1, display_size.width do
|
||||||
local item
|
local item
|
||||||
@ -285,10 +285,10 @@ unified_inventory.register_page("craftguide", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if alternates and alternates > 1 then
|
if alternates and alternates > 1 then
|
||||||
formspec = formspec.."label[6,"..(unified_inventory.formspec_y + 0.95)..";"..recipe_text[dir].." "
|
formspec = formspec.."label[5.5,"..(unified_inventory.formspec_y + 1.6)..";"..recipe_text[dir].." "
|
||||||
..tostring(alternate).." of "
|
..tostring(alternate).." of "
|
||||||
..tostring(alternates).."]"
|
..tostring(alternates).."]"
|
||||||
.."button[6,"..(unified_inventory.formspec_y + 1.3)..";2,1;alternate;" .. S("Alternate") .. "]"
|
.."button[5.5,"..(unified_inventory.formspec_y + 2)..";2,1;alternate;" .. S("Alternate") .. "]"
|
||||||
end
|
end
|
||||||
return {formspec = formspec}
|
return {formspec = formspec}
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user