Quantcast

Added filter that will sort skills that have key reagents (those not available from vendors).

pschifferer [02-19-09 - 20:06]
Added filter that will sort skills that have key reagents (those not available from vendors).
Filename
CauldronMain.lua
CauldronMainUI.lua
CauldronTradeskill.lua
CauldronUtil.lua
diff --git a/CauldronMain.lua b/CauldronMain.lua
index e4def62..4f0587e 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -854,6 +854,7 @@ end
 									["index"] = <reagent index>, -- the index of the reagent, for API call usage
 									["skillIndex"] = <skill index>, -- the index of the skill, for API call usage
 									["icon"] = "<icon>",
+									["key"] = <true-or-false>,
 								}, -- [1]
 								...
 							},
diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index c95fd5c..fcea2b9 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -1330,7 +1330,6 @@ function Cauldron:FilterDropDown_Initialize(level)
 		};
 		UIDropDownMenu_AddButton(haveAllReagents);

-		--[[
 		local haveKeyReagents = {
 			text = L["Have key"],
 			checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveKeyReagents,
@@ -1341,7 +1340,6 @@ function Cauldron:FilterDropDown_Initialize(level)
 			arg2 = "",
 		};
 		UIDropDownMenu_AddButton(haveKeyReagents);
-		--]]

 		local haveAnyReagents = {
 			text = L["Have any"],
diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua
index 7e283e3..79eaac2 100644
--- a/CauldronTradeskill.lua
+++ b/CauldronTradeskill.lua
@@ -327,14 +327,18 @@ function Cauldron:GetSkillList(playername, skillName)
 			end
 		elseif self.db.realm.userdata[playername].skills[skillName].window.filter.haveKeyReagents then
 			-- check if the reagent count for key reagents is 0
+			for rname, rinfo in pairs(recipe.reagents) do
+				-- check possession count
+				if (GetItemCount(rname) == 0) and (rinfo.key) then
+					add = false;
+				end
+			end
 		elseif self.db.realm.userdata[playername].skills[skillName].window.filter.haveAnyReagents then
 			-- check if the reagent count for any reagent is 0
 			for rname, rinfo in pairs(recipe.reagents) do
 				-- check possession count
 				if GetItemCount(rname) == 0 then
---					if Cauldron:GetAltReagentCount(rinfo) == 0 then
-						add = false;
---					end
+					add = false;
 				end
 			end
 		end
@@ -528,6 +532,12 @@ function Cauldron:GetReagentsForSkill(skillInfo)
 		for i=1,GetTradeSkillNumReagents(skillInfo.index) do
 			local name, icon, count, _ = GetTradeSkillReagentInfo(skillInfo.index, i);
 			local link = GetTradeSkillReagentItemLink(skillInfo.index, i);
+			local itemId = Cauldron:GetIdFromLink(link);
+			local value, set = self.libs.PT:ItemInSet(itemId, "Tradeskill.Mat.BySource.Vendor");
+			local key = true;
+			if value then
+				key = false;
+			end

 			local r = {
 --				["toonHas"] = GetItemCount(link),
@@ -536,6 +546,7 @@ function Cauldron:GetReagentsForSkill(skillInfo)
 				["skillIndex"] = skillInfo.index,
 				["icon"] = icon,
 				["link"] = link,
+				["key"] = key,
 			};

 			table.insert(reagents, r);
diff --git a/CauldronUtil.lua b/CauldronUtil.lua
index 731d300..37280ac 100644
--- a/CauldronUtil.lua
+++ b/CauldronUtil.lua
@@ -9,11 +9,14 @@ function Cauldron:GetAltReagentCount(reagentInfo)
 	self:debug("GetAltReagentCount exit");
 end

-function Cauldron:GetPotentialCraftCount(skill)
+function Cauldron:GetPotentialCraftCount(skillInfo)
 	self:debug("GetPotentialCraftCount enter");

 	local count = 0;

+	-- get reagent list
+--	local reagents = Cauldron:GetReagentsForSkill(skillInfo);
+
 	-- TODO

 	self:debug("GetPotentialCraftCount exit");