|
local function truncate(value) |
if(value >= 1e6) then |
return string.format('%dm', value / 1e6) |
return string_format('%dm', value / 1e6) |
elseif(value >= 1e4) then |
return string.format('%dk', value / 1e3) |
return string_format('%dk', value / 1e3) |
else |
return value |
end |
end |
|
local function Hex(r, g, b) |
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 |
|
return string.format('|cff%02x%02x%02x', r*255, g*255, b*255) |
oUF.Tags['[colorpp]'] = function(unit) |
local num, str = UnitPowerType(unit) |
local c = colors.power[str] |
return string_format('|cff%02x%02x%02x', c[1] * 255, c[2] * 255, c[3] * 255) |
end |
|
oUF.Tags['[colorpp]'] = function(u) local n,s = UnitPowerType(u) return Hex(colors.power[s]) end |
oUF.Tags['[colorinfo]'] = function(u) |
if(UnitIsTapped(u) and not UnitIsTappedByPlayer(u)) then |
return Hex(colors.tapped) |
elseif(not UnitIsConnected(u)) then |
return Hex(colors.disconnected) |
elseif(not UnitIsPlayer(u)) then |
return Hex(UnitSelectionColor(u)) |
oUF.Tags['[colorinfo]'] = function(unit) |
if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then |
local c = colors.tapped |
return string_format('|cff%02x%02x%02x', c[1] * 255, c[2] * 255, c[3] * 255) |
elseif(not UnitIsConnected(unit)) then |
local c = colors.disconnected |
return string_format('|cff%02x%02x%02x', c[1] * 255, c[2] * 255, c[3] * 255) |
elseif(not UnitIsPlayer(unit)) then |
local r, g, b = UnitSelectionColor(unit) |
return string_format('|cff%02x%02x%02x', r * 255, g * 255, b * 255) |
else |
return Hex(1, 1, 1) |
return '|cffffffff' |
end |
end |
|