-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOverlay.lua
More file actions
72 lines (61 loc) · 2.64 KB
/
Copy pathOverlay.lua
File metadata and controls
72 lines (61 loc) · 2.64 KB
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
local _, addon = ...
CDMButtonAurasOverlayMixin = {}
-- local timerColorCurve = C_CurveUtil.CreateColorCurve()
-- timerColorCurve:SetType(Enum.LuaCurveType.Linear)
-- timerColorCurve:AddPoint(0.0, CreateColor(1, 0, 0, 1))
-- timerColorCurve:AddPoint(3.0, CreateColor(1, 1, 0, 1))
-- timerColorCurve:AddPoint(10.0, CreateColor(1, 1, 1, 1))
function CDMButtonAurasOverlayMixin:OnLoad()
local parent = self:GetParent()
PixelUtil.SetSize(self, parent:GetSize())
if parent.cooldown then
self:SetFrameLevel(parent.cooldown:GetFrameLevel() + 1)
end
-- Using Cooldown frame here only for the Abbrev capability. Once
-- Blizzard provides the promised secret-safe SecondsFormatter then
-- it can be changed to a FontString.
self.Cooldown:SetPoint("TOPLEFT", parent.icon, "LEFT", 5, 0)
self.Cooldown:SetPoint("BOTTOMRIGHT", parent.icon, "BOTTOM", 0, 3)
self.Cooldown:SetDrawSwipe(false)
self.Cooldown:SetCountdownFont("NumberFontNormal")
self.Cooldown:SetCountdownAbbrevThreshold(60)
self.Cooldown:SetScript('OnCooldownDone', function () self:Update() end)
end
-- The problem here, matching by name is blizzard has multiple CDM items of the
-- same buff. This is incredibly stupid, the player sees multiple identical
-- looking buffs in the cooldown settings and has no idea why. Another shitfest
-- DUe to their rushed and foolish addon crusade. Assuming that only one of
-- them will be active, we shouldn't nil an aura unless it came from the same
-- cooldownID. In an ideal world we would just use whichever is longer but
-- hey, Blizzard hates us and usability and competence.
function CDMButtonAurasOverlayMixin:SetAura(unit, auraInstanceID, cooldownID)
if cooldownID ~= nil and auraInstanceID == nil and self.auraInstanceID ~= nil then
return
else
self.cooldownID = cooldownID
self.unit = unit
self.auraInstanceID = auraInstanceID
end
end
function CDMButtonAurasOverlayMixin:Update()
if self.unit and self.auraInstanceID then
local duration = C_UnitAuras.GetAuraDuration(self.unit, self.auraInstanceID)
if duration then
self.Cooldown:SetCooldownFromDurationObject(duration, true)
self.Cooldown:Show()
else
self.Cooldown:Hide()
end
local count = C_UnitAuras.GetAuraApplicationDisplayCount(self.unit, self.auraInstanceID)
self.Stacks:SetText(count)
if self.unit == 'player' then
self.Glow:SetVertexColor(0, 0.7, 0, 0.5)
else
self.Glow:SetVertexColor(1, 0, 0, 0.5)
end
self.Glow:Show()
self:Show()
else
self:Hide()
end
end