diff SecureMenu.lua @ 73:a77fd9d06ba4

Use the new internal data format everywhere
author contrebasse
date Sat, 14 May 2011 20:55:49 +0200
parents 4f9fd025112b
children 3d344a2d8fdf
line wrap: on
line diff
--- a/SecureMenu.lua	Sat May 14 20:28:05 2011 +0200
+++ b/SecureMenu.lua	Sat May 14 20:55:49 2011 +0200
@@ -210,14 +210,14 @@
 
 		if numMakable>0 then
 			-- Set action
-			if type(action)=="function" then
+			if type(btn.action)=="function" then
 				btn:SetScript("PreClick",btn.action)
 				btn:SetAttribute("type", nil)
 				btn:SetAttribute("macrotext", nil)
 			else --if type(action)=="string" then
 				btn:SetScript("PreClick",nil)
 				btn:SetAttribute("type", "macro")
-				btn:SetAttribute("macrotext", btn.action..btn.itemNameString)
+				btn:SetAttribute("macrotext", btn.action:format(btn.itemNameString))
 			end -- if
 
 			anyMakable = true
@@ -249,7 +249,7 @@
 	end
 end
 
-local function menuAddItem(action,itemID,reagent,spellLink)
+local function menuAddItem(action,itemID,reagent)
 	local btn
 	-- Create a button only if necessary
 	if numActiveEntries >= #menuEntries then
@@ -260,19 +260,12 @@
 
 	-- Set text and icon
 	local name, link, _, _, _, _, _, _, _, texture = GetItemInfo(reagent[1])
-	if name then
-		btn.itemName:SetText(name)
-	else
-		--A.DEBUG("No item name : "..reagent[1])
+	if not (name and link and texture) then
+		-- Will be retried on next OnUpdate
 		return
 	end
-
-	if texture then
-		btn.icon:SetTexture(texture)
-	else
-		--A.DEBUG("No item texture : "..reagent[1])
-		return
-	end
+	btn.itemName:SetText(name)
+	btn.icon:SetTexture(texture)
 
 	-- Set chance to have the item or the number of items created
 	if reagent[3] then
@@ -290,7 +283,7 @@
 	btn.reagentID = reagent[1]
 	btn.reagentLink = link
 	btn.reagentsForOneRecipe = reagent[2]
-	btn.spellLink = spellLink
+	btn.spellLink = reagent.spellLink
 	btn.action = action
 	btn.itemNameString = name
 
@@ -336,16 +329,16 @@
 
 	-- Save vars to show the tooltip later
 	MenuFrame.reagentLink = link
-	MenuFrame.spellLink = A.data[itemID].spellLink
+	MenuFrame.spellLink = A.isRecipeUnique(A.data[itemID]) and A.data[itemID][1].spellLink
 	MenuFrame.itemID = itemID
-	MenuFrame.superItemID = superItemID -- optional
+	MenuFrame.superItemID = superItemID -- optional, will be nil if not set
 
 	-- Loop over the available recipes
 	MenuFrame.state = true
 	for _,reagent in ipairs(A.data[itemID]) do
-		if A.data[itemID].spell then
+		if reagent.macro then
 			-- Special spell
-			MenuFrame.state = menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellLink) and MenuFrame.state
+			MenuFrame.state = menuAddItem(reagent.macro,itemID,reagent) and MenuFrame.state
 		else
 			-- Standard tradeskill spell UNTESTED
 			MenuFrame.state = menuAddItem(A.craft,itemID,reagent) and MenuFrame.state