api: add and use rgbhex function

* A memoizing method to cache and return hex colorstrings from rgb input.
* Refactor all occurences of adhoc rgb to hex string concatenation to use the new method
* Refactor chat module to use it
This commit is contained in:
Road-block
2019-05-01 15:23:05 +02:00
committed by shagu
parent 0ea4d54f24
commit cf4c9ac361
8 changed files with 58 additions and 28 deletions
+2 -2
View File
@@ -64,8 +64,8 @@ pfUI:RegisterModule("afkcam", 20400, function ()
local class = GetUnitData(arg2 or "")
local author, msg
if class and class ~= UNKNOWN then
local class_color = string.format("%02x%02x%02x", RAID_CLASS_COLORS[class].r * 255, RAID_CLASS_COLORS[class].g * 255, RAID_CLASS_COLORS[class].b * 255)
author = string.format("|cff%s%s|r",class_color,arg2)
local class_color = rgbhex(RAID_CLASS_COLORS[class])
author = string.format("%s%s|r",class_color,arg2)
else
author = arg2
end