PageRenderTime 122ms CodeModel.GetById 81ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

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

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