mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-30 23:46:57 +00:00
Add an option to show timestamps in chat copy
"Show Timestamps In Chat Copy" (chat text settings, on by default) is read each time chat copy opens. With it off, chat copy takes each line through pfUI.chat.StripTimestamp, which removes the exact timestamp AddMessage prepends: the configured color and brackets, so other bracketed text stays. Whispers are now recolored before the timestamp goes on, not after. The recolor turned the stamp's closing "|r " into "|r" plus the whisper color, so whisper lines did not match. The shown text and the saved history come out the same.
This commit is contained in:
+21
-6
@@ -779,6 +779,20 @@ pfUI:RegisterModule("chat", function ()
|
||||
local r,g,b,a = GetStringColor(C.chat.text.timecolor)
|
||||
local timecolorhex = rgbhex(r,g,b,a)
|
||||
|
||||
-- AddMessage puts the time between these at the start of each line
|
||||
local timestampStart = timecolorhex .. tleft
|
||||
local timestampEnd = tright .. "|r "
|
||||
|
||||
-- [ StripTimestamp ]
|
||||
-- Returns a chat line without the timestamp AddMessage put before it.
|
||||
function pfUI.chat.StripTimestamp(text)
|
||||
if C.chat.text.time ~= "1" or text:sub(1, #timestampStart) ~= timestampStart then
|
||||
return text
|
||||
end
|
||||
local _, last = text:find(timestampEnd, #timestampStart + 1, true)
|
||||
return last and text:sub(last + 1) or text
|
||||
end
|
||||
|
||||
local r,g,b = GetStringColor(C.chat.text.unknowncolor)
|
||||
local unknowncolorhex = rgbhex(r,g,b)
|
||||
|
||||
@@ -879,9 +893,15 @@ pfUI:RegisterModule("chat", function ()
|
||||
-- pushes the whisper colour code off position 1 and the find below fails
|
||||
local isWhisper = C.chat.global.whispermod == "1" and string.find(text, wcol, 1) == 1
|
||||
|
||||
if isWhisper then
|
||||
-- patch incoming whisper string to match the colors, before the
|
||||
-- timestamp so it keeps the form StripTimestamp looks for
|
||||
text = string.gsub(text, "|r", "|r" .. wcol)
|
||||
end
|
||||
|
||||
-- show timestamp in chat
|
||||
if C.chat.text.time == "1" then
|
||||
text = timecolorhex .. tleft .. date(C.chat.text.timeformat) .. tright .. "|r " .. text
|
||||
text = timestampStart .. date(C.chat.text.timeformat) .. timestampEnd .. text
|
||||
end
|
||||
|
||||
-- save chat history
|
||||
@@ -891,11 +911,6 @@ pfUI:RegisterModule("chat", function ()
|
||||
SaveChatHistory(frame:GetID(), text, a1, a2, a3)
|
||||
end
|
||||
|
||||
if isWhisper then
|
||||
-- patch incoming whisper string to match the colors
|
||||
text = string.gsub(text, "|r", "|r" .. wcol)
|
||||
end
|
||||
|
||||
frame:HookAddMessage(text, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)
|
||||
end
|
||||
|
||||
|
||||
@@ -75,6 +75,9 @@ pfUI:RegisterModule("chatcopy", function ()
|
||||
local lines = {}
|
||||
for index=1, frame:GetNumMessages() do
|
||||
local text, r, g, b = frame:GetMessageInfo(index)
|
||||
if C.chat.text.copytime == "0" then
|
||||
text = pfUI.chat.StripTimestamp(text)
|
||||
end
|
||||
local color = rgbhex(r, g, b)
|
||||
table.insert(lines, color .. text:gsub("|r", color))
|
||||
end
|
||||
|
||||
@@ -2892,6 +2892,8 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(nil, T["Timestamp Format"], C.chat.text, "timeformat", nil, nil, nil, nil, "STRING")
|
||||
CreateConfig(nil, T["Timestamp Brackets"], C.chat.text, "timebracket", nil, nil, nil, nil, "STRING")
|
||||
CreateConfig(nil, T["Timestamp Color"], C.chat.text, "timecolor", "color")
|
||||
-- read each time chat copy opens, so no reload
|
||||
CreateConfig(function() end, T["Show Timestamps In Chat Copy"], C.chat.text, "copytime", "checkbox")
|
||||
CreateConfig(nil, T["Hide Channel Names"], C.chat.text, "channelnumonly", "checkbox")
|
||||
CreateConfig(nil, T["Generate Playerlinks"], C.chat.text, "playerlinks", "checkbox")
|
||||
CreateConfig(nil, T["Enable URL Detection"], C.chat.text, "detecturl", "checkbox")
|
||||
|
||||
Reference in New Issue
Block a user