Table UI adjustments
This commit is contained in:
parent
8f0e161b7c
commit
8ccf1afbb6
60
table.lua
60
table.lua
@ -215,17 +215,23 @@ end
|
|||||||
-- Draw a label with material costs from a table
|
-- Draw a label with material costs from a table
|
||||||
-- x: The x position of the interface
|
-- x: The x position of the interface
|
||||||
-- y: The y position of the interface
|
-- y: The y position of the interface
|
||||||
-- materials: A table of material costs, with string keys for the material
|
-- cost: A table of material costs, with string keys for the material
|
||||||
-- names and iteger values
|
-- names and iteger values
|
||||||
-- skin: A formspec skin table
|
-- skin: A formspec skin table
|
||||||
--
|
--
|
||||||
-- Returns a formspec string
|
-- Returns a formspec string
|
||||||
function fs.cost(x, y, materials, skin)
|
function fs.cost(x, y, cost, skin)
|
||||||
local data = "";
|
local data = string.format("background9[%f,%f;1,0.5;%s.png;false;%s]", x, y - 0.125, skin.label.texture, tostring(skin.label.radius));
|
||||||
local i = 0;
|
local i = 0;
|
||||||
|
|
||||||
for name,value in pairs(materials) do
|
for name,value in pairs(cost) do
|
||||||
data = data .. string.format("label[%f,%f;%s%s x %d]", x, y + (i * 0.25), minetest.get_color_escape_sequence(skin.label.font_color), name, value);
|
if name == "paper" then
|
||||||
|
data = data .. string.format("image[%f,%f;0.25,0.25;%s.png]", x + 0.125, y + (i * 0.25) - 0.125, skin.paper_texture)
|
||||||
|
elseif name == "pigment" then
|
||||||
|
data = data .. string.format("image[%f,%f;0.25,0.25;%s.png]", x + 0.125, y + (i * 0.25) - 0.125, skin.pigment_texture)
|
||||||
|
end
|
||||||
|
|
||||||
|
data = data .. string.format("label[%f,%f;%sx %d]", x + 0.375, y + (i * 0.25), minetest.get_color_escape_sequence(skin.label.font_color), value);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -247,8 +253,9 @@ function fs.convert(x, y, pos, skin)
|
|||||||
.. "formspec_version[3]"
|
.. "formspec_version[3]"
|
||||||
.. inventory_bg(0, 0, 1, 1, skin.slot)
|
.. inventory_bg(0, 0, 1, 1, skin.slot)
|
||||||
.. string.format("list[nodemeta:%d,%d,%d;input;0,0;1,1;]", pos.x, pos.y, pos.z)
|
.. string.format("list[nodemeta:%d,%d,%d;input;0,0;1,1;]", pos.x, pos.y, pos.z)
|
||||||
.. fs.button(1.25, 0.5, 2, 0.5, "convert", "Convert Materials", value.paper + value.pigment > 0)
|
.. "tooltip[0,0;1,1;Place items here to convert\nthem into mapmaking materials]"
|
||||||
.. fs.cost(1.25, 0.125, value, skin)
|
.. fs.button(2.5, 0.25, 2, 0.5, "convert", "Convert Materials", value.paper + value.pigment > 0)
|
||||||
|
.. fs.cost(1.25, 0.375, value, skin)
|
||||||
.. "container_end[]";
|
.. "container_end[]";
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -265,29 +272,32 @@ function fs.craft(x, y, pos, rank, meta, skin)
|
|||||||
local cost, is_positive = get_craft_material_cost(meta);
|
local cost, is_positive = get_craft_material_cost(meta);
|
||||||
local data = string.format("container[%f,%f]", x, y)
|
local data = string.format("container[%f,%f]", x, y)
|
||||||
.. "formspec_version[3]"
|
.. "formspec_version[3]"
|
||||||
.. inventory_bg(0, 0.75, 1, 1, skin.slot)
|
.. inventory_bg(0, 1, 1, 1, skin.slot)
|
||||||
.. string.format("list[nodemeta:%d,%d,%d;output;0,0.75;1,1;]", pos.x, pos.y, pos.z)
|
.. string.format("list[nodemeta:%d,%d,%d;output;0,1;1,1;]", pos.x, pos.y, pos.z)
|
||||||
.. fs.button(1.25, 1.25, 2, 0.5, "craft", "Craft Map", is_positive and can_afford(cost, meta))
|
.. "tooltip[0,1;1,1;Place a map here to upgrade it,\nor leave empty to craft]"
|
||||||
.. fs.cost(1.25, 0.875, cost, skin);
|
.. fs.button(2.5, 1.25, 2, 0.5, "craft", "Craft Map", is_positive and can_afford(cost, meta))
|
||||||
|
.. fs.cost(1.25, 1.375, cost, skin);
|
||||||
|
|
||||||
if rank > 1 then
|
if rank > 1 then
|
||||||
data = data .. string.format("style[%dx;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png]", meta:get_int("scale"), skin.button.selected_texture, skin.button.selected_texture, skin.button.selected_texture)
|
data = data .. string.format("style[%dx;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png]", meta:get_int("scale"), skin.button.selected_texture, skin.button.selected_texture, skin.button.selected_texture)
|
||||||
.. "button[2.5,0;0.5,0.5;1x;1x]"
|
.. string.format("label[2.5,0;%sMap Scale]", minetest.get_color_escape_sequence(skin.label.font_color))
|
||||||
.. "button[3.0,0;0.5,0.5;2x;2x]";
|
.. "button[2.5,0.25;0.5,0.5;1x;1x]"
|
||||||
|
.. "button[3.0,0.25;0.5,0.5;2x;2x]";
|
||||||
|
|
||||||
if rank > 2 then
|
if rank > 2 then
|
||||||
data = data .. "button[3.5,0;0.5,0.5;4x;4x]"
|
data = data .. "button[3.5,0.25;0.5,0.5;4x;4x]"
|
||||||
.. "button[4.0,0;0.5,0.5;8x;8x]";
|
.. "button[4.0,0.25;0.5,0.5;8x;8x]";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
data = data .. string.format("style[%d;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png]", meta:get_int("detail") + 1, skin.button.selected_texture, skin.button.selected_texture, skin.button.selected_texture)
|
data = data .. string.format("style[%d;bgimg=%s.png;bgimg_hovered=%s.png;bgimg_pressed=%s.png]", meta:get_int("detail") + 1, skin.button.selected_texture, skin.button.selected_texture, skin.button.selected_texture)
|
||||||
.. "button[0.0,0;0.5,0.5;1;1]"
|
.. string.format("label[0,0;%sDetail Level]", minetest.get_color_escape_sequence(skin.label.font_color))
|
||||||
.. "button[0.5,0;0.5,0.5;2;2]";
|
.. "button[0.0,0.25;0.5,0.5;1;1]"
|
||||||
|
.. "button[0.5,0.25;0.5,0.5;2;2]";
|
||||||
if rank > 1 then
|
if rank > 1 then
|
||||||
data = data .. "button[1.0,0;0.5,0.5;3;3]";
|
data = data .. "button[1.0,0.25;0.5,0.5;3;3]";
|
||||||
if rank > 2 then
|
if rank > 2 then
|
||||||
data = data .. "button[1.5,0;0.5,0.5;4;4]";
|
data = data .. "button[1.5,0.25;0.5,0.5;4;4]";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -309,8 +319,8 @@ function fs.copy(x, y, pos, skin)
|
|||||||
.. "formspec_version[3]"
|
.. "formspec_version[3]"
|
||||||
.. inventory_bg(0, 0, 1, 1, skin.slot)
|
.. inventory_bg(0, 0, 1, 1, skin.slot)
|
||||||
.. string.format("list[nodemeta:%d,%d,%d;copy_input;0,0;1,1;]", pos.x, pos.y, pos.z)
|
.. string.format("list[nodemeta:%d,%d,%d;copy_input;0,0;1,1;]", pos.x, pos.y, pos.z)
|
||||||
.. fs.button(1.25, 0.5, 2, 0.5, "copy", "Copy Map", can_afford(costs, meta))
|
.. fs.button(2.5, 0.25, 2, 0.5, "copy", "Copy Map", can_afford(costs, meta))
|
||||||
.. fs.cost(1.25, 0.125, costs, skin)
|
.. fs.cost(1.25, 0.375, costs, skin)
|
||||||
.. inventory_bg(8.75, 0, 1, 1, skin.slot)
|
.. inventory_bg(8.75, 0, 1, 1, skin.slot)
|
||||||
.. string.format("list[nodemeta:%d,%d,%d;copy_output;8.75,0;1,1;]", pos.x, pos.y, pos.z)
|
.. string.format("list[nodemeta:%d,%d,%d;copy_output;8.75,0;1,1;]", pos.x, pos.y, pos.z)
|
||||||
.. "container_end[]";
|
.. "container_end[]";
|
||||||
@ -369,12 +379,12 @@ local function table_formspec(player)
|
|||||||
);
|
);
|
||||||
elseif data.tab == 2 then
|
elseif data.tab == 2 then
|
||||||
minetest.show_formspec(player, "simple_table",
|
minetest.show_formspec(player, "simple_table",
|
||||||
fs.header(10.25, 8.0, rank, data.tab, skin) ..
|
fs.header(10.25, 8.25, rank, data.tab, skin) ..
|
||||||
fs.materials(0.25, 0.1875, meta, skin) ..
|
fs.materials(0.25, 0.1875, meta, skin) ..
|
||||||
fs.separator(0.6875, skin.separator) ..
|
fs.separator(0.6875, skin.separator) ..
|
||||||
fs.craft(0.25, 0.875, pos, rank, meta, skin) ..
|
fs.craft(0.25, 0.875, pos, rank, meta, skin) ..
|
||||||
fs.separator(2.75, skin.separator) ..
|
fs.separator(3, skin.separator) ..
|
||||||
fs.inv(0.25, 3, skin)
|
fs.inv(0.25, 3.25, skin)
|
||||||
);
|
);
|
||||||
elseif data.tab == 3 then
|
elseif data.tab == 3 then
|
||||||
minetest.show_formspec(player, "simple_table",
|
minetest.show_formspec(player, "simple_table",
|
||||||
|
Loading…
Reference in New Issue
Block a user