changeset 33:218e1dd1b821

Hide external frame when selecting a recipe which doesn't need this reagent
author contrebasse
date Fri, 29 Apr 2011 00:14:25 +0200
parents 416c307fd00b
children 0af9cb8a79f0
files ReagentMaker.lua SecureMenu.lua
diffstat 2 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ReagentMaker.lua	Thu Apr 28 23:39:30 2011 +0200
+++ b/ReagentMaker.lua	Fri Apr 29 00:14:25 2011 +0200
@@ -122,17 +122,18 @@
 	if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then
 		local numMakable, reagentIndex = A.numMakable(reagentID)
 		if not numMakable then
-			print("Sorry, i can't determine the number of makables reagents...")
+			print("Sorry, I can't determine the number of makables reagents...")
 			return
 		end
 		if numMakable>0 then
 			A.craft(reagentID,reagentRecipeIndex,reagentIndex,numMakable,chooseNumberToCraft)
 			return
 		end
+
 		-- If we can make the item needed to make the reagent, open a window to make it
 		-- one step recursion, enables to mill to create an ink
 		if A.data[A.data[reagentID][1][1]] then
-			A.externalCraftWindow(A.data[reagentID][1][1])
+			A.externalCraftWindow(A.data[reagentID][1][1],reagentID)
 		else
 			print("Sorry, couldn't make reagent...")
 		end
--- a/SecureMenu.lua	Thu Apr 28 23:39:30 2011 +0200
+++ b/SecureMenu.lua	Fri Apr 29 00:14:25 2011 +0200
@@ -51,6 +51,18 @@
 	GameTooltip:Hide()
 	A.tooltipRecipe:Hide()
 end)
+
+-- Hide frame when selecting a recipe which doesn't need this reagent
+hooksecurefunc("SelectTradeSkill",function()
+	local selectedIndex = GetTradeSkillSelectionIndex()
+	for reagentRecipeIndex = 1,GetTradeSkillNumReagents(selectedIndex) do
+		local reagentID = A.link2ID(GetTradeSkillReagentItemLink(selectedIndex, reagentRecipeIndex))
+		if reagentID == MenuFrame.itemID or (MenuFrame.superItemID and reagentID == MenuFrame.superItemID) then
+			return
+		end
+	end
+	MenuFrame:Hide()
+end)
 A.MenuFrame = MenuFrame
 
 -- Background adaptable vertically
@@ -272,7 +284,7 @@
 end -- function
 
 -- Fill the window and open it
-function A.externalCraftWindow(itemID)
+function A.externalCraftWindow(itemID,superItemID)
 	-- Do not open during combat
 	if InCombatLockdown() then return end
 
@@ -296,6 +308,8 @@
 	-- Save vars to show the tooltip later
 	MenuFrame.reagentLink = link
 	MenuFrame.spellLink = A.data[itemID].spellLink
+	MenuFrame.itemID = itemID
+	MenuFrame.superItemID = superItemID -- optional
 	
 	-- Loop over the available recipes
 	for _,reagent in ipairs(A.data[itemID]) do