Skip to content

Commit

Permalink
GUI: Use nicer picture to indicate unknown nodes (-> no search results)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Mar 11, 2017
1 parent e49f717 commit c0f3bb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions worldedit_gui/functionality.lua
Expand Up @@ -40,7 +40,7 @@ local angle_values = {90, 180, 270}
setmetatable(angle_indices, {__index = function () return 1 end})
setmetatable(angle_values, {__index = function () return 90 end})

--given multiple sets of privileges, produces a single set of privs that would have the same effect as requiring all of them at the same time
-- given multiple sets of privileges, produces a single set of privs that would have the same effect as requiring all of them at the same time
local combine_privs = function(...)
local result = {}
for i, privs in ipairs({...}) do
Expand All @@ -54,6 +54,12 @@ local combine_privs = function(...)
return result
end

-- display node (or unknown_node image otherwise) at specified pos in formspec
local formspec_node = function(pos, nodename)
return nodename and string.format("item_image[%s;1,1;%s]", pos, nodename)
or string.format("image[%s;1,1;worldedit_gui_unknown.png]", pos)
end

worldedit.register_gui_function("worldedit_gui_about", {
name = "About", privs = minetest.chatcommands["/about"].privs,
on_select = function(name)
Expand Down Expand Up @@ -155,8 +161,7 @@ worldedit.register_gui_function("worldedit_gui_set", {
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_set") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_set_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_set_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
"button_exit[0,2.5;3,0.8;worldedit_gui_set_submit;Set Nodes]"
end,
})
Expand Down Expand Up @@ -184,12 +189,10 @@ worldedit.register_gui_function("worldedit_gui_replace", {
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_replace") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_replace_search;Name;%s]", minetest.formspec_escape(search)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_replace_search_search;Search]" ..
(search_nodename and string.format("item_image[5.5,1.1;1,1;%s]", search_nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", search_nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_replace_replace;Name;%s]", minetest.formspec_escape(replace)) ..
"button[4,2.18;1.5,0.8;worldedit_gui_replace_replace_search;Search]" ..
(replace_nodename and string.format("item_image[5.5,2.1;1,1;%s]", replace_nodename)
or "image[5.5,2.1;1,1;unknown_node.png]") ..
formspec_node("5.5,2.1", replace_nodename) ..
"button_exit[0,3.5;3,0.8;worldedit_gui_replace_submit;Replace Nodes]" ..
"button_exit[3.5,3.5;3,0.8;worldedit_gui_replace_submit_inverse;Replace Inverse]"
end,
Expand Down Expand Up @@ -228,8 +231,7 @@ worldedit.register_gui_function("worldedit_gui_sphere_dome", {
return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_sphere_dome") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_sphere_dome_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_sphere_dome_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_sphere_dome_radius;Radius;%s]", minetest.formspec_escape(radius)) ..
"button_exit[0,3.5;3,0.8;worldedit_gui_sphere_dome_submit_hollow;Hollow Sphere]" ..
"button_exit[3.5,3.5;3,0.8;worldedit_gui_sphere_dome_submit_solid;Solid Sphere]" ..
Expand Down Expand Up @@ -275,8 +277,7 @@ worldedit.register_gui_function("worldedit_gui_cylinder", {
return "size[6.5,5]" .. worldedit.get_formspec_header("worldedit_gui_cylinder") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_cylinder_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_cylinder_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_cylinder_length;Length;%s]", minetest.formspec_escape(length)) ..
string.format("dropdown[4,2.18;2.5;worldedit_gui_cylinder_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
string.format("field[0.5,3.5;4,0.8;worldedit_gui_cylinder_radius;Radius;%s]", minetest.formspec_escape(radius)) ..
Expand Down Expand Up @@ -324,8 +325,7 @@ worldedit.register_gui_function("worldedit_gui_pyramid", {
return "size[6.5,4]" .. worldedit.get_formspec_header("worldedit_gui_pyramid") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_pyramid_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_pyramid_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_pyramid_length;Length;%s]", minetest.formspec_escape(length)) ..
string.format("dropdown[4,2.18;2.5;worldedit_gui_pyramid_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) ..
"button_exit[0,3.5;3,0.8;worldedit_gui_pyramid_submit_hollow;Hollow Pyramid]" ..
Expand Down Expand Up @@ -370,8 +370,7 @@ worldedit.register_gui_function("worldedit_gui_spiral", {
return "size[6.5,6]" .. worldedit.get_formspec_header("worldedit_gui_spiral") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_spiral_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_spiral_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
string.format("field[0.5,2.5;4,0.8;worldedit_gui_spiral_length;Side Length;%s]", minetest.formspec_escape(length)) ..
string.format("field[0.5,3.5;4,0.8;worldedit_gui_spiral_height;Height;%s]", minetest.formspec_escape(height)) ..
string.format("field[0.5,4.5;4,0.8;worldedit_gui_spiral_space;Wall Spacing;%s]", minetest.formspec_escape(space)) ..
Expand Down Expand Up @@ -616,8 +615,7 @@ worldedit.register_gui_function("worldedit_gui_suppress", {
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_suppress") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_suppress_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_suppress_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
"button_exit[0,2.5;3,0.8;worldedit_gui_suppress_submit;Suppress Nodes]"
end,
})
Expand Down Expand Up @@ -645,8 +643,7 @@ worldedit.register_gui_function("worldedit_gui_highlight", {
return "size[6.5,3]" .. worldedit.get_formspec_header("worldedit_gui_highlight") ..
string.format("field[0.5,1.5;4,0.8;worldedit_gui_highlight_node;Name;%s]", minetest.formspec_escape(node)) ..
"button[4,1.18;1.5,0.8;worldedit_gui_highlight_search;Search]" ..
(nodename and string.format("item_image[5.5,1.1;1,1;%s]", nodename)
or "image[5.5,1.1;1,1;unknown_node.png]") ..
formspec_node("5.5,1.1", nodename) ..
"button_exit[0,2.5;3,0.8;worldedit_gui_highlight_submit;Highlight Nodes]"
end,
})
Expand Down
Binary file added worldedit_gui/textures/worldedit_gui_unknown.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c0f3bb6

Please sign in to comment.