PageRenderTime 50ms CodeModel.GetById 44ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/Asphyxia/Tukui
Lua | 62 lines | 52 code | 10 blank | 0 comment | 9 complexity | 0662f85991c4d4325201bdb860426fce MD5 | raw file
 1local parent, ns = ...
 2local oUF = ns.oUF
 3
 4local function Update(self, event)
 5	local unit
 6	local method, pid, rid = GetLootMethod()
 7	if(method == 'master') then
 8		if(pid) then
 9			if(pid == 0) then
10				unit = 'player'
11			else
12				unit = 'party'..pid
13			end
14		elseif(rid) then
15			unit = 'raid'..rid
16		else
17			return
18		end
19
20		if(UnitIsUnit(unit, self.unit)) then
21			self.MasterLooter:Show()
22		elseif(self.MasterLooter:IsShown()) then
23			self.MasterLooter:Hide()
24		end
25	elseif(self.MasterLooter:IsShown()) then
26		self.MasterLooter:Hide()
27	end
28end
29
30local Path = function(self, ...)
31	return (self.MasterLooter.Override or Update) (self, ...)
32end
33
34local ForceUpdate = function(element)
35	return Path(element.__owner, 'ForceUpdate')
36end
37
38local function Enable(self, unit)
39	local masterlooter = self.MasterLooter
40	if(masterlooter) then
41		masterlooter.__owner = self
42		masterlooter.ForceUpdate = ForceUpdate
43
44		self:RegisterEvent('PARTY_LOOT_METHOD_CHANGED', Path)
45		self:RegisterEvent('PARTY_MEMBERS_CHANGED', Path)
46
47		if(masterlooter:IsObjectType('Texture') and not masterlooter:GetTexture()) then
48			masterlooter:SetTexture([[Interface\GroupFrame\UI-Group-MasterLooter]])
49		end
50
51		return true
52	end
53end
54
55local function Disable(self)
56	if(self.MasterLooter) then
57		self:UnregisterEvent('PARTY_LOOT_METHOD_CHANGED', Path)
58		self:UnregisterEvent('PARTY_MEMBERS_CHANGED', Path)
59	end
60end
61
62oUF:AddElement('MasterLooter', Path, Enable, Disable)