Addressed an issue with the reagent filter not showing skills if *some* reagents were possessed.
pschifferer [02-26-09 - 00:55]
Addressed an issue with the reagent filter not showing skills if *some* reagents were possessed.
Added a tooltip hook for SetTradeskillItem() to display if a reagent is "key" or "vendor".
diff --git a/CauldronMain.lua b/CauldronMain.lua
index d9982b5..039cf93 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -735,7 +735,7 @@ function Cauldron:HookTooltips()
-- self:SecureHook(GameTooltip, "SetInventoryItem");
-- self:SecureHook(GameTooltip, "SetLootItem");
-- self:SecureHook(GameTooltip, "SetHyperlink");
--- self:SecureHook(GameTooltip, "SetTradeSkillItem");
+ self:SecureHook(GameTooltip, "SetTradeSkillItem");
-- self:SecureHook(GameTooltip, "SetMerchantItem");
-- self:SecureHook(GameTooltip, "SetAuctionItem");
-- self:SecureHook(GameTooltip, "SetTrainerService");
@@ -748,6 +748,31 @@ function Cauldron:HookTooltips()
end
----------------------------------------------------------------------
+-- Tooltip hook functions
+----------------------------------------------------------------------
+
+function Cauldron:SetTradeSkillItem(tooltip, itemIndex, reagentIndex)
+ local link;
+ local name;
+ if reagentIndex then
+ local skillInfo = Cauldron:GetSkillInfoByIndex(itemIndex);
+ local reagentInfo = Cauldron:GetReagentInfoByIndex(itemIndex, reagentIndex);
+
+ -- let the user know if the reagent is a "non-key" reagent
+ if reagentInfo.key then
+ tooltip:AddLine(L["Type: "]..L["Key"]);
+ else
+ tooltip:AddLine(L["Type: "]..L["Vendor"]);
+ end
+ else
+-- link = GetTradeSkillItemLink(itemIndex);
+-- name = Cauldron:GetIdFromLink(link);
+ end
+
+ tooltip:Show();
+end
+
+----------------------------------------------------------------------
-- Property functions
----------------------------------------------------------------------
diff --git a/CauldronMain.xml b/CauldronMain.xml
index 3cdf6b8..7aec0a2 100644
--- a/CauldronMain.xml
+++ b/CauldronMain.xml
@@ -286,7 +286,7 @@
<Layer level="OVERLAY">
<!-- item name -->
<FontString name="$parentItemName" inherits="GameFontNormal"
- text="" justifyH="LEFT" justifyV="CENTER">
+ text="(name)" justifyH="LEFT" justifyV="CENTER">
<Size x="250" y="12"/>
<Anchors>
<Anchor point="TOPLEFT">
@@ -297,7 +297,7 @@
</FontString>
<!-- quantity info -->
<FontString name="$parentInfo" inherits="GameFontNormal"
- text="" justifyH="LEFT" justifyV="CENTER">
+ text="(info)" justifyH="LEFT" justifyV="CENTER">
<Size x="250" y="12"/>
<Anchors>
<Anchor point="TOPLEFT">
diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua
index 68b86e7..8e4bf28 100644
--- a/CauldronTradeskill.lua
+++ b/CauldronTradeskill.lua
@@ -339,14 +339,13 @@ function Cauldron:GetSkillList(playername, skillName)
end
end
elseif self.db.realm.userdata[playername].skills[skillName].window.filter.haveAnyReagents then
- -- check if the reagent count for any reagent is 0
- local count = 0;
+ -- check if the reagent count for any reagent is > 0
+ add = false;
for rname, rinfo in pairs(recipe.reagents) do
-- check possession count
- count = count + GetItemCount(rname);
- end
- if count == 0 then
- add = false;
+ if GetItemCount(rname) > 0 then
+ add = true;
+ end
end
end
@@ -467,6 +466,43 @@ function Cauldron:GetSkillInfoForItem(item)
return nil;
end
+function Cauldron:GetSkillInfoByIndex(itemIndex)
+
+ for tradeskill, list in pairs(self.db.realm.userdata[self.vars.playername].skills) do
+ -- skip linked skills
+ if not (string.find(tradeskill, "Linked-")) then
+ for _, recipeInfo in pairs(list.recipes) do
+ if recipeInfo.index == itemIndex then
+ return recipeInfo;
+ end
+ end
+ end
+ end
+
+ return nil;
+end
+
+function Cauldron:GetReagentInfoByIndex(item, reagentIndex)
+
+ local skillInfo = nil;
+
+ if type(item) == "table" then
+ skillInfo = item;
+ elseif type(item) == "number" then
+ skillInfo = self:GetSkillInfoByIndex(tonumber(item));
+ end
+
+ if skillInfo then
+ for i, reagentInfo in ipairs(skillInfo.reagents) do
+ if reagentInfo.index == reagentIndex then
+ return reagentInfo;
+ end
+ end
+ end
+
+ return nil;
+end
+
function Cauldron:GetRequiredItems(skillInfo, amount)
local intermediates = {};
diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua
index e54feee..993e8ff 100644
--- a/Locale/Cauldron-enUS.lua
+++ b/Locale/Cauldron-enUS.lua
@@ -105,6 +105,10 @@ L["Decrease the amount of this item"] = true
L["Remove this item from the shopping list"] = true
+L["Type: "] = true
+L["Vendor"] = true
+L["Key"] = true
+
-- error messages
L["Crafting %1$s requires the %2$s skill."] = true