PageRenderTime 308ms CodeModel.GetById 89ms app.highlight 9ms RepoModel.GetById 90ms app.codeStats 64ms

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

http://github.com/Asphyxia/Tukui
Lua | 45 lines | 36 code | 9 blank | 0 comment | 5 complexity | e2aa25c72514f22d506a9ac5b172c529 MD5 | raw file
 1local parent, ns = ...
 2local oUF = ns.oUF
 3
 4local Update = function(self, event)
 5	if(UnitAffectingCombat"player") then
 6		self.Combat:Show()
 7	else
 8		self.Combat:Hide()
 9	end
10end
11
12local Path = function(self, ...)
13	return (self.Combat.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 combat = self.Combat
22	if(combat and unit == 'player') then
23		combat.__owner = self
24		combat.ForceUpdate = ForceUpdate
25
26		self:RegisterEvent("PLAYER_REGEN_DISABLED", Path)
27		self:RegisterEvent("PLAYER_REGEN_ENABLED", Path)
28
29		if(combat:IsObjectType"Texture" and not combat:GetTexture()) then
30			combat:SetTexture[[Interface\CharacterFrame\UI-StateIcon]]
31			combat:SetTexCoord(.5, 1, 0, .49)
32		end
33
34		return true
35	end
36end
37
38local Disable = function(self)
39	if(self.Combat) then
40		self:UnregisterEvent("PLAYER_REGEN_DISABLED", Path)
41		self:UnregisterEvent("PLAYER_REGEN_ENABLED", Path)
42	end
43end
44
45oUF:AddElement('Combat', Path, Enable, Disable)