PageRenderTime 53ms CodeModel.GetById 26ms app.highlight 2ms RepoModel.GetById 23ms app.codeStats 0ms

/Tukui/modules/unitframes/core/oUF/elements/resurrect.lua

http://github.com/Asphyxia/Tukui
Lua | 49 lines | 38 code | 11 blank | 0 comment | 6 complexity | ad2353e0938d8c730f2474eada794a0d MD5 | raw file
 1local WoW42 = select(4, GetBuildInfo()) == 40200
 2if(not WoW42) then return end
 3
 4local parent, ns = ...
 5local oUF = ns.oUF
 6
 7local Update = function(self, event)
 8	local incomingResurrect = UnitHasIncomingResurrection(self.unit)
 9	local resurrect = self.ResurrectIcon
10
11	if(incomingResurrect) and UnitIsDeadOrGhost(self.unit) and UnitIsConnected(self.unit) then
12		resurrect:Show()
13	else
14		resurrect:Hide()
15	end
16end
17
18local Path = function(self, ...)
19	return (self.ResurrectIcon.Override or Update) (self, ...)
20end
21
22local ForceUpdate = function(element)
23	return Path(element.__owner, 'ForceUpdate')
24end
25
26local Enable = function(self)
27	local resurrect = self.ResurrectIcon
28	if(resurrect) then
29		resurrect.__owner = self
30		resurrect.ForceUpdate = ForceUpdate
31
32		self:RegisterEvent('INCOMING_RESURRECT_CHANGED', Path)
33
34		if(resurrect:IsObjectType('Texture') and not resurrect:GetTexture()) then
35			resurrect:SetTexture[[Interface\RaidFrame\Raid-Icon-Rez]]
36		end
37
38		return true
39	end
40end
41
42local Disable = function(self)
43	local resurrect = self.ResurrectIcon
44	if(resurrect) then
45		self:UnregisterEvent('INCOMING_RESURRECT_CHANGED', Path)
46	end
47end
48
49oUF:AddElement('ResurrectIcon', Path, Enable, Disable)