comparison CampFireButton.lua @ 111:af23986010ef v1.1beta0

Rewrote the main part to clarify things, should have removed some hidden nasty bugs.
author contrebasse
date Thu, 02 Jun 2011 23:07:23 +0200
parents 08ede537787b
children c79ab5443ee5
comparison
equal deleted inserted replaced
110:d60d6b4cab0c 111:af23986010ef
5 local btn 5 local btn
6 local cookingName 6 local cookingName
7 local CooldownFrame_SetTimer = CooldownFrame_SetTimer 7 local CooldownFrame_SetTimer = CooldownFrame_SetTimer
8 local GetSpellCooldown = GetSpellCooldown 8 local GetSpellCooldown = GetSpellCooldown
9 9
10 -- The cooldown info is not directly obtainable
10 local function WaitCooldown(self) 11 local function WaitCooldown(self)
11 local start, duration, enable = GetSpellCooldown(CAMPFIRE_ID) 12 local start, duration, enable = GetSpellCooldown(CAMPFIRE_ID)
12 if start>0 then 13 if start>0 then
13 CooldownFrame_SetTimer(btn.cooldown,GetSpellCooldown(CAMPFIRE_ID)) 14 CooldownFrame_SetTimer(btn.cooldown,GetSpellCooldown(CAMPFIRE_ID))
14 self:SetScript("OnUpdate",nil) 15 self:SetScript("OnUpdate",nil)
17 18
18 -- Create button 19 -- Create button
19 function A.InitialiseCampFireBtn() 20 function A.InitialiseCampFireBtn()
20 if not GetTradeSkillLine() or InCombatLockdown() then return end 21 if not GetTradeSkillLine() or InCombatLockdown() then return end
21 22
22 -- create the frame 23 -- Create the frame
23 btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate") 24 btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate")
24 btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID))) 25 btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID)))
25 btn:SetHighlightTexture("Interface\\BUTTONS\\ButtonHilight-Square") 26 btn:SetHighlightTexture("Interface\\BUTTONS\\ButtonHilight-Square")
26 btn:SetSize(24,24) 27 btn:SetSize(24,24)
27 btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179) 28 btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179)
65 end 66 end
66 67
67 -- Hide button 68 -- Hide button
68 function A.HideCampFireBtn() 69 function A.HideCampFireBtn()
69 if btn then btn:Hide() end 70 if btn then btn:Hide() end
71 btn:UnregisterAllEvents()
70 end 72 end
71 73
72 -- Show button if applicable 74 -- Show button if applicable
73 function A.ManageCampFireBtn() 75 function A.ManageCampFireBtn()
74 -- Display only if the tradeskill is Cooking 76 -- Display only if the tradeskill is Cooking