View Single Post
10-25-08, 06:26 PM   #157
Balkeep
A Cyclonian
 
Balkeep's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 43
I have nasty issue with color updating...
Im trying to make some kind of visual representation of some buffs and debuffs on frames BUT...
I was trying to start from coloring of the frames... I was testing it on my pala and basicly code stollen fro banzai works pretty well BUT only on targettarget, tagettargettarget and focustarget frames... (maybe group frames aswel havent tested that yet) and it refuses to work on player target and focus.
Im using following code, can some please tell me why it only updates colors of player by reloading ui, and target by untargeting and then targeting that unit again, so basicly update occures on recreating of that frames only... why?
Code:
--Buffs approach
local function Buffed(unit, auraName)
	for i=1,100 do
		if auraName == select(1,UnitAura(unit, i))
		then 
			return true
		else
			return false
		end
	end
end
local ignoredUnits = {
	target = false,
	targettarget = false,
	targettargettarget = false,
}
local function ApplyColor(frame, event, unit, bar)
	if not ignoredUnits[unit] then
		if(Buffed(unit, "Seal of Righteousness"))
			then
				bar:SetStatusBarColor(204/255, 204/255, 255/255)
		end
	end

	oUF:UNIT_MAXHEALTH(event, unit)
end
local function UpdateColor(frame)
	local o = frame.PostUpdateHealth
	frame.PostUpdateHealth = function(...)
		if o then o(...) end
		ApplyColor(...)
	end
end
for i, frame in ipairs(oUF.objects) do UpdateColor(frame) end
oUF:RegisterInitCallback(UpdateColor)