PageRenderTime 96ms CodeModel.GetById 35ms app.highlight 2ms RepoModel.GetById 58ms app.codeStats 0ms

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

http://github.com/Asphyxia/Tukui
Lua | 46 lines | 36 code | 10 blank | 0 comment | 4 complexity | fbb049f86c66349172e0dcd5097d0549 MD5 | raw file
 1local parent, ns = ...
 2local oUF = ns.oUF
 3
 4local Update = function(self, event)
 5	local inPhase = UnitInPhase(self.unit)
 6	local picon = self.PhaseIcon
 7
 8	if(inPhase) then
 9		picon:Hide()
10	else
11		picon:Show()
12	end
13end
14
15local Path = function(self, ...)
16	return (self.PhaseIcon.Override or Update) (self, ...)
17end
18
19local ForceUpdate = function(element)
20	return Path(element.__owner, 'ForceUpdate')
21end
22
23local Enable = function(self)
24	local picon = self.PhaseIcon
25	if(picon) then
26		picon.__owner = self
27		picon.ForceUpdate = ForceUpdate
28
29		self:RegisterEvent('UNIT_PHASE', Path)
30
31		if(picon:IsObjectType'Texture' and not picon:GetTexture()) then
32			picon:SetTexture[[Interface\TargetingFrame\UI-PhasingIcon]]
33		end
34
35		return true
36	end
37end
38
39local Disable = function(self)
40	local picon = self.PhaseIcon
41	if(picon) then
42		self:UnregisterEvent('UNIT_PHASE', Path)
43	end
44end
45
46oUF:AddElement('PhaseIcon', Path, Enable, Disable)