View Single Post
Old 05-26-11, 01:55 PM   #2
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 312
How did you created the arror? (is it a texture, what is its parent frame and what events are registered to the frame?)

You have 2 options: creating an element as an oUF module and registering the proper events so it updates correctly, or just do it directly in the layout. This is what I currently use for threat, maybe it helps you a bit

create the element and expose it to the namespace
lua Code:
  1. local AddThreatHighlight = function(self, event, unit)
  2.     if (unit ~= self.unit) then return end
  3.  
  4.     local status = UnitThreatSituation(unit)
  5.     if (status and status > 0) then
  6.         local r, g, b = GetThreatStatusColor(status)
  7.    
  8.         self.FrameBackdrop:SetBackdropBorderColor(r, g, b)
  9.     else
  10.         self.FrameBackdrop:SetBackdropBorderColor(0, 0, 0)
  11.     end
  12. end
  13. ns.AddThreatHighlight = AddThreatHighlight

enable it for the frame:
lua Code:
  1. self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", ns.AddThreatHighlight)

I'm unsure if an element as a module has any benefits.

And if you plan to release your layout, you should use metatables for the colors and not overwrite the oUF dafault table, in case a user wants to use a diffenrent layout for say raid frames or so.
lua Code:
  1. ns.colors = setmetatable({
  2.     power = setmetatable({
  3.         ['MANA'] = {0.0, 0.56, 1.0},
  4.         ['RAGE'] = {1.0,0,0},
  5.         ['FOCUS'] = {1.0,0.75,0.25},
  6.         ['ENERGY'] = {1.0, 0.9, 0.35},
  7.         ['RUNIC_POWER'] = {0.44,0.44,0.44},
  8.     }, {__index = oUF.colors.power}),
  9. }, {__index = oUF.colors})

Last edited by Rainrider : 05-26-11 at 02:01 PM.
Rainrider is offline   Reply With Quote