Originally Posted by haste
Based on how your function looks (ie. dynamic function calling) - I would say no. The hex function in oUF is there to convert colors into strings for text, while your function is there for a generalized coloring function.
Regarding the two solutions - I would call the second one cleaner.
|
Apparently there would even be an easier way, i've found this to be working just fine, and as i wasnt' using the Hex function anywhere else:
Code:
local function UpdateColor(self, element, unit, func)
if(UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then
r, g, b = colors.disconnected
elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
r, g, b = colors.tapped
elseif(unit == 'player' or unit == 'pet') then
local num, str = UnitPowerType(unit)
r, g, b = colors.power[str]
elseif(UnitIsPlayer(unit)) then
local _, class = UnitClass(unit)
r, g, b = colors.class[class]
else
local reaction = UnitReaction(unit, 'player')
r, g, b = FACTION_BAR_COLORS[reaction]
end
if(type(r) == 'table') then
if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
end
if(not r or not g or not b) then r, g, b = 1, 1, 1 end
if(func == 'SetVertexColor') then
element[func](element, r * .33, g * .33, b * .33)
else
element[func](element, r, g, b)
end
end