View Single Post
11-20-12, 04:51 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
You want sth like this.

Lua Code:
  1. --functions
  2.  
  3.   local postUpdateDebuff = function(element, unit, button, index, offset)
  4.  
  5.     local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unit, index, "HARMFUL")
  6.     if not name then return end
  7.     local _, class = UnitClass(caster)
  8.     if not class then return end  
  9.     local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  10.     if not color then return end
  11.     --print(color)
  12.     button.border:SetBackdropBorderColor(color.r, color.g, color.b,1)
  13.  
  14.   end
  15.  
  16.   local postUpdateBuff = function(element, unit, button, index, offset)
  17.  
  18.     local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unit, index, "HELPFUL")
  19.     if not name then return end
  20.     local _, class = UnitClass(caster)
  21.     if not class then return end  
  22.     local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  23.     if not color then return end
  24.     --print(color)
  25.     button.border:SetBackdropBorderColor(color.r, color.g, color.b,1)
  26.  
  27.   end  
  28.  
  29.   local postUpdateAura = function(element, unit, button, index, offset)
  30.  
  31.     local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unit, index)
  32.     if not name then return end
  33.     local _, class = UnitClass(caster)
  34.     if not class then return end  
  35.     local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  36.     if not color then return end
  37.     --print(color)
  38.     button.border:SetBackdropBorderColor(color.r, color.g, color.b,1)
  39.  
  40.   end  
  41.  
  42.   --post update aura icon
  43.  
  44.   --self.Buffs.PostUpdateIcon = postUpdateBuff
  45.   --self.Debuffs.PostUpdateIcon = postUpdateDebuff
  46.   self.Auras.PostUpdateIcon = postUpdateAura

Which function you need to call depends on how you created your aura icons. If you used self.Buffs you use postUdateBuff ... etc.

Regarding UnitAura check: http://wowprogramming.com/docs/api/UnitAura
For the oUF documentation on auras read: https://github.com/haste/oUF/wiki/element---auras

I'm currently not sure. It may actually be possible to work with CreateAura instead of PostUpdateIcon because you can extract the unit from element:GetParent().unit.

That would look like this for Auras:

Lua Code:
  1. --function
  2.   local createIcon = function(element, index)
  3.  
  4.     local unit = element:GetParent().unit
  5.     if not unit then return end
  6.     local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unit, index)
  7.     if not name then return end
  8.     local _, class = UnitClass(caster)
  9.     if not class then return end  
  10.     local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  11.     if not color then return end
  12.     --print(color)
  13.     button.border:SetBackdropBorderColor(color.r, color.g, color.b,1)
  14.  
  15.   end  
  16.  
  17.   self.Auras.CreateIcon = createIcon

The benefit is that CreateIcon is only used once. But I'm not sure if it is sufficient (means if it is called each time a new aura is created, even if an aura existed already for the same index)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 11-20-12 at 05:09 AM.
  Reply With Quote