View Single Post
02-11-14, 01:05 AM   #11
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by Phanx View Post
Don't hook CF_MEH. Just use the "filter" system that Blizzard put into the game for exactly this purpose. >_<
I implemented a function using event filters very much like the one suggested in your first post. It worked well, but like you'd said in that post, I still needed to get round the issue of working out which chat frames (if any) the message would be displayed on.

I should have said all this in my initial post, but (although I know that event filtering can be used for other things) the feature I'm adding doesn't need to filter chat messages (in-fact, it doesn't even need to know the content of the message). It's simply an alert feature for when a particular type of message is received. A sound will be played and the chat button will 'pulse' the colour of the chat message. It also auto-undocks the chat window (this is all dependent on user settings).

When I say auto-undock, I'm not referring to undocking a ChatFrame from GENERAL_CHAT_DOCK. It's a feature of my chat module which essentially allows the user to show/hide all chat frames within GENERAL_CHAT_DOCK with a hotkey.

In order to work properly, the function requires:

1. A guarantee that the message will actually be displayed.

2. The event (firstly so that I can get the message event category via CHAT_CATEGORY_LIST which I can then compare to user preferences and secondly, so that I can get the r, g, b values for the message).

3. The chat frame(s) on which the message will be displayed.

After a good bit of experimentation, I have eventually settled on just hooking each chat frame's 'OnEvent' handler. To avoid unnecessary processing (to prevent the code from being read for config/system events), the first line of the hooked function is:

Lua Code:
  1. if ((strsub(event, 1, 8) ~= "CHAT_MSG") or (not self.isDocked)) then return; end

I've found that this works well, because due to the system already implemented in Bliz's ChatFrame.lua, each particular event will only fire for chat frames which are registered to receive them.

I know that if I added a filter, I could retrieve the channel name (arg9) and work out which frames receive that channel, but I'm hoping that that won't be necessary.

The obvious downside to hooking OnEvent is that my function will bypass not only the user-created filters, but also MessageEventHandler which will result in false positives. I'm going to be testing it a lot to see what kind of impact this has.

Just so you know, I don't think for a second that this is the perfect way to handle what I'm attempting to achieve so any suggestions which encompass all of the function's requirements above are always welcome.
__________________
__________________

Last edited by Aanson : 02-11-14 at 01:15 AM.
  Reply With Quote