comparison 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
comparison
equal deleted inserted replaced
19:f7b23db7bcc6 20:4ea38bae4174
40 return 40 return
41 end 41 end
42 42
43 -- Scan availabe recipes 43 -- Scan availabe recipes
44 A:ScanSimpleRecipes() 44 A:ScanSimpleRecipes()
45
46 -- Show makables reagents
47 A.updateCounts(GetTradeSkillSelectionIndex())
45 end 48 end
46 end 49 end
47 A.EventsFrame:SetScript("OnEvent", function(self, event) 50 A.EventsFrame:SetScript("OnEvent", function(self, event)
48 if event == "TRADE_SKILL_UPDATE" then 51 if event == "TRADE_SKILL_UPDATE" then
49 t_throttle = SCAN_DELAY 52 t_throttle = SCAN_DELAY
62 --------------------------------------------------- 65 ---------------------------------------------------
63 function A:Initialize() 66 function A:Initialize()
64 67
65 -- Register clics on reagent's buttons 68 -- Register clics on reagent's buttons
66 for i=1,7 do 69 for i=1,7 do
67 local btn = _G["TradeSkillReagent"..i]; 70 local btn = _G["TradeSkillReagent"..i]
68 btn:HookScript("OnDoubleClick", A.ProcessReagent); 71 btn:HookScript("OnDoubleClick", A.ProcessReagent)
69 btn:HookScript("OnEnter", A.btnEntered) 72 btn:HookScript("OnEnter", A.btnEntered)
70 btn:HookScript("OnLeave", A.btnLeft) 73 btn:HookScript("OnLeave", A.btnLeft)
71 btn.SplitStack = A.SplitStack 74 btn.SplitStack = A.SplitStack
72 75
73 local textureHighlight = btn:CreateTexture() 76 local textureHighlight = btn:CreateTexture()
74 textureHighlight:Hide() 77 textureHighlight:Hide()
75 textureHighlight:SetTexture("Interface\\BUTTONS\\CheckButtonHilight") 78 textureHighlight:SetTexture("Interface\\BUTTONS\\CheckButtonHilight")
76 textureHighlight:SetBlendMode("ADD") 79 textureHighlight:SetBlendMode("ADD")
77 --textureHighlight:SetPoint("TOPLEFT")
78 --textureHighlight:SetSize(btn:GetHeight(),btn:GetHeight())
79 textureHighlight:SetAllPoints("TradeSkillReagent"..i.."IconTexture") 80 textureHighlight:SetAllPoints("TradeSkillReagent"..i.."IconTexture")
80 btn.textureHighlight = textureHighlight 81 btn.textureHighlight = textureHighlight
81 82
82 local label = btn:CreateFontString(nil,"ARTWORK","GameFontHighlight") 83 local label = btn:CreateFontString(nil,"ARTWORK","GameFontHighlight")
83 label:SetSize(100,20) 84 label:SetSize(100,20)
194 -- Continue only if the reagent is known 195 -- Continue only if the reagent is known
195 if not reagentID or not A.data[reagentID] then return end 196 if not reagentID or not A.data[reagentID] then return end
196 197
197 btn.textureHighlight:Show() 198 btn.textureHighlight:Show()
198 199
199 if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then
200 local numMakable = A.numMakable(reagentID)
201 btn.label:SetText(numMakable)
202 if numMakable==0 then
203 btn.label:SetTextColor(1, 0, 0, 1)
204 else
205 btn.label:SetTextColor(0, 5, 0, 1)
206 end
207 btn.label:Show()
208 end
209
210 -- Tooltips 200 -- Tooltips
211 local link 201 local link
212 if A.data[reagentID].spell then 202 if A.data[reagentID].spell then
213 link = GetSpellLink(A.data[reagentID].spellID) 203 link = GetSpellLink(A.data[reagentID].spellID)
214 else 204 else
217 if link then 207 if link then
218 A.tooltipRecipe:SetOwner(btn) 208 A.tooltipRecipe:SetOwner(btn)
219 A.tooltipRecipe:SetHyperlink(link) 209 A.tooltipRecipe:SetHyperlink(link)
220 A.tooltipRecipe:Show() 210 A.tooltipRecipe:Show()
221 A.tooltipRecipe:ClearAllPoints() 211 A.tooltipRecipe:ClearAllPoints()
222 --A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT")
223 A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") 212 A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT")
224
225 --[[
226 if #(A.data[reagentID]) == 1 then
227 A.tooltipReagent:SetOwner(A.tooltipRecipe)
228 local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(A.data[reagentID][1][1])
229 A.tooltipReagent:SetHyperlink(link)
230 A.tooltipReagent:Show()
231 A.tooltipReagent:ClearAllPoints()
232 A.tooltipReagent:SetPoint("BOTTOMLEFT",A.tooltipRecipe,"BOTTOMRIGHT")
233 end
234 --]]
235 end 213 end
236 end 214 end
237 215
238 function A.btnLeft(btn) 216 function A.btnLeft(btn)
239 btn.textureHighlight:Hide() 217 btn.textureHighlight:Hide()
240 btn.label:Hide()
241 A.tooltipRecipe:Hide() 218 A.tooltipRecipe:Hide()
242 --A.tooltipReagent:Hide() 219 --A.tooltipReagent:Hide()
243 end 220 end -- function
221
222 function A.updateCounts(recipeIndex)
223 -- Needs an argument
224 if not recipeIndex then return end
225
226 -- Do not manage guild tradeskill
227 if IsTradeSkillGuild() or IsTradeSkillLinked() then
228 for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do
229 _G["TradeSkillReagent"..reagentRecipeIndex].label:Hide()
230 end
231 return
232 end
233
234 -- Count makable items and show it
235 for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do
236 -- ID of the reagent we want to craft
237 local reagentLink = GetTradeSkillReagentItemLink(recipeIndex, reagentRecipeIndex)
238 local reagentID = A.link2ID(reagentLink)
239
240 local label = _G["TradeSkillReagent"..reagentRecipeIndex].label
241 if not label then return end
242
243 -- Continue only if the reagent is known
244 if not reagentID or not A.data[reagentID] or #(A.data[reagentID]) ~= 1 or A.data[reagentID].spell then
245 label:Hide()
246 else
247 -- Count and show
248 local numMakable = A.numMakable(reagentID)
249 label:SetText(numMakable)
250 if numMakable==0 then
251 label:SetTextColor(1, 0, 0, 1)
252 else
253 label:SetTextColor(0, 5, 0, 1)
254 end -- if
255 label:Show()
256 end -- if
257 end -- for
258 end -- function
259 hooksecurefunc("SelectTradeSkill",A.updateCounts)