WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Filter/replace System messages in ChatFrame (https://www.wowinterface.com/forums/showthread.php?t=59041)

joejoe317 02-05-22 01:20 AM

Filter/replace System messages in ChatFrame
 
Hello, I have dipped my toe in development of addons because of the current Zero to Hero challenges with PVP where players try and keep anonymous on stream while starting fresh characters and trying to get 2400 rating in arena while only using LFG.

Currently I have modified and added significantly to an addon that a streamer named Xaryu has been using. I have mostly changed most information such as nameplates, chat, craftet items, enemy names etc..

One main issue with chat right now is that I can change the players names etc, however when people queue for arena system messages are used for events such as "LFG_ROLE_CHECK_ROLE_CHOSEN"..

I have found the way blizzard implements this and they use ChatFrame_DisplaySystemMessageInPrimary to print out the player name etc. If I try and use the role check event in ChatFrame_AddMessageEventFilter this does not product any prints.

If I register a frame, it will print on a registered event, but only after the system already printed it. The function name they have for these checks (which I assume is a function for on selection) is called LFGEventFrame_OnLoad.

My entire approach and thought may be incorrect as I am currently in the mindself of being able to return back the correct information on AddMessageEventFilter for other events such as say, whispers etc...

My main goal is to basically loop through the party and my current self, if its me then replace my name with a variable NewName created at the start of the file.. If it's anyone else then just use their class name.

joejoe317 02-05-22 01:58 AM

I figured out the part for when I select a role, now I need to figure out how to change when someone else selects a role... I would assume this part would function the same when someone enters or leaves an arena.

For reference:

Code:

local NewName = UnitClass("player");
local frame_handlers = {}

local function EventHandler(self, event, ...)
    if event == 'LFG_ROLE_CHECK_ROLE_CHOSEN' then
        -- alter stuff
                local player, isTank, isHealer, isDamage = ...;

                --Yes, consecutive string concatenation == bad for garbage collection. But the alternative is either extremely unslightly or localization unfriendly. (Also, this happens fairly rarely)
                local roleList;

                if ( isTank ) then
                        roleList = INLINE_TANK_ICON.." "..TANK;
                end
                if ( isHealer ) then
                        if ( roleList ) then
                                roleList = roleList..PLAYER_LIST_DELIMITER.." "..INLINE_HEALER_ICON.." "..HEALER;
                        else
                                roleList = INLINE_HEALER_ICON.." "..HEALER;
                        end
                end
                if ( isDamage ) then
                        if ( roleList ) then
                                roleList = roleList..PLAYER_LIST_DELIMITER.." "..INLINE_DAMAGER_ICON.." "..DAMAGER;
                        else
                                roleList = INLINE_DAMAGER_ICON.." "..DAMAGER;
                        end
                end
                assert(roleList);
                ChatFrame_DisplaySystemMessageInPrimary(string.format(LFG_ROLE_CHECK_ROLE_CHOSEN, NewName, roleList));
                return NewName, isTank, isHealer, isDamage
    end
    frame_handlers[self](self, event, ...)
end

local function HookFrames(...)
    for i = 1 ,select('#', ...) do
        local frame = select(i, ...)
        if not frame_handlers[frame] and frame:GetScript('OnEvent') then
            frame_handlers[frame] = frame:GetScript('OnEvent')
            frame:SetScript('OnEvent', EventHandler)
        end
    end
end



All times are GMT -6. The time now is 12:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI