PageRenderTime 72ms CodeModel.GetById 30ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

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

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