comparison ReagentMaker.lua @ 13:5eb02d3e1647

Do not manage guild or linked tradeskills
author contrebasse
date Sun, 03 Apr 2011 13:28:25 +0200
parents 17844b0b88c1
children cc56799582f2
comparison
equal deleted inserted replaced
12:2273a56762cb 13:5eb02d3e1647
27 --------------------------------------------------- 27 ---------------------------------------------------
28 A.EventsFrame = CreateFrame("Frame") 28 A.EventsFrame = CreateFrame("Frame")
29 29
30 A.EventsFrame:SetScript("OnEvent", function(self, event, ...) 30 A.EventsFrame:SetScript("OnEvent", function(self, event, ...)
31 if event == "TRADE_SKILL_UPDATE" then 31 if event == "TRADE_SKILL_UPDATE" then
32 -- Scan availabe recipes
33 A:ScanSimpleRecipes()
34
35 -- Close the external window if the tradeskill changed 32 -- Close the external window if the tradeskill changed
36 if A.currentTradeSkill ~= GetTradeSkillLine() then 33 if A.currentTradeSkill ~= GetTradeSkillLine() then
37 A.MenuFrame:Hide() 34 A.MenuFrame:Hide()
38 end 35 end
36
37 if IsTradeSkillGuild() or IsTradeSkillLinked() then
38 A.MenuFrame:Hide()
39 return
40 end
41
42 -- Scan availabe recipes
43 A:ScanSimpleRecipes()
44
39 elseif event == "TRADE_SKILL_SHOW" then 45 elseif event == "TRADE_SKILL_SHOW" then
46 if IsTradeSkillGuild() or IsTradeSkillLinked() then
47 A.MenuFrame:Hide()
48 return
49 end
40 A:Initialize() 50 A:Initialize()
51 A.EventsFrame:UnregisterEvent("TRADE_SKILL_SHOW")
41 end -- if 52 end -- if
42 end) -- function 53 end) -- function
43 A.EventsFrame:RegisterEvent("TRADE_SKILL_SHOW") 54 A.EventsFrame:RegisterEvent("TRADE_SKILL_SHOW")
44 A.EventsFrame:RegisterEvent("TRADE_SKILL_UPDATE") 55 A.EventsFrame:RegisterEvent("TRADE_SKILL_UPDATE")
45 56
46 --------------------------------------------------- 57 ---------------------------------------------------
47 -- Initialize 58 -- Initialize
48 --------------------------------------------------- 59 ---------------------------------------------------
49 local toInitialize = true
50 function A:Initialize() 60 function A:Initialize()
51 A.EventsFrame:UnregisterEvent("TRADE_SKILL_SHOW")
52 61
53 -- Register clics on reagent's buttons 62 -- Register clics on reagent's buttons
54 for i=1,7 do 63 for i=1,7 do
55 local btn = _G["TradeSkillReagent"..i]; 64 local btn = _G["TradeSkillReagent"..i];
56 btn:HookScript("OnDoubleClick", A.ProcessReagent); 65 btn:HookScript("OnDoubleClick", A.ProcessReagent);
84 A.tooltipReagent:SetFrameStrata("TOOLTIP") 93 A.tooltipReagent:SetFrameStrata("TOOLTIP")
85 A.tooltipReagent:Hide() 94 A.tooltipReagent:Hide()
86 --]] 95 --]]
87 end -- function 96 end -- function
88 97
89 98 -- Function run after selecting a item in the tradeskill window
90 -- Function run avter selecting a item in the tradeskill window
91 function A.ProcessReagent(btn, ...) 99 function A.ProcessReagent(btn, ...)
100 -- Do not manage guild tradeskill
101 if IsTradeSkillGuild() or IsTradeSkillLinked() then return end
102
92 -- We want no modifiers, or shift to choose the number of reagent to craft 103 -- We want no modifiers, or shift to choose the number of reagent to craft
93 if IsModifierKeyDown() and not IsShiftKeyDown() then return end 104 if IsModifierKeyDown() and not IsShiftKeyDown() then return end
94 local chooseNumberToCraft = IsShiftKeyDown() 105 local chooseNumberToCraft = IsShiftKeyDown()
95 106
96 -- Index of the reagent in the recipe, taken from the button name 107 -- Index of the reagent in the recipe, taken from the button name
165 end -- function 176 end -- function
166 177
167 178
168 -- Button hovering 179 -- Button hovering
169 function A.btnEntered(btn) 180 function A.btnEntered(btn)
181 -- Do not manage guild tradeskill
182 if IsTradeSkillGuild() or IsTradeSkillLinked() then return end
183
170 -- Index of the reagent in the recipe, taken from the button name 184 -- Index of the reagent in the recipe, taken from the button name
171 local reagentRecipeIndex = A.buttonNumber(btn) 185 local reagentRecipeIndex = A.buttonNumber(btn)
172 186
173 -- ID of the reagent we want to craft 187 -- ID of the reagent we want to craft
174 local reagentLink = GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), reagentRecipeIndex) 188 local reagentLink = GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), reagentRecipeIndex)