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
+1 -1
View File
@@ -133,7 +133,7 @@ pfUI:RegisterModule("chatcopy", 20400, function ()
local AddMessage = frame.AddMessage
frame.AddMessage = function(self,msg,r,g,b)
if msg and r and g and b then
local col = string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
local col = rgbhex(r,g,b)
table.insert(history, 1, col..string.gsub(msg, "|r", col))
elseif msg then
table.insert(history, 1, "|cffffffff"..msg)