This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcooldowns.lua
95 lines (76 loc) · 2.73 KB
/
cooldowns.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
local _, addon = ...
local globalCooldown = 1.5
local function GetAlpha(self, duration)
-- local alpha = self.alpha.inactive
-- if self.Icon.Cooldown:GetCooldownDuration() > 0 then
-- alpha = self.alpha.active
-- end
local alpha = self.alpha.active
if self.Icon.Cooldown:GetCooldownDuration() == 0 and not InCombatLockdown() then
alpha = 0
end
return alpha
end
local function UpdateCooldown(self, event, ...)
-- if event == 'PLAYER_REGEN_DISABLED' then
-- self.Icon.Cooldown:SetDrawBling(true)
-- end
local start, duration, enable = GetSpellCooldown(self.spellID)
local charges, maxCharges, chargeStart, chargeDuration = GetSpellCharges(self.spellID)
if event == 'SPELL_UPDATE_CHARGES' then
if maxCharges ~= nil and maxCharges > 1 then
self.Icon.Count:SetText(charges)
else
self.Icon.Count:SetText('')
end
end
if charges and maxCharges and maxCharges > 1 and charges < maxCharges then
StartChargeCooldown(self.Icon, chargeStart, chargeDuration)
else
ClearChargeCooldown(self.Icon)
end
if duration > globalCooldown then
CooldownFrame_Set(self.Icon.Cooldown, start, duration, enable)
end
-- if self.Icon.Cooldown:GetCooldownDuration() == 0 then
-- self.Icon.Duration:SetText('RDY')
-- else
-- self.Icon.Duration:SetText()
-- end
if self.desaturate and self.Icon.Cooldown:GetCooldownDuration() > 0 then
self.Icon.Texture:SetDesaturated(true)
else
self.Icon.Texture:SetDesaturated(false)
end
local alpha = GetAlpha(self, duration)
self.Icon:SetAlpha(alpha)
if self.glowOverlay and alpha > 0 and IsSpellOverlayed(self.spellID) then
ActionButton_ShowOverlayGlow(self.Icon)
else
ActionButton_HideOverlayGlow(self.Icon)
end
if duration and self.PostUpdateHook then
self:PostUpdateHook()
end
-- if event == 'PLAYER_REGEN_ENABLED' then
-- self.Icon.Cooldown:SetDrawBling(false)
-- end
end
local function ScanCooldowns(self, event, ...)
for _, self in pairs(addon.cooldowns) do
if self:IsCurrentSpec() and FindSpellBookSlotBySpellID(self.spellID) then
UpdateCooldown(self, event, ...)
else
self.Icon:SetAlpha(0)
end
end
end
local events = CreateFrame('Frame')
events:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
events:RegisterEvent('PLAYER_REGEN_DISABLED')
events:RegisterEvent('PLAYER_REGEN_ENABLED')
events:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
events:RegisterEvent('SPELL_UPDATE_CHARGES')
events:RegisterEvent('SPELL_UPDATE_COOLDOWN')
events:RegisterEvent('SPELL_UPDATE_USABLE')
events:SetScript('OnEvent', ScanCooldowns)