View Single Post
01-14-09, 07:53 AM   #200
Blood Druid
A Fallenroot Satyr
Join Date: Oct 2008
Posts: 26
Originally Posted by haste View Post
I fixed the missing coordinate, and the values I use are the ones from the Blizzard XML.
ty


Originally Posted by haste View Post
I'll have to check the ML behavior later however.
Here my code (it I already post):
Code:
local parent = debugstack():match[[\AddOns\(.-)\]]
local global = GetAddOnMetadata(parent, 'X-oUF')
assert(global, 'X-oUF needs to be defined in the parent add-on.')
local oUF = _G[global]

local Update = function(self, event)
	if(UnitIsPartyLeader(self.unit)) then
		self.Leader:Show()
	else
		self.Leader:Hide()
	end
	if self.MasterIcon then
		local isML = false
		local lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod()
		if (masterlooterRaidID ~= nil) then
			if (masterlooterRaidID < 10) then
				if (UnitName('raid0'..masterlooterRaidID) == UnitName(self.unit)) then
					isML = true
				end
			else
				if (UnitName('raid'..masterlooterRaidID) == UnitName(self.unit)) then
					isML = true
				end
			end
		elseif (masterlooterPartyID ~= nil) then
			if masterlooterPartyID <=0 then
				masterlooterPartyID = 'player'
			else
				masterlooterPartyID = 'party'..masterlooterPartyID
			end	
			if (UnitName(masterlooterPartyID) == UnitName(self.unit)) then
				isML = true
			end
		end	
		if isML then
			if (self.Leader:IsShown()) then
				if (self.unit == 'player') then
					self.MasterIcon:SetPoint(self.Leader:GetPoint(), self.Leader, 'TOPLEFT', 1, 0)
				else
					self.MasterIcon:SetPoint(self.Leader:GetPoint(), self.Leader, 'TOPRIGHT', -3, 0)
				end
			else
				self.MasterIcon:SetPoint(self.Leader:GetPoint())
			end
			self.MasterIcon:Show()
		else
			self.MasterIcon:Hide()
		end
	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

		local masterIcon = self.MasterIcon
		if(masterIcon) then
			if(masterIcon:IsObjectType"Texture" and not masterIcon:GetTexture()) then
				masterIcon:SetTexture[[Interface\GroupFrame\UI-Group-MasterLooter]]
			end
		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)
Yes it bulky, but dependably works 7 months