Quantcast WoWInterface - View Single Post - Temporary Chat Frames/Community Chat Frame/New Chat Window Issue
View Single Post
10-07-18, 09:46 PM   #5
Kanegasi
A Rage Talon Dragon Guard
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 337
Ah, I missed that. The taint source for that is at the bottom.

Lua Code:
  1. frame.DefaultAddMessage = frame.AddMessage --idk what all of this is
  2. frame.AddMessage = AddMessage --idk what all of this is

As for the things you do in your replaced AddMessage, you already use ChatFrame_AddMessageEventFilter for some events. For the stuff you can't change through the filter return, just build your own message and feed it directly into AddMessage, then return true in the filter so that the original line is filtered. The event filters get all the returns from the chat event, so you can do anything Blizzard's chat output does without replacing AddMessage.

Here's an example of your channel header change added to colorName along with duplicate protection. Keep in mind I did not test this, but this should give you an idea to go on whether it works or not.

Lua Code:
  1. local messages={}
  2. local function colorName(self, event, msg, ...)
  3.  
  4.     local test = msg:gsub('[^a-zA-Z%s]', '')
  5.     local words = {strsplit(' ', test)}
  6.     for i = 1, #words do
  7.         local w = words[i]
  8.         if (w and not (w == 'player' or w == 'target') and UnitName(w) and UnitIsPlayer(w)) then
  9.             local class = select(2, UnitClass(w))
  10.             local colors = RAID_CLASS_COLORS[class]
  11.             if (colors) then
  12.                 msg = gsub(msg, w, '|cff'..RGBPercToHex(colors.r, colors.g, colors.b)..'%1|r')
  13.             end
  14.         end
  15.     end
  16.  
  17.     -- get some of the args from the chat event
  18.     local namerealm,lang,fullchan,name,afkdnd,zoneID,chanID,channame,unusedzero,lineID,playerguid=...
  19.  
  20.     -- get text color and id of event (FrameXML\ChatFrame.lua:3186)
  21.     local type = strsub(event, 10)
  22.     local info = ChatTypeInfo[type]
  23.  
  24.     if event=="CHAT_MSG_CHANNEL" then
  25.  
  26.         -- prevent duplicate messages
  27.         if messages[lineID] then
  28.             return true -- hide, do nothing
  29.         else
  30.             messages[lineID]=true
  31.         end
  32.  
  33.          -- since we have the raw message, we have to add the channel number ourselves
  34.         msg = "|Hchannel:channel:"..chanID.."|h"..chanID..".|h "..msg
  35.  
  36.         -- we also need to add the timestamp exactly how Blizzard does it
  37.         -- FrameXML\ChatFrame.lua:3540 (BetterDate @ FrameXML\UIParent.lua:4736)
  38.         if CHAT_TIMESTAMP_FORMAT then
  39.             msg= BetterDate(CHAT_TIMESTAMP_FORMAT, time())..msg
  40.         end
  41.  
  42.          -- add message as if it was the original
  43.         self:AddMessage(msg,info.r,info.g,info.b,info.id)
  44.  
  45.          -- hide original message
  46.         return true
  47.  
  48.     end
  49.  
  50.     return false, msg, ...
  51. end

Last edited by Kanegasi : 10-07-18 at 09:50 PM.
  Reply With Quote