Quantcast
WoWInterface: SVN - fernir_UI - Rev 2 - /oUF/elements/leader.lua

WoWInterface SVN fernir_UI

[/] [oUF/] [elements/] [leader.lua] - Rev 2

Compare with Previous | Blame | View Log

local parent, ns = ...
local oUF = ns.oUF

local Update = function(self, event)
        local unit = self.unit
        if((UnitInParty(unit) or UnitInRaid(unit)) and UnitIsPartyLeader(unit)) then
                self.Leader:Show()
        else
                self.Leader:Hide()
        end
end

local Enable = function(self)
        local leader = self.Leader
        if(leader) then
                self:RegisterEvent("PARTY_LEADER_CHANGED", Update)
                self:RegisterEvent("PARTY_MEMBERS_CHANGED", Update)

                if(leader:IsObjectType"Texture" and not leader:GetTexture()) then
                        leader:SetTexture[[Interface\GroupFrame\UI-Group-LeaderIcon]]
                end

                return true
        end
end

local Disable = function(self)
        local leader = self.Leader
        if(leader) then
                self:UnregisterEvent("PARTY_LEADER_CHANGED", Update)
                self:UnregisterEvent("PARTY_MEMBERS_CHANGED", Update)
        end
end

oUF:AddElement('Leader', Update, Enable, Disable)

Compare with Previous | Blame