diff SecureMenu.lua @ 10:b6a5902f376f

Display the percent chance to have an item while prospecting
author contrebasse
date Sat, 02 Apr 2011 22:42:53 +0200
parents cea9633a6d4e
children 2716889648bd
line wrap: on
line diff
--- a/SecureMenu.lua	Sat Apr 02 22:19:02 2011 +0200
+++ b/SecureMenu.lua	Sat Apr 02 22:42:53 2011 +0200
@@ -135,6 +135,12 @@
 	countDetail:SetJustifyV("BOTTOM")
 	btn.countDetail = countDetail
 
+	local resultNumber = btn:CreateFontString(nil,"ARTWORK","NumberFontNormal")
+	resultNumber:SetPoint("TOPLEFT",icon,"TOPLEFT",1,-1)
+	resultNumber:SetJustifyH("LEFT")
+	resultNumber:SetJustifyV("TOP")
+	btn.resultNumber = resultNumber
+
 	btn:HookScript("OnEnter", btnEntered)
 	btn:HookScript("OnLeave", btnLeft)
 
@@ -180,7 +186,7 @@
 	end
 end
 
-local function menuAddItem(action,itemID,reagentID,reagentsForOneRecipe,spellID)
+local function menuAddItem(action,itemID,reagent,spellID)
 	local btn
 	-- Create a button only if necessary
 	if numActiveEntries >= #menuEntries then
@@ -190,26 +196,35 @@
 	end
 
 	-- Set text and icon
-	local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(reagentID)
+	local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(reagent[1])
 	if name then
 		btn.itemName:SetText(name)
 	else
-		A.DEBUG("No item name : "..reagentID)
+		A.DEBUG("No item name : "..reagent[1])
 		return
 	end
 
 	if texture then
 		btn.icon:SetTexture(texture)
 	else
-		A.DEBUG("No item texture : "..reagentID)
+		A.DEBUG("No item texture : "..reagent[1])
 		return
 	end
 
+	-- Set chance to have the item or the number of items created
+	if reagent[3] then
+		if reagent[3]<1 then
+			btn.resultNumber:SetText((reagent[3]*100).."%")
+		elseif reagent[3]>1 then
+			btn.resultNumber:SetText(reagent[3])
+		end
+	end
+
 	-- Save params
 	btn.itemID = itemID
-	btn.reagentID = reagentID
+	btn.reagentID = reagent[1]
 	btn.reagentLink = link
-	btn.reagentsForOneRecipe = reagentsForOneRecipe
+	btn.reagentsForOneRecipe = reagent[2]
 	btn.spellID = spellID
 
 	-- Set action
@@ -255,10 +270,10 @@
 	for _,reagent in ipairs(A.data[itemID]) do
 			if A.data[itemID].spell then
 				-- Special spell
-				menuAddItem(A.data[itemID].spell,itemID,reagent[1],reagent[2],A.data[itemID].spellID)
+				menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellID)
 			else
 				-- Standard tradeskill spell UNTESTED
-				menuAddItem(A.craft,itemID,reagent[1],reagent[2])
+				menuAddItem(A.craft,itemID,reagent)
 			end -- if
 	end -- for