This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oUF_Resurrect.lua
98 lines (79 loc) · 2.09 KB
/
oUF_Resurrect.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
96
97
98
local _, ns = ...
local oUF = ns.oUF or oUF
local elementName = 'oUF Resurrect'
assert(oUF, elementName .. ' was unable to locate oUF install')
local LRI = LibStub('LibResInfo-1.0', true)
assert(LRI, elementName .. ' requires LibResInfo-1.0')
oUF.colors.resurrect = {
CASTING = {1, 1, 1},
MASSRES = {1, 1, 1},
SELFRES = {0.3, 0.3, 1},
PENDING = {0.3, 1, 0.3},
}
local function Update(self, event, unit)
if(unit ~= self.unit) then
return
end
local element = self.Resurrect
if(element.PreUpdate) then
element:PreUpdate()
end
local status, endTime, casterUnit = LRI:UnitHasIncomingRes(unit)
if(status) then
local colors = self.colors.resurrect[status]
element:SetVertexColor(colors[1], colors[2], colors[3])
element:Show()
else
element:Hide()
end
if(element.PostUpdate) then
return element:PostUpdate(status, endTime, casterUnit)
end
end
local function Path(self, ...)
return (self.Resurrect.Override or Update)(self, ...)
end
local function ForceUpdate(element)
local parent = element.__owner
return Path(parent, 'ForceUpdate', parent.unit)
end
local REGISTERED = {}
local function RegisterCallbacks(element)
table.insert(REGISTERED, element)
if(#REGISTERED == 1) then
LRI.RegisterAllCallbacks(elementName, function(event)
for index = 1, #oUF.objects do
local frame = oUF.objects[index]
if(frame.unit and frame.Resurrect) then
Path(frame, event, frame.unit)
end
end
end, true)
end
end
local function UnregisterCallbacks(element)
table.remove(REGISTERED, element)
if(#REGISTERED == 0) then
LRI.UnregisterAllCallbacks(elementName)
end
end
local function Enable(self)
local element = self.Resurrect
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
RegisterCallbacks(element)
if(element:IsObjectType('Texture') and not element:GetTexture()) then
element:SetTexture([[Interface\RaidFrame\Raid-Icon-Rez]])
end
return true
end
end
local function Disable(self)
local element = self.Resurrect
if(element) then
element:Hide()
UnregisterCallbacks(element)
end
end
oUF:AddElement('Resurrect', Path, Enable, Disable)