diff --git a/interface/sip/recipe.png b/interface/sip/recipe.png new file mode 100644 index 0000000..7d6890b Binary files /dev/null and b/interface/sip/recipe.png differ diff --git a/interface/sip/sip.config b/interface/sip/sip.config index 3a54953..7cdded7 100644 --- a/interface/sip/sip.config +++ b/interface/sip/sip.config @@ -104,13 +104,9 @@ "type": "button", "base": "/interface/sip/print.png", "hover": "/interface/sip/print.png?brightness=30", - "caption": "", - "fontSize": 7, - "wrapWidth": 80, - "hAnchor": "mid", "zlevel": 20, "pressedOffset": [0, -1], - "position": [212, 25], + "position": [202, 25], "callback": "sip.callback.print" }, "sipImagePrintAmount": { @@ -162,6 +158,17 @@ "callback": "sip.callback.changeQuantity" }, + "buttonPrintBlueprint":{ + "type": "button", + "base": "/interface/sip/recipe.png", + "hover": "/interface/sip/recipe.png?brightness=30", + "zlevel": 20, + "pressedOffset": [0, -1], + "disabled": true, + "position": [287, 25], + "callback": "sip.callback.printBlueprint" + }, + "sipImageSearch": { "type": "image", "file": "/interface/sip/search.png", @@ -1105,6 +1112,7 @@ "sip.callback.showType", "sip.callback.selectItem", "sip.callback.print", + "sip.callback.printBlueprint", "sip.callback.changeQuantity", "sip.callback.selectCategory", "sip.callback.changeWeaponLevel", @@ -1165,7 +1173,8 @@ "fire": 3, "electric": 4 }, - "labelClothingColor": "paneClothing.labelColor" + "labelClothingColor": "paneClothing.labelColor", + "blueprint": "buttonPrintBlueprint" }, "knownCategories": { "items": [ diff --git a/scripts/sip_callback.lua b/scripts/sip_callback.lua index 9fad60d..66f8c56 100644 --- a/scripts/sip_callback.lua +++ b/scripts/sip_callback.lua @@ -66,6 +66,9 @@ function sip.callback.selectItem() local rarity = sip.item.rarity and sip.item.rarity:lower() or "common" widget.setImage(sip.widgets.itemRarity, sip.rarityImages.flags[rarity]) + -- Blueprint + widget.setButtonEnabled(sip.widgets.blueprint, sip_util.hasBlueprint(sip.item.name)) + -- Item slot sip.randomizeItem() sip.showSpecifications(config) @@ -131,6 +134,14 @@ function sip.callback.print() sip.spawnItem(cfg.config, q) end +--- Spawns a recipe for the current item, if the item supports a recipe. +function sip.callback.printBlueprint() + local item = sip.item + if item and item.name and sip_util.hasBlueprint(item.name) then + player.giveItem({name=item.name .. "-recipe", count=1}) + end +end + --- Takes the item, or place an item to copy. -- If no item is held, the item will be taken (without consuming it). This acts similar to print, but only (x1). -- If an item is held, the selection is overwritten, allowing users to copy their existing items. diff --git a/scripts/sip_util.lua b/scripts/sip_util.lua index c825ef0..1b0653e 100644 --- a/scripts/sip_util.lua +++ b/scripts/sip_util.lua @@ -31,6 +31,12 @@ function sip_util.isLevelableWeapon(itemConfig) return false end +--- Returns a value indicating whether the item has an unlockable blueprint +function sip_util.hasBlueprint(itemName) + if type(itemName) ~= "string" then return false end + return not not root.itemConfig(itemName .. "-recipe") +end + --- Filters the item list by categories. -- Categories are identified by name, and are case insensitive. -- @param list Item table, as stored in the item dump.