diff --git a/api/config.lua b/api/config.lua index a8166f0e..bb9c1e8b 100644 --- a/api/config.lua +++ b/api/config.lua @@ -825,6 +825,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("chat", "text", "timeformat", "%H:%M:%S") pfUI:UpdateConfig("chat", "text", "timebracket", "[]") pfUI:UpdateConfig("chat", "text", "timecolor", ".8,.8,.8,1") + pfUI:UpdateConfig("chat", "text", "copytime", "1") pfUI:UpdateConfig("chat", "text", "tintunknown", "1") pfUI:UpdateConfig("chat", "text", "unknowncolor", ".7,.7,.7,1") pfUI:UpdateConfig("chat", "text", "channelnumonly", "1") diff --git a/modules/chat.lua b/modules/chat.lua index 4bcf94ab..c790644e 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -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 diff --git a/modules/chatcopy.lua b/modules/chatcopy.lua index da16bc40..71d0eae5 100644 --- a/modules/chatcopy.lua +++ b/modules/chatcopy.lua @@ -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 diff --git a/modules/gui.lua b/modules/gui.lua index 7b0854f7..0509f383 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -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")