summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2014-06-13 12:35:12 +0100
committerDiego Martinez <kaeza@users.sf.net>2014-06-13 09:28:40 -0300
commitc33efe86316342c491267c5f5d8b8fa2cdc58747 (patch)
tree1a49f781b56e81ce0552fa2e3ac5f226b2061745
parent4c982dd667828888958116cf13dbd868d374555c (diff)
Cleaner display of lack of recipes (redux)
When the current craft guide item has no recipes, show a "no" symbol instead of an ingredient grid, alongside the "No recipes" message. When no item is selected in the craft guide, leave the recipe space empty.
-rw-r--r--register.lua28
-rw-r--r--textures/ui_no.pngbin0 -> 7525 bytes
2 files changed, 15 insertions, 13 deletions
diff --git a/register.lua b/register.lua
index 5fcd5fc..3815f05 100644
--- a/register.lua
+++ b/register.lua
@@ -174,17 +174,18 @@ unified_inventory.register_page("craftguide", {
local player_name = player:get_player_name()
local formspec = ""
formspec = formspec.."background[0,4.5;8,4;ui_main_inventory.png]"
- formspec = formspec.."background[0,1;8,3;ui_craftguide_form.png]"
formspec = formspec.."label[0,0;Crafting Guide]"
formspec = formspec.."listcolors[#00000000;#00000000]"
+ local item_name = unified_inventory.current_item[player_name]
+ if not item_name then return {formspec=formspec} end
+
+ formspec = formspec.."background[0,1;8,3;ui_craftguide_form.png]"
+ formspec = formspec.."textarea[0.3,0.6;10,1;;Result: "..minetest.formspec_escape(item_name)..";]"
+ formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."craftrecipe;output;6,1;1,1;]"
local craftinv = minetest.get_inventory({
type = "detached",
name = player_name.."craftrecipe"
})
- local item_name = unified_inventory.current_item[player_name] or ""
-
- formspec = formspec.."textarea[0.3,0.6;10,1;;Result: "..minetest.formspec_escape(item_name)..";]"
- formspec = formspec.."list[detached:"..minetest.formspec_escape(player_name).."craftrecipe;output;6,1;1,1;]"
local alternate, alternates, craft, craft_type
alternate = unified_inventory.alternate[player_name]
@@ -194,19 +195,20 @@ unified_inventory.register_page("craftguide", {
craft = crafts[alternate]
end
- if craft then
- craftinv:set_stack("output", 1, craft.output)
- craft_type = unified_inventory.registered_craft_types[craft.type] or
- unified_inventory.craft_type_defaults(craft.type, {})
- formspec = formspec.."label[6,3.35;Method:]"
- formspec = formspec.."label[6,3.75;"
- ..minetest.formspec_escape(craft_type.description).."]"
- else
+ if not craft then
craftinv:set_stack("output", 1, item_name)
craft_type = unified_inventory.craft_type_defaults("", {})
formspec = formspec.."label[6,3.35;No recipes]"
+ formspec = formspec.."image[4,1;1.1,1.1;ui_no.png]"
+ return {formspec = formspec}
end
+ craftinv:set_stack("output", 1, craft.output)
+ craft_type = unified_inventory.registered_craft_types[craft.type] or
+ unified_inventory.craft_type_defaults(craft.type, {})
+ formspec = formspec.."label[6,3.35;Method:]"
+ formspec = formspec.."label[6,3.75;"
+ ..minetest.formspec_escape(craft_type.description).."]"
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
diff --git a/textures/ui_no.png b/textures/ui_no.png
new file mode 100644
index 0000000..ad9470b
--- /dev/null
+++ b/textures/ui_no.png
Binary files differ