Quantcast WoWInterface - View Single Post - Temporary Chat Frames/Community Chat Frame/New Chat Window Issue
View Single Post
10-08-18, 11:29 AM   #8
Kanegasi
A Rage Talon Dragon Guard
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 337
The method I presented, using filters as one piece printing and filtering, does seem like it's complicated, but using the filters is the best (or only) way to do what you want without replacing Blizzard objects. I also included duplicate prevention because I have had problems with some addons doing weird stuff with chat filters. Prat and WIM do weird things together when you try to add a filter that does more than filter.

An easier way to use the filters is to have a simple filter that blocks all default events for the event you want to manipulate, while using the event that fired directly. You'll have to specify the ChatFrame to go to since that's not self anymore. Also, keep in mind this blanket method clashes with all other chat addons, since they all use the combo filter method I posted originally and a straight "return true" filter will just kill all changes they do. If you don't have any other chat addons and your addon is meant to be used alone, this is fine.

Here's a piece of code that does what I posted earlier, but standalone without your code:

Lua Code:
  1. -- block ALL channel events from default UI
  2. ChatFrame_AddMessageEventFilter( "CHAT_MSG_CHANNEL", function( ) return true end )
  3.  
  4. local f = CreateFrame( "frame" )
  5.  
  6. f:RegisterEvent( "CHAT_MSG_CHANNEL" )
  7.  
  8. f:SetScript( "OnEvent", function( self, event, ... )
  9.  
  10.     local type = strsub( event, 10 )
  11.     local info = ChatTypeInfo[ type ]
  12.  
  13.     arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, _, arg11, arg12 = ...
  14.  
  15.     if event == "CHAT_MSG_CHANNEL" then
  16.  
  17.         arg1 = "|Hchannel:channel:" .. arg8 .. "|h" .. arg8 .. ".|h " .. arg1
  18.  
  19.         if CHAT_TIMESTAMP_FORMAT then
  20.             arg1 = BetterDate( CHAT_TIMESTAMP_FORMAT, time( ) ) .. arg1
  21.         end
  22.  
  23.         ChatFrame1:AddMessage( arg1, info.r, info.g, info.b, info.id )
  24.  
  25.     end
  26.  
  27. end )

I also have a way to automatically choose which ChatFrame to post to based on Blizzard's chat settings using IsEventRegistered, but I wanted to keep this simple.

Last edited by Kanegasi : 10-08-18 at 11:32 AM.
  Reply With Quote