comparison CampFireButton.lua @ 103:c8d527a9fb3a v1.0beta11

Better manage combat and secure buttons
author contrebasse
date Sat, 21 May 2011 14:19:33 +0200
parents 060f5d0f7a35
children 08ede537787b
comparison
equal deleted inserted replaced
102:e74ed53097d7 103:c8d527a9fb3a
5 local btn 5 local btn
6 local cookingName 6 local cookingName
7 7
8 -- Create button 8 -- Create button
9 function A.InitialiseCampFireBtn() 9 function A.InitialiseCampFireBtn()
10 if not GetTradeSkillLine() or InCombatLockdown() then return end
11
10 -- create the frame 12 -- create the frame
11 btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate") 13 btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate")
12 btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID))) 14 btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID)))
13 btn:SetSize(24,24) 15 btn:SetSize(24,24)
14 btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179) 16 btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179)
30 btn.cooldown:SetAllPoints(btn) 32 btn.cooldown:SetAllPoints(btn)
31 local CooldownFrame_SetTimer = CooldownFrame_SetTimer 33 local CooldownFrame_SetTimer = CooldownFrame_SetTimer
32 local GetSpellCooldown = GetSpellCooldown 34 local GetSpellCooldown = GetSpellCooldown
33 btn:SetScript("OnUpdate",function(self) CooldownFrame_SetTimer(self.cooldown,GetSpellCooldown(CAMPFIRE_ID)); end) 35 btn:SetScript("OnUpdate",function(self) CooldownFrame_SetTimer(self.cooldown,GetSpellCooldown(CAMPFIRE_ID)); end)
34 36
35 -- Save info
36 cookingName = GetSpellInfo(COOKING_ID)
37
38 -- Show if needed 37 -- Show if needed
39 A.ManageCampFireBtn() 38 A.ManageCampFireBtn()
40 end 39 end
41 40
42 -- Hide button 41 -- Hide button
44 if btn then btn:Hide() end 43 if btn then btn:Hide() end
45 end 44 end
46 45
47 -- Show button if applicable 46 -- Show button if applicable
48 function A.ManageCampFireBtn() 47 function A.ManageCampFireBtn()
49 if not btn then return end
50 -- Display only if the tradeskill is Cooking 48 -- Display only if the tradeskill is Cooking
51 local tradeskillName = GetTradeSkillLine() 49 if not cookingName then cookingName = GetSpellInfo(COOKING_ID) end
52 if tradeskillName ~= cookingName then 50 if GetTradeSkillLine() ~= cookingName then
53 btn:Hide() 51 if btn then btn:Hide() end
54 else 52 else
53 -- create button if necessary
54 if not btn then
55 A.InitialiseCampFireBtn()
56 end
57 -- It may not have been created
58 if not btn then return end
55 btn:Show() 59 btn:Show()
56 end 60 end
57 end 61 end