diff options
| author | sfan5 <sfan5@live.de> | 2017-03-11 12:24:47 +0100 | 
|---|---|---|
| committer | sfan5 <sfan5@live.de> | 2017-03-11 12:24:47 +0100 | 
| commit | c0f3bb695865c46738bee71efafd80851d83f81e (patch) | |
| tree | 4164b4c476bfa36a9d9826790c7a59086f9d32ef | |
| parent | e49f7170003d6d296ee754b81ca9e6c3664c1cb1 (diff) | |
GUI: Use nicer picture to indicate unknown nodes (-> no search results)
| -rw-r--r-- | worldedit_gui/functionality.lua | 35 | ||||
| -rw-r--r-- | worldedit_gui/textures/worldedit_gui_unknown.png | bin | 0 -> 597 bytes | 
2 files changed, 16 insertions, 19 deletions
| diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua index 7282ae9..5cbf8fa 100644 --- a/worldedit_gui/functionality.lua +++ b/worldedit_gui/functionality.lua @@ -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
 @@ -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)
 @@ -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,
  })
 @@ -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,
 @@ -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]" ..
 @@ -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)) ..
 @@ -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]" ..
 @@ -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)) ..
 @@ -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,
  })
 @@ -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,
  })
 diff --git a/worldedit_gui/textures/worldedit_gui_unknown.png b/worldedit_gui/textures/worldedit_gui_unknown.pngBinary files differ new file mode 100644 index 0000000..f57436c --- /dev/null +++ b/worldedit_gui/textures/worldedit_gui_unknown.png | 
