vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Class Button |
||
3 | --]] |
||
4 | |||
5 | BClassButton = { |
||
6 | --constructor |
||
7 | Create = function(id, parent) |
||
8 | local button = BBasicActionButton.Create(id, parent:GetName() .. "Button" .. id, parent, 30); |
||
9 | |||
10 | if not BActionSets.g.hideHotkeys then |
||
11 | BClassButton.UpdateHotkey(button); |
||
12 | end |
||
13 | |||
14 | BClassButton.SetScripts(button); |
||
15 | |||
16 | return button; |
||
17 | end, |
||
18 | |||
19 | --load scripts |
||
20 | SetScripts = function(button) |
||
21 | button:SetScript("OnClick", BClassButton.OnClick); |
||
22 | button:SetScript("OnEnter", BClassButton.OnEnter); |
||
23 | button:SetScript("OnLeave", BClassButton.OnLeave); |
||
24 | end, |
||
25 | |||
26 | --[[ OnX Functions ]]-- |
||
27 | |||
28 | OnClick = function() |
||
29 | this:SetChecked(not this:GetChecked() ); |
||
30 | CastShapeshiftForm(this:GetID()); |
||
31 | end, |
||
32 | |||
33 | OnEnter = function() |
||
34 | if BActionSets.g.tooltips then |
||
35 | if GetCVar("UberTooltips") == "1" then |
||
36 | GameTooltip_SetDefaultAnchor(GameTooltip, this); |
||
37 | else |
||
38 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
39 | end |
||
40 | GameTooltip:SetShapeshift(this:GetID()); |
||
41 | end |
||
42 | end, |
||
43 | |||
44 | OnLeave = function() |
||
45 | GameTooltip:Hide(); |
||
46 | end, |
||
47 | |||
48 | Update = function(button) |
||
49 | local texture, name, isActive, isCastable = GetShapeshiftFormInfo(button:GetID()); |
||
50 | button:SetChecked(isActive); |
||
51 | |||
52 | --update icon |
||
53 | local icon = getglobal(button:GetName() .. "Icon"); |
||
54 | icon:SetTexture(texture); |
||
55 | if isCastable then |
||
56 | icon:SetVertexColor(1.0, 1.0, 1.0); |
||
57 | else |
||
58 | icon:SetVertexColor(0.4, 0.4, 0.4); |
||
59 | end |
||
60 | |||
61 | --update cooldown |
||
62 | local cooldown = getglobal(button:GetName() .. "Cooldown"); |
||
63 | if texture then |
||
64 | cooldown:Show(); |
||
65 | else |
||
66 | cooldown:Hide(); |
||
67 | end |
||
68 | local start, duration, enable = GetShapeshiftFormCooldown(button:GetID()); |
||
69 | CooldownFrame_SetTimer(cooldown, start, duration, enable); |
||
70 | end, |
||
71 | |||
72 | UpdateHotkey = function(button) |
||
73 | BBasicActionButton.UpdateHotkey(button, "SHAPESHIFTBUTTON"); |
||
74 | end, |
||
75 | } |