Add "lite" mode
Set unified_inventory_lite = true in minetest.conf to enable. This mode reduces the feature-set of the mod as follows: * no bags * no waypoints, * no home/go-home buttons, * no set-day/-night buttons, * smaller creative/craft guide inventory pages (4x6 instead of 8x10) * fewer paging buttons * smaller search field * move "Result: foo" to below the crafting guide grid. * Move main "tab" buttons to the right, below the search and paging buttons. * Made "tab" buttons able to use to 2 rows if necessary (max 8 buttons)
This commit is contained in:
parent
20eba2bf9b
commit
0a70d8edef
@ -68,11 +68,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
|
|
||||||
-- Inventory page controls
|
-- Inventory page controls
|
||||||
local start = math.floor(
|
local start = math.floor(
|
||||||
unified_inventory.current_index[player_name] / 80 + 1)
|
unified_inventory.current_index[player_name] / unified_inventory.items_per_page + 1)
|
||||||
local start_i = start
|
local start_i = start
|
||||||
local pagemax = math.floor(
|
local pagemax = math.floor(
|
||||||
(#unified_inventory.filtered_items_list[player_name] - 1)
|
(#unified_inventory.filtered_items_list[player_name] - 1)
|
||||||
/ (80) + 1)
|
/ (unified_inventory.items_per_page) + 1)
|
||||||
|
|
||||||
if fields.start_list then
|
if fields.start_list then
|
||||||
start_i = 1
|
start_i = 1
|
||||||
@ -101,7 +101,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if not (start_i == start) then
|
if not (start_i == start) then
|
||||||
minetest.sound_play("paperflip1",
|
minetest.sound_play("paperflip1",
|
||||||
{to_player=player_name, gain = 1.0})
|
{to_player=player_name, gain = 1.0})
|
||||||
unified_inventory.current_index[player_name] = (start_i - 1) * 80 + 1
|
unified_inventory.current_index[player_name] = (start_i - 1) * unified_inventory.items_per_page + 1
|
||||||
unified_inventory.set_inventory_formspec(player,
|
unified_inventory.set_inventory_formspec(player,
|
||||||
unified_inventory.current_page[player_name])
|
unified_inventory.current_page[player_name])
|
||||||
end
|
end
|
||||||
|
35
init.lua
35
init.lua
@ -3,7 +3,6 @@
|
|||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
local worldpath = minetest.get_worldpath()
|
local worldpath = minetest.get_worldpath()
|
||||||
|
|
||||||
|
|
||||||
-- Data tables definitions
|
-- Data tables definitions
|
||||||
unified_inventory = {
|
unified_inventory = {
|
||||||
activefilter = {},
|
activefilter = {},
|
||||||
@ -33,8 +32,35 @@ unified_inventory = {
|
|||||||
|
|
||||||
-- intllib
|
-- intllib
|
||||||
gettext = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end,
|
gettext = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end,
|
||||||
|
|
||||||
|
-- "Lite" mode
|
||||||
|
lite_mode = minetest.setting_getbool("unified_inventory_lite"),
|
||||||
|
|
||||||
|
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.6,
|
||||||
|
form_header_y = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if unified_inventory.lite_mode then
|
||||||
|
unified_inventory.pagecols = 4
|
||||||
|
unified_inventory.pagerows = 6
|
||||||
|
unified_inventory.page_y = 0.25
|
||||||
|
unified_inventory.formspec_y = 0.47
|
||||||
|
unified_inventory.main_button_x = 8.2
|
||||||
|
unified_inventory.main_button_y = 6.5
|
||||||
|
unified_inventory.craft_result_x = 2.3
|
||||||
|
unified_inventory.craft_result_y = 3.4
|
||||||
|
unified_inventory.form_header_y = -0.1
|
||||||
|
end
|
||||||
|
|
||||||
|
unified_inventory.items_per_page = unified_inventory.pagecols * unified_inventory.pagerows
|
||||||
|
|
||||||
-- Disable default creative inventory
|
-- Disable default creative inventory
|
||||||
if rawget(_G, "creative_inventory") then
|
if rawget(_G, "creative_inventory") then
|
||||||
function creative_inventory.set_creative_formspec(player, start_i, pagenum)
|
function creative_inventory.set_creative_formspec(player, start_i, pagenum)
|
||||||
@ -47,9 +73,14 @@ dofile(modpath.."/api.lua")
|
|||||||
dofile(modpath.."/internal.lua")
|
dofile(modpath.."/internal.lua")
|
||||||
dofile(modpath.."/callbacks.lua")
|
dofile(modpath.."/callbacks.lua")
|
||||||
dofile(modpath.."/register.lua")
|
dofile(modpath.."/register.lua")
|
||||||
|
|
||||||
|
if not unified_inventory.lite_mode then
|
||||||
dofile(modpath.."/bags.lua")
|
dofile(modpath.."/bags.lua")
|
||||||
|
end
|
||||||
|
|
||||||
dofile(modpath.."/item_names.lua")
|
dofile(modpath.."/item_names.lua")
|
||||||
if minetest.get_modpath("datastorage") then
|
|
||||||
|
if minetest.get_modpath("datastorage") and not unified_inventory.lite_mode then
|
||||||
dofile(modpath.."/waypoints.lua")
|
dofile(modpath.."/waypoints.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
74
internal.lua
74
internal.lua
@ -24,10 +24,16 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
local pagedef = unified_inventory.pages[page]
|
local pagedef = unified_inventory.pages[page]
|
||||||
|
|
||||||
local formspec = "size[14,10]"
|
local formspec = "size[14,10]"
|
||||||
local fsdata = nil
|
|
||||||
|
|
||||||
-- Background
|
-- Background
|
||||||
formspec = formspec .. "background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]"
|
formspec = formspec .. "background[-0.19,-0.25;14.4,10.75;ui_form_bg.png]"
|
||||||
|
|
||||||
|
if unified_inventory.lite_mode then
|
||||||
|
formspec = "size[11,7.7]"
|
||||||
|
formspec = formspec .. "background[-0.19,-0.2;11.4,8.4;ui_form_bg.png]"
|
||||||
|
end
|
||||||
|
|
||||||
|
local fsdata = nil
|
||||||
|
|
||||||
-- Current page
|
-- Current page
|
||||||
if unified_inventory.pages[page] then
|
if unified_inventory.pages[page] then
|
||||||
fsdata = pagedef.get_formspec(player)
|
fsdata = pagedef.get_formspec(player)
|
||||||
@ -36,12 +42,22 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
return "" -- Invalid page name
|
return "" -- Invalid page name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local button_row = 0
|
||||||
|
local button_col = 0
|
||||||
|
|
||||||
-- 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
|
||||||
|
button_row = 1
|
||||||
|
button_col = 1
|
||||||
|
end
|
||||||
|
|
||||||
local tooltip = def.tooltip or ""
|
local tooltip = def.tooltip or ""
|
||||||
if def.type == "image" then
|
if def.type == "image" then
|
||||||
formspec = formspec.."image_button["
|
formspec = formspec.."image_button["
|
||||||
..(0.65 * (i - 1))..",9;0.8,0.8;"
|
..( unified_inventory.main_button_x + 0.65 * (i - 1) - button_col * 0.65 * 4)
|
||||||
|
..","..(unified_inventory.main_button_y + button_row * 0.7)..";0.8,0.8;"
|
||||||
..minetest.formspec_escape(def.image)..";"
|
..minetest.formspec_escape(def.image)..";"
|
||||||
..minetest.formspec_escape(def.name)..";]"
|
..minetest.formspec_escape(def.name)..";]"
|
||||||
.."tooltip["..minetest.formspec_escape(def.name)
|
.."tooltip["..minetest.formspec_escape(def.name)
|
||||||
@ -52,7 +68,7 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
if fsdata.draw_inventory ~= false then
|
if fsdata.draw_inventory ~= false then
|
||||||
-- Player inventory
|
-- Player inventory
|
||||||
formspec = formspec.."listcolors[#00000000;#00000000]"
|
formspec = formspec.."listcolors[#00000000;#00000000]"
|
||||||
formspec = formspec .. "list[current_player;main;0,4.5;8,4;]"
|
formspec = formspec .. "list[current_player;main;0,"..(unified_inventory.formspec_y + 3.5)..";8,4;]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if fsdata.draw_item_list == false then
|
if fsdata.draw_item_list == false then
|
||||||
@ -61,6 +77,8 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
|
|
||||||
-- Controls to flip items pages
|
-- Controls to flip items pages
|
||||||
local start_x = 9.2
|
local start_x = 9.2
|
||||||
|
|
||||||
|
if not unified_inventory.lite_mode then
|
||||||
formspec = formspec
|
formspec = formspec
|
||||||
.. "image_button[" .. (start_x + 0.6 * 0)
|
.. "image_button[" .. (start_x + 0.6 * 0)
|
||||||
.. ",9;.8,.8;ui_skip_backward_icon.png;start_list;]"
|
.. ",9;.8,.8;ui_skip_backward_icon.png;start_list;]"
|
||||||
@ -69,7 +87,6 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
.. "image_button[" .. (start_x + 0.6 * 1)
|
.. "image_button[" .. (start_x + 0.6 * 1)
|
||||||
.. ",9;.8,.8;ui_doubleleft_icon.png;rewind3;]"
|
.. ",9;.8,.8;ui_doubleleft_icon.png;rewind3;]"
|
||||||
.. "tooltip[rewind3;" .. minetest.formspec_escape(S("Back three pages")) .. "]"
|
.. "tooltip[rewind3;" .. minetest.formspec_escape(S("Back three pages")) .. "]"
|
||||||
|
|
||||||
.. "image_button[" .. (start_x + 0.6 * 2)
|
.. "image_button[" .. (start_x + 0.6 * 2)
|
||||||
.. ",9;.8,.8;ui_left_icon.png;rewind1;]"
|
.. ",9;.8,.8;ui_left_icon.png;rewind1;]"
|
||||||
.. "tooltip[rewind1;" .. minetest.formspec_escape(S("Back one page")) .. "]"
|
.. "tooltip[rewind1;" .. minetest.formspec_escape(S("Back one page")) .. "]"
|
||||||
@ -77,7 +94,6 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
.. "image_button[" .. (start_x + 0.6 * 3)
|
.. "image_button[" .. (start_x + 0.6 * 3)
|
||||||
.. ",9;.8,.8;ui_right_icon.png;forward1;]"
|
.. ",9;.8,.8;ui_right_icon.png;forward1;]"
|
||||||
.. "tooltip[forward1;" .. minetest.formspec_escape(S("Forward one page")) .. "]"
|
.. "tooltip[forward1;" .. minetest.formspec_escape(S("Forward one page")) .. "]"
|
||||||
|
|
||||||
.. "image_button[" .. (start_x + 0.6 * 4)
|
.. "image_button[" .. (start_x + 0.6 * 4)
|
||||||
.. ",9;.8,.8;ui_doubleright_icon.png;forward3;]"
|
.. ",9;.8,.8;ui_doubleright_icon.png;forward3;]"
|
||||||
.. "tooltip[forward3;" .. minetest.formspec_escape(S("Forward three pages")) .. "]"
|
.. "tooltip[forward3;" .. minetest.formspec_escape(S("Forward three pages")) .. "]"
|
||||||
@ -85,43 +101,71 @@ function unified_inventory.get_formspec(player, page)
|
|||||||
.. "image_button[" .. (start_x + 0.6 * 5)
|
.. "image_button[" .. (start_x + 0.6 * 5)
|
||||||
.. ",9;.8,.8;ui_skip_forward_icon.png;end_list;]"
|
.. ",9;.8,.8;ui_skip_forward_icon.png;end_list;]"
|
||||||
.. "tooltip[end_list;" .. minetest.formspec_escape(S("Last page")) .. "]"
|
.. "tooltip[end_list;" .. minetest.formspec_escape(S("Last page")) .. "]"
|
||||||
|
else
|
||||||
|
formspec = formspec
|
||||||
|
.. "image_button[" .. (8.2 + 0.65 * 0)
|
||||||
|
.. ",5.8;.8,.8;ui_skip_backward_icon.png;start_list;]"
|
||||||
|
.. "tooltip[start_list;" .. minetest.formspec_escape(S("First page")) .. "]"
|
||||||
|
.. "image_button[" .. (8.2 + 0.65 * 1)
|
||||||
|
.. ",5.8;.8,.8;ui_left_icon.png;rewind1;]"
|
||||||
|
.. "tooltip[rewind1;" .. minetest.formspec_escape(S("Back one page")) .. "]"
|
||||||
|
.. "image_button[" .. (8.2 + 0.65 * 2)
|
||||||
|
.. ",5.8;.8,.8;ui_right_icon.png;forward1;]"
|
||||||
|
.. "tooltip[forward1;" .. minetest.formspec_escape(S("Forward one page")) .. "]"
|
||||||
|
.. "image_button[" .. (8.2 + 0.65 * 3)
|
||||||
|
.. ",5.8;.8,.8;ui_skip_forward_icon.png;end_list;]"
|
||||||
|
.. "tooltip[end_list;" .. minetest.formspec_escape(S("Last page")) .. "]"
|
||||||
|
end
|
||||||
|
|
||||||
-- Search box
|
-- Search box
|
||||||
|
|
||||||
|
if not unified_inventory.lite_mode then
|
||||||
formspec = formspec .. "field[9.5,8.325;3,1;searchbox;;"
|
formspec = formspec .. "field[9.5,8.325;3,1;searchbox;;"
|
||||||
.. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]"
|
.. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]"
|
||||||
formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]"
|
formspec = formspec .. "image_button[12.2,8.1;.8,.8;ui_search_icon.png;searchbutton;]"
|
||||||
.. "tooltip[searchbutton;" ..S("Search") .. "]"
|
.. "tooltip[searchbutton;" ..S("Search") .. "]"
|
||||||
|
else
|
||||||
|
formspec = formspec .. "field[8.5,5.225;2.2,1;searchbox;;"
|
||||||
|
.. minetest.formspec_escape(unified_inventory.current_searchbox[player_name]) .. "]"
|
||||||
|
formspec = formspec .. "image_button[10.3,5;.8,.8;ui_search_icon.png;searchbutton;]"
|
||||||
|
.. "tooltip[searchbutton;" ..S("Search") .. "]"
|
||||||
|
end
|
||||||
|
|
||||||
|
local no_matches = "No matching items"
|
||||||
|
if unified_inventory.lite_mode then
|
||||||
|
no_matches = "No matches."
|
||||||
|
end
|
||||||
|
|
||||||
-- Items list
|
-- Items list
|
||||||
if #unified_inventory.filtered_items_list[player_name] == 0 then
|
if #unified_inventory.filtered_items_list[player_name] == 0 then
|
||||||
formspec = formspec.."label[8.2,0;" .. S("No matching items") .. "]"
|
formspec = formspec.."label[8.2,"..unified_inventory.form_header_y..";" .. S(no_matches) .. "]"
|
||||||
else
|
else
|
||||||
local dir = unified_inventory.active_search_direction[player_name]
|
local dir = unified_inventory.active_search_direction[player_name]
|
||||||
local list_index = unified_inventory.current_index[player_name]
|
local list_index = unified_inventory.current_index[player_name]
|
||||||
local page = math.floor(list_index / (80) + 1)
|
local page = math.floor(list_index / (unified_inventory.items_per_page) + 1)
|
||||||
local pagemax = math.floor(
|
local pagemax = math.floor(
|
||||||
(#unified_inventory.filtered_items_list[player_name] - 1)
|
(#unified_inventory.filtered_items_list[player_name] - 1)
|
||||||
/ (80) + 1)
|
/ (unified_inventory.items_per_page) + 1)
|
||||||
local item = {}
|
local item = {}
|
||||||
for y = 0, 9 do
|
for y = 0, unified_inventory.pagerows - 1 do
|
||||||
for x = 0, 7 do
|
for x = 0, unified_inventory.pagecols - 1 do
|
||||||
local name = unified_inventory.filtered_items_list[player_name][list_index]
|
local name = unified_inventory.filtered_items_list[player_name][list_index]
|
||||||
if minetest.registered_items[name] then
|
if minetest.registered_items[name] then
|
||||||
formspec = formspec.."item_image_button["
|
formspec = formspec.."item_image_button["
|
||||||
..(8.2 + x * 0.7)..","
|
..(8.2 + x * 0.7)..","
|
||||||
..(1 + y * 0.7)..";.81,.81;"
|
..(unified_inventory.formspec_y + unified_inventory.page_y + y * 0.7)..";.81,.81;"
|
||||||
..name..";item_button_"..dir.."_"
|
..name..";item_button_"..dir.."_"
|
||||||
..unified_inventory.mangle_for_formspec(name)..";]"
|
..unified_inventory.mangle_for_formspec(name)..";]"
|
||||||
list_index = list_index + 1
|
list_index = list_index + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
formspec = formspec.."label[8.2,0;"..S("Page") .. ": "
|
formspec = formspec.."label[8.2,"..unified_inventory.form_header_y..";"..S("Page") .. ": "
|
||||||
.. S("%s of %s"):format(page,pagemax).."]"
|
.. S("%s of %s"):format(page,pagemax).."]"
|
||||||
end
|
end
|
||||||
if unified_inventory.activefilter[player_name] ~= "" then
|
if unified_inventory.activefilter[player_name] ~= "" then
|
||||||
formspec = formspec.."label[8.2,0.4;" .. S("Filter") .. ":]"
|
formspec = formspec.."label[8.2,"..(unified_inventory.form_header_y + 0.4)..";" .. S("Filter") .. ":]"
|
||||||
formspec = formspec.."label[9,0.4;"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]"
|
formspec = formspec.."label[9.1,"..(unified_inventory.form_header_y + 0.4)..";"..minetest.formspec_escape(unified_inventory.activefilter[player_name]).."]"
|
||||||
end
|
end
|
||||||
return formspec
|
return formspec
|
||||||
end
|
end
|
||||||
|
81
register.lua
81
register.lua
@ -33,6 +33,7 @@ unified_inventory.register_button("craftguide", {
|
|||||||
tooltip = S("Crafting Guide")
|
tooltip = S("Crafting Guide")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if not unified_inventory.lite_mode then
|
||||||
unified_inventory.register_button("home_gui_set", {
|
unified_inventory.register_button("home_gui_set", {
|
||||||
type = "image",
|
type = "image",
|
||||||
image = "ui_sethome_icon.png",
|
image = "ui_sethome_icon.png",
|
||||||
@ -98,6 +99,7 @@ unified_inventory.register_button("misc_set_night", {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
unified_inventory.register_button("clear_inv", {
|
unified_inventory.register_button("clear_inv", {
|
||||||
type = "image",
|
type = "image",
|
||||||
@ -123,23 +125,22 @@ unified_inventory.register_button("clear_inv", {
|
|||||||
unified_inventory.register_page("craft", {
|
unified_inventory.register_page("craft", {
|
||||||
get_formspec = function(player, formspec)
|
get_formspec = function(player, formspec)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local formspec = "background[0,1;8,3;ui_crafting_form.png]"
|
local formspec = "background[0,"..unified_inventory.formspec_y..";8,3;ui_crafting_form.png]"
|
||||||
formspec = formspec.."background[0,4.5;8,4;ui_main_inventory.png]"
|
formspec = formspec.."background[0,"..(unified_inventory.formspec_y + 3.5)..";8,4;ui_main_inventory.png]"
|
||||||
formspec = formspec.."label[0,0;Crafting]"
|
formspec = formspec.."label[0,"..unified_inventory.form_header_y..";Crafting]"
|
||||||
formspec = formspec.."listcolors[#00000000;#00000000]"
|
formspec = formspec.."listcolors[#00000000;#00000000]"
|
||||||
formspec = formspec.."list[current_player;craftpreview;6,1;1,1;]"
|
formspec = formspec.."list[current_player;craftpreview;6,"..unified_inventory.formspec_y..";1,1;]"
|
||||||
formspec = formspec.."list[current_player;craft;2,1;3,3;]"
|
formspec = formspec.."list[current_player;craft;2,"..unified_inventory.formspec_y..";3,3;]"
|
||||||
formspec = formspec.."label[7,2.5;" .. S("Trash:") .. "]"
|
formspec = formspec.."label[7,"..(unified_inventory.formspec_y + 1.5)..";" .. S("Trash:") .. "]"
|
||||||
formspec = formspec.."list[detached:trash;main;7,3;1,1;]"
|
formspec = formspec.."list[detached:trash;main;7,"..(unified_inventory.formspec_y + 2)..";1,1;]"
|
||||||
if unified_inventory.is_creative(player_name) then
|
if unified_inventory.is_creative(player_name) then
|
||||||
formspec = formspec.."label[0,2.5;" .. S("Refill:") .. "]"
|
formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 1.5)..";" .. S("Refill:") .. "]"
|
||||||
formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,3;1,1;]"
|
formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."refill;main;0,"..(unified_inventory.formspec_y +2)..";1,1;]"
|
||||||
end
|
end
|
||||||
return {formspec=formspec}
|
return {formspec=formspec}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- stack_image_button(): generate a form button displaying a stack of items
|
-- stack_image_button(): generate a form button displaying a stack of items
|
||||||
--
|
--
|
||||||
-- Normally a simple item_image_button[] is used. If the stack contains
|
-- Normally a simple item_image_button[] is used. If the stack contains
|
||||||
@ -167,7 +168,7 @@ local function stack_image_button(x, y, w, h, buttonname_prefix, item)
|
|||||||
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" or " ", count):gsub(" 1$", " .")
|
||||||
if label == "\n\n ." then label = "" end
|
if label == "\n\n ." then label = "" end
|
||||||
return string.format("item_image_button[%u,%u;%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,
|
||||||
minetest.formspec_escape(displayitem),
|
minetest.formspec_escape(displayitem),
|
||||||
minetest.formspec_escape(buttonname_prefix..unified_inventory.mangle_for_formspec(selectitem)),
|
minetest.formspec_escape(buttonname_prefix..unified_inventory.mangle_for_formspec(selectitem)),
|
||||||
@ -196,8 +197,8 @@ unified_inventory.register_page("craftguide", {
|
|||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local player_privs = minetest.get_player_privs(player_name)
|
local player_privs = minetest.get_player_privs(player_name)
|
||||||
local formspec = ""
|
local formspec = ""
|
||||||
formspec = formspec.."background[0,4.5;8,4;ui_main_inventory.png]"
|
formspec = formspec.."background[0,"..(unified_inventory.formspec_y + 3.5)..";8,4;ui_main_inventory.png]"
|
||||||
formspec = formspec.."label[0,0;" .. S("Crafting Guide") .. "]"
|
formspec = formspec.."label[0,"..unified_inventory.form_header_y..";" .. S("Crafting Guide") .. "]"
|
||||||
formspec = formspec.."listcolors[#00000000;#00000000]"
|
formspec = formspec.."listcolors[#00000000;#00000000]"
|
||||||
local item_name = unified_inventory.current_item[player_name]
|
local item_name = unified_inventory.current_item[player_name]
|
||||||
if not item_name then return {formspec=formspec} end
|
if not item_name then return {formspec=formspec} end
|
||||||
@ -214,21 +215,25 @@ unified_inventory.register_page("craftguide", {
|
|||||||
craft = crafts[alternate]
|
craft = crafts[alternate]
|
||||||
end
|
end
|
||||||
|
|
||||||
formspec = formspec.."background[0,1;8,3;ui_craftguide_form.png]"
|
formspec = formspec.."background[0,"..unified_inventory.formspec_y..";8,3;ui_craftguide_form.png]"
|
||||||
formspec = formspec.."textarea[0.3,0.6;10,1;;"..minetest.formspec_escape(role_text[dir]..": "..item_name)..";]"
|
formspec = formspec.."textarea["..unified_inventory.craft_result_x..","..unified_inventory.craft_result_y
|
||||||
formspec = formspec..stack_image_button(0, 1, 1.1, 1.1, "item_button_" .. rdir .. "_", ItemStack(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_"
|
||||||
|
.. rdir .. "_", ItemStack(item_name))
|
||||||
|
|
||||||
if not craft then
|
if not craft then
|
||||||
formspec = formspec.."label[6,3.35;"..minetest.formspec_escape(no_recipe_text[dir]).."]"
|
formspec = formspec.."label[6,"..(unified_inventory.formspec_y + 2.35)..";"
|
||||||
|
..minetest.formspec_escape(no_recipe_text[dir]).."]"
|
||||||
local no_pos = dir == "recipe" and 4 or 6
|
local no_pos = dir == "recipe" and 4 or 6
|
||||||
local item_pos = dir == "recipe" and 6 or 4
|
local item_pos = dir == "recipe" and 6 or 4
|
||||||
formspec = formspec.."image["..no_pos..",1;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, 1, 1.1, 1.1, "item_button_"..other_dir[dir].."_", ItemStack(item_name))
|
formspec = formspec..stack_image_button(item_pos, unified_inventory.formspec_y, 1.1, 1.1, "item_button_"
|
||||||
|
..other_dir[dir].."_", ItemStack(item_name))
|
||||||
if player_privs.give == true then
|
if player_privs.give == true then
|
||||||
formspec = formspec.."label[0,3.10;" .. S("Give me:") .. "]"
|
formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 2.10)..";" .. S("Give me:") .. "]"
|
||||||
.."button[0, 3.70;0.6,0.5;craftguide_giveme_1;1]"
|
.."button[0, "..(unified_inventory.formspec_y + 2.7)..";0.6,0.5;craftguide_giveme_1;1]"
|
||||||
.."button[0.6,3.70;0.7,0.5;craftguide_giveme_10;10]"
|
.."button[0.6,"..(unified_inventory.formspec_y + 2.7)..";0.7,0.5;craftguide_giveme_10;10]"
|
||||||
.."button[1.3,3.70;0.8,0.5;craftguide_giveme_99;99]"
|
.."button[1.3,"..(unified_inventory.formspec_y + 2.7)..";0.8,0.5;craftguide_giveme_99;99]"
|
||||||
end
|
end
|
||||||
return {formspec = formspec}
|
return {formspec = formspec}
|
||||||
end
|
end
|
||||||
@ -236,10 +241,10 @@ 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,0.85,0.5,0.5,craft_type.icon)
|
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)
|
||||||
end
|
end
|
||||||
formspec = formspec.."label[5,1.50;" .. minetest.formspec_escape(craft_type.description).."]"
|
formspec = formspec.."label[5,"..(unified_inventory.formspec_y + 0.5)..";" .. minetest.formspec_escape(craft_type.description).."]"
|
||||||
formspec = formspec..stack_image_button(6, 1, 1.1, 1.1, "item_button_usage_", ItemStack(craft.output))
|
formspec = formspec..stack_image_button(6, 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
|
||||||
|
|
||||||
@ -254,36 +259,36 @@ unified_inventory.register_page("craftguide", {
|
|||||||
end
|
end
|
||||||
if item then
|
if item then
|
||||||
formspec = formspec..stack_image_button(
|
formspec = formspec..stack_image_button(
|
||||||
xoffset + x, y, 1.1, 1.1,
|
xoffset + x, unified_inventory.formspec_y - 1 + y, 1.1, 1.1,
|
||||||
"item_button_recipe_",
|
"item_button_recipe_",
|
||||||
ItemStack(item))
|
ItemStack(item))
|
||||||
else
|
else
|
||||||
-- Fake buttons just to make grid
|
-- Fake buttons just to make grid
|
||||||
formspec = formspec.."image_button["
|
formspec = formspec.."image_button["
|
||||||
..tostring(xoffset + x)..","..tostring(y)
|
..tostring(xoffset + x)..","..tostring(unified_inventory.formspec_y - 1 + y)
|
||||||
..";1,1;ui_blank_image.png;;]"
|
..";1,1;ui_blank_image.png;;]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if craft_type.uses_crafting_grid then
|
if craft_type.uses_crafting_grid then
|
||||||
formspec = formspec.."label[0,1.90;" .. S("To craft grid:") .. "]"
|
formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 0.9)..";" .. S("To craft grid:") .. "]"
|
||||||
.."button[0, 2.5;0.6,0.5;craftguide_craft_1;1]"
|
.."button[0, "..(unified_inventory.formspec_y + 1.5)..";0.6,0.5;craftguide_craft_1;1]"
|
||||||
.."button[0.6,2.5;0.7,0.5;craftguide_craft_10;10]"
|
.."button[0.6,"..(unified_inventory.formspec_y + 1.5)..";0.7,0.5;craftguide_craft_10;10]"
|
||||||
.."button[1.3,2.5;0.8,0.5;craftguide_craft_max;" .. S("All") .. "]"
|
.."button[1.3,"..(unified_inventory.formspec_y + 1.5)..";0.8,0.5;craftguide_craft_max;" .. S("All") .. "]"
|
||||||
end
|
end
|
||||||
if player_privs.give then
|
if player_privs.give then
|
||||||
formspec = formspec.."label[0,3.10;" .. S("Give me:") .. "]"
|
formspec = formspec.."label[0,"..(unified_inventory.formspec_y + 2.1)..";" .. S("Give me:") .. "]"
|
||||||
.."button[0, 3.70;0.6,0.5;craftguide_giveme_1;1]"
|
.."button[0, "..(unified_inventory.formspec_y + 2.7)..";0.6,0.5;craftguide_giveme_1;1]"
|
||||||
.."button[0.6,3.70;0.7,0.5;craftguide_giveme_10;10]"
|
.."button[0.6,"..(unified_inventory.formspec_y + 2.7)..";0.7,0.5;craftguide_giveme_10;10]"
|
||||||
.."button[1.3,3.70;0.8,0.5;craftguide_giveme_99;99]"
|
.."button[1.3,"..(unified_inventory.formspec_y + 2.7)..";0.8,0.5;craftguide_giveme_99;99]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if alternates and alternates > 1 then
|
if alternates and alternates > 1 then
|
||||||
formspec = formspec.."label[6,1.95;"..recipe_text[dir].." "
|
formspec = formspec.."label[6,"..(unified_inventory.formspec_y + 0.95)..";"..recipe_text[dir].." "
|
||||||
..tostring(alternate).." of "
|
..tostring(alternate).." of "
|
||||||
..tostring(alternates).."]"
|
..tostring(alternates).."]"
|
||||||
.."button[6,2.3;2,1;alternate;" .. S("Alternate") .. "]"
|
.."button[6,"..(unified_inventory.formspec_y + 1.3)..";2,1;alternate;" .. S("Alternate") .. "]"
|
||||||
end
|
end
|
||||||
return {formspec = formspec}
|
return {formspec = formspec}
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user