mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-10 07:30:01 +00:00
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:
+2
-2
@@ -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
|
||||
|
||||
@@ -315,7 +315,7 @@ pfUI:RegisterModule("buffwatch", function ()
|
||||
sr, sg, sb, sa = 1, .3, .3, 1
|
||||
end
|
||||
if frame.config.colorstacks == "1" then
|
||||
frame.bars[bar].stacks:SetText("|cff" .. string.format("%02x%02x%02x", sr*255, sg*255, sb*255) .. data[5])
|
||||
frame.bars[bar].stacks:SetText(rgbhex(sr,sg,sb) .. data[5])
|
||||
else
|
||||
frame.bars[bar].stacks:SetText(data[5])
|
||||
end
|
||||
|
||||
+9
-12
@@ -601,7 +601,7 @@ pfUI:RegisterModule("chat", 20400, function ()
|
||||
-- read and parse whisper color settings
|
||||
local cr, cg, cb, ca = strsplit(",", C.chat.global.whisper)
|
||||
cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb)
|
||||
local wcol = string.format("%02x%02x%02x",cr * 255,cg * 255, cb * 255)
|
||||
local wcol = rgbhex(cr, cg, cb)
|
||||
|
||||
-- read and parse chat bracket settings
|
||||
local left = "|r" .. string.sub(C.chat.text.bracket, 1, 1)
|
||||
@@ -626,15 +626,15 @@ pfUI:RegisterModule("chat", 20400, function ()
|
||||
_G.CHAT_YELL_GET = left .. "Y" .. right ..default
|
||||
|
||||
if C.chat.global.whispermod == "1" then
|
||||
_G.CHAT_WHISPER_GET = '|cff' .. wcol .. '[W]' .. default
|
||||
_G.CHAT_WHISPER_GET = wcol .. '[W]' .. default
|
||||
_G.CHAT_WHISPER_INFORM_GET = '[W]' .. default
|
||||
end
|
||||
|
||||
local r,g,b,a = strsplit(",", C.chat.text.timecolor)
|
||||
local timecolorhex = string.format("%02x%02x%02x%02x", a*255, r*255, g*255, b*255)
|
||||
local timecolorhex = rgbhex(r,g,b,a)
|
||||
|
||||
local r,g,b = strsplit(",", C.chat.text.unknowncolor)
|
||||
local unknowncolorhex = string.format("%02x%02x%02x", r*255, g*255, b*255)
|
||||
local unknowncolorhex = rgbhex(r,g,b)
|
||||
|
||||
for i=1,NUM_CHAT_WINDOWS do
|
||||
if not _G["ChatFrame"..i].HookAddMessage then
|
||||
@@ -668,17 +668,14 @@ pfUI:RegisterModule("chat", 20400, function ()
|
||||
local class = GetUnitData(name)
|
||||
if class then
|
||||
if class ~= UNKNOWN then
|
||||
color = string.format("%02x%02x%02x",
|
||||
RAID_CLASS_COLORS[class].r * 255,
|
||||
RAID_CLASS_COLORS[class].g * 255,
|
||||
RAID_CLASS_COLORS[class].b * 255)
|
||||
color = rgbhex(RAID_CLASS_COLORS[class])
|
||||
match = true
|
||||
end
|
||||
end
|
||||
|
||||
if C.chat.text.tintunknown == "1" or match then
|
||||
text = string.gsub(text, "|Hplayer:"..name.."|h%["..name.."%]|h(.-:-)",
|
||||
left.."|cff"..color.."|Hplayer:"..name.."|h" .. name .. "|h|r"..right.."%1")
|
||||
left..color.."|Hplayer:"..name.."|h" .. name .. "|h|r"..right.."%1")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -695,13 +692,13 @@ pfUI:RegisterModule("chat", 20400, function ()
|
||||
|
||||
-- show timestamp in chat
|
||||
if C.chat.text.time == "1" then
|
||||
text = "|c" .. timecolorhex .. tleft .. date(C.chat.text.timeformat) .. tright .. "|r " .. text
|
||||
text = timecolorhex .. tleft .. date(C.chat.text.timeformat) .. tright .. "|r " .. text
|
||||
end
|
||||
|
||||
if C.chat.global.whispermod == "1" then
|
||||
-- patch incoming whisper string to match the colors
|
||||
if string.find(text, '|cff'..wcol, 1) == 1 then
|
||||
text = string.gsub(text, "|r", "|r|cff" .. wcol)
|
||||
if string.find(text, wcol, 1) == 1 then
|
||||
text = string.gsub(text, "|r", "|r" .. wcol)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -75,7 +75,7 @@ pfUI:RegisterModule("socialmod", function ()
|
||||
local lcolor = GetDifficultyColor(tonumber(level)) or { 1, 1, 1 }
|
||||
|
||||
zone = ( zone == playerzone and "|cffffffff" or "|cffaaaaaa" ) .. zone .. "|r"
|
||||
name = "|cff" .. string.format("%02x%02x%02x", ccolor.r*255, ccolor.g*255, ccolor.b*255) .. name .. "|r"
|
||||
name = RgbHex(ccolor) .. name .. "|r"
|
||||
|
||||
_G["FriendsFrameFriendButton"..i..FRIENDS_NAME_LOCATION]:SetText(format(TEXT(FRIENDS_LIST_TEMPLATE), name, zone, status))
|
||||
_G["FriendsFrameFriendButton"..i.."ButtonTextInfo"]:SetText(format(TEXT(FRIENDS_LEVEL_TEMPLATE), level, class))
|
||||
|
||||
Reference in New Issue
Block a user