Mercurial > wow > reagentmaker
comparison CampFireButton.lua @ 98:b980c00affcd
Added a button to cast a campfire
I got a problem with newlines and merging with a non-Mercurial repository, I hope noting broke...
author | contrebasse |
---|---|
date | Fri, 20 May 2011 18:32:43 +0200 |
parents | |
children | 060f5d0f7a35 |
comparison
equal
deleted
inserted
replaced
97:61439697f8c5 | 98:b980c00affcd |
---|---|
1 local addonName, A = ... | |
2 | |
3 local CAMPFIRE_ID = 818 | |
4 local COOKING_ID = 2550 | |
5 local btn | |
6 local cookingName | |
7 | |
8 -- Create button | |
9 function A.InitialiseCampFireBtn() | |
10 -- create the frame | |
11 btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate") | |
12 btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID))) | |
13 btn:SetSize(24,24) | |
14 btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179) | |
15 | |
16 -- Set the action | |
17 btn:SetAttribute("type", "spell") | |
18 btn:SetAttribute("spell", CAMPFIRE_ID) | |
19 | |
20 -- Set the tooltip | |
21 btn:SetScript("OnEnter",function(self) | |
22 GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") | |
23 GameTooltip:SetSpellByID(CAMPFIRE_ID) | |
24 GameTooltip:Show() | |
25 end) | |
26 btn:SetScript("OnLeave",function() GameTooltip:Hide(); end) | |
27 | |
28 -- Add cooldown | |
29 btn.cooldown = CreateFrame("Cooldown",nil,btn) | |
30 btn.cooldown:SetAllPoints(btn) | |
31 local CooldownFrame_SetTimer = CooldownFrame_SetTimer | |
32 local GetSpellCooldown = GetSpellCooldown | |
33 btn:SetScript("OnUpdate",function(self) CooldownFrame_SetTimer(self.cooldown,GetSpellCooldown(CAMPFIRE_ID)); end) | |
34 | |
35 -- Save info | |
36 cookingName = GetSpellInfo(COOKING_ID) | |
37 | |
38 -- Show if needed | |
39 A.ManageCampFireBtn() | |
40 end | |
41 | |
42 -- Hide button | |
43 function A.HideCampFireBtn() | |
44 btn:Hide() | |
45 end | |
46 | |
47 -- Show button if applicable | |
48 function A.ManageCampFireBtn() | |
49 if not btn then return end | |
50 -- Display only if the tradeskill is Cooking | |
51 local tradeskillName = GetTradeSkillLine() | |
52 if tradeskillName ~= cookingName then | |
53 btn:Hide() | |
54 else | |
55 btn:Show() | |
56 end | |
57 end |