recent chat: colorize chat correctly ver2
This commit is contained in:
+8
-10
@@ -13373,33 +13373,30 @@
|
|||||||
chatTypeIndexToName[ GetChatTypeIndex(chatType) ] = chatType
|
chatTypeIndexToName[ GetChatTypeIndex(chatType) ] = chatType
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- live-grab & colourize routine
|
||||||
local function ShowChatbox(chatFrame)
|
local function ShowChatbox(chatFrame)
|
||||||
edit:ClearFocus()
|
edit:ClearFocus()
|
||||||
edit:SetText("")
|
edit:SetText("")
|
||||||
|
|
||||||
local num = chatFrame:GetNumMessages()
|
local num = chatFrame:GetNumMessages()
|
||||||
if num == 0 then return end
|
if num == 0 then return end
|
||||||
|
|
||||||
-- choose your start… (e.g. oldest N lines)
|
local start = 1 -- or picked offset
|
||||||
local start = 1
|
|
||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
for i = start, num do
|
for i = start, num do
|
||||||
local msg, _, lineID = chatFrame:GetMessageInfo(i)
|
local msg, _, lineID = chatFrame:GetMessageInfo(i)
|
||||||
if msg then
|
if msg then
|
||||||
-- 1) strip icon/atlas tags however you like
|
-- strip icons/atlases
|
||||||
msg = gsub(msg, "|T.-|t", "")
|
msg = gsub(msg, "|T.-|t", "")
|
||||||
msg = gsub(msg, "|A.-|a", "")
|
msg = gsub(msg, "|A.-|a", "")
|
||||||
|
|
||||||
-- 2) pick up the right color
|
-- pick up the right color
|
||||||
local info = ChatTypeInfo[ chatTypeIndexToName[lineID] ]
|
local info = ChatTypeInfo[ chatTypeIndexToName[lineID] ]
|
||||||
local r,g,b = info and info.r, info.g, info.b or 1,1,1
|
local r,g,b = (info and info.r) or 1, (info and info.g) or 1, (info and info.b) or 1
|
||||||
|
|
||||||
-- 3) wrap in hex
|
-- wrap in hex + reset
|
||||||
local hex = format("|cff%02x%02x%02x", r*255, g*255, b*255)
|
local hex = format("|cff%02x%02x%02x", r*255, g*255, b*255)
|
||||||
msg = hex .. msg .. "|r"
|
msg = hex .. msg:gsub("|r","|r"..hex) .. "|r"
|
||||||
|
|
||||||
-- 4) insert into copy window
|
|
||||||
edit:Insert(msg)
|
edit:Insert(msg)
|
||||||
edit:Insert("\n")
|
edit:Insert("\n")
|
||||||
count = count + 1
|
count = count + 1
|
||||||
@@ -13408,6 +13405,7 @@
|
|||||||
|
|
||||||
title.count:SetText("Messages: "..count)
|
title.count:SetText("Messages: "..count)
|
||||||
ResizeEdit(count)
|
ResizeEdit(count)
|
||||||
|
-- scroll to bottom
|
||||||
scroll:SetVerticalScroll(scroll:GetVerticalScrollRange())
|
scroll:SetVerticalScroll(scroll:GetVerticalScrollRange())
|
||||||
frame:Show()
|
frame:Show()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user