Mercurial > wow > reagentmaker
diff ReagentMaker.lua @ 20:4ea38bae4174
Lots of display arrangements (tooltips and counts)
Corrected an id in data
author | contrebasse |
---|---|
date | Sun, 10 Apr 2011 19:26:33 +0200 |
parents | f7b23db7bcc6 |
children | 25b9f98f9bba |
line wrap: on
line diff
--- a/ReagentMaker.lua Fri Apr 08 19:58:08 2011 +0200 +++ b/ReagentMaker.lua Sun Apr 10 19:26:33 2011 +0200 @@ -42,6 +42,9 @@ -- Scan availabe recipes A:ScanSimpleRecipes() + + -- Show makables reagents + A.updateCounts(GetTradeSkillSelectionIndex()) end end A.EventsFrame:SetScript("OnEvent", function(self, event) @@ -64,8 +67,8 @@ -- Register clics on reagent's buttons for i=1,7 do - local btn = _G["TradeSkillReagent"..i]; - btn:HookScript("OnDoubleClick", A.ProcessReagent); + local btn = _G["TradeSkillReagent"..i] + btn:HookScript("OnDoubleClick", A.ProcessReagent) btn:HookScript("OnEnter", A.btnEntered) btn:HookScript("OnLeave", A.btnLeft) btn.SplitStack = A.SplitStack @@ -74,8 +77,6 @@ textureHighlight:Hide() textureHighlight:SetTexture("Interface\\BUTTONS\\CheckButtonHilight") textureHighlight:SetBlendMode("ADD") - --textureHighlight:SetPoint("TOPLEFT") - --textureHighlight:SetSize(btn:GetHeight(),btn:GetHeight()) textureHighlight:SetAllPoints("TradeSkillReagent"..i.."IconTexture") btn.textureHighlight = textureHighlight @@ -196,17 +197,6 @@ btn.textureHighlight:Show() - if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then - local numMakable = A.numMakable(reagentID) - btn.label:SetText(numMakable) - if numMakable==0 then - btn.label:SetTextColor(1, 0, 0, 1) - else - btn.label:SetTextColor(0, 5, 0, 1) - end - btn.label:Show() - end - -- Tooltips local link if A.data[reagentID].spell then @@ -219,25 +209,51 @@ A.tooltipRecipe:SetHyperlink(link) A.tooltipRecipe:Show() A.tooltipRecipe:ClearAllPoints() - --A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT") A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") - - --[[ - if #(A.data[reagentID]) == 1 then - A.tooltipReagent:SetOwner(A.tooltipRecipe) - local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(A.data[reagentID][1][1]) - A.tooltipReagent:SetHyperlink(link) - A.tooltipReagent:Show() - A.tooltipReagent:ClearAllPoints() - A.tooltipReagent:SetPoint("BOTTOMLEFT",A.tooltipRecipe,"BOTTOMRIGHT") - end - --]] end end function A.btnLeft(btn) btn.textureHighlight:Hide() - btn.label:Hide() A.tooltipRecipe:Hide() --A.tooltipReagent:Hide() -end +end -- function + +function A.updateCounts(recipeIndex) + -- Needs an argument + if not recipeIndex then return end + + -- Do not manage guild tradeskill + if IsTradeSkillGuild() or IsTradeSkillLinked() then + for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do + _G["TradeSkillReagent"..reagentRecipeIndex].label:Hide() + end + return + end + + -- Count makable items and show it + for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do + -- ID of the reagent we want to craft + local reagentLink = GetTradeSkillReagentItemLink(recipeIndex, reagentRecipeIndex) + local reagentID = A.link2ID(reagentLink) + + local label = _G["TradeSkillReagent"..reagentRecipeIndex].label + if not label then return end + + -- Continue only if the reagent is known + if not reagentID or not A.data[reagentID] or #(A.data[reagentID]) ~= 1 or A.data[reagentID].spell then + label:Hide() + else + -- Count and show + local numMakable = A.numMakable(reagentID) + label:SetText(numMakable) + if numMakable==0 then + label:SetTextColor(1, 0, 0, 1) + else + label:SetTextColor(0, 5, 0, 1) + end -- if + label:Show() + end -- if + end -- for +end -- function +hooksecurefunc("SelectTradeSkill",A.updateCounts)