PageRenderTime 193ms CodeModel.GetById 92ms app.highlight 2ms RepoModel.GetById 98ms app.codeStats 0ms

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

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