Originally Posted by Haleth
That's what I meant. I managed to get it working without taint eventually. Overwriting GetColoredName only causes taint if you, well, change it too much from the original.
|
That isn't how taint works. Overwriting a Blizzard-defined global causes taint, period.
Originally Posted by Dawn
Since we are talking about colors:
Would you consider adding an option to change Faction colors to your Class Colors addon, Phanx?
|
As has been asked and answered at least once on the addon's comment page, no, I have no plans to add options for power colors, faction colors, etc. Changing those colors does not break any part of the default UI that I'm aware of, so you can (and should) just modify the Blizzard-defined tables for them directly.
Originally Posted by Haleth
Slight update on the problem, overwriting GetColoredName does seem to cause taint.
|
Of course it does.
It doesn't, however, break right-click buff cancelling. I just logged in with no addons enabled except for a "sandbox" addon that contained only the code from your last post (plus a
FreeUI = { } at the top), and was able to right-click cancel buffs just fine.
At login:
Code:
11/21 21:06:37.890 Global variable GetColoredName tainted by PhanxMod - Interface\AddOns\PhanxMod\Sandbox.lua:14
When sending a whisper to myself:
Code:
11/21 21:06:43.656 Execution tainted by PhanxMod while reading GetColoredName - Interface\FrameXML\ChatFrame.lua:2744 ChatFrame_MessageEventHandler()
11/21 21:06:43.656 Interface\FrameXML\ChatFrame.lua:2550 ChatFrame_OnEvent()
11/21 21:06:43.656 ChatFrame1:OnEvent()
11/21 21:06:43.765 Execution tainted by PhanxMod while reading GetColoredName - Interface\FrameXML\ChatFrame.lua:2744 ChatFrame_MessageEventHandler()
11/21 21:06:43.765 Interface\FrameXML\ChatFrame.lua:2550 ChatFrame_OnEvent()
11/21 21:06:43.765 ChatFrame1:OnEvent()
There weren't any messages related to the buff frame, or any actions blocked. Most likely, something else in your addon is tainting another variable that's causing buff right-clicking to fail.
Originally Posted by Haleth
How would I go about doing this properly without overwriting?
|
Well, there's simply no way to do it without overwriting
something. You can either overwrite GetColoredName, or you can overwrite FCF_GetTemporaryWindow and each chat frame's AddMessage method:
Code:
local colorMap = { }
for class, old in pairs(RAID_CLASS_COLORS) do
local new = CUSTOM_CLASS_COLORS[class]
colorMap[("\124cff%02x%02x%02x"):format(old.r * 255, old.g * 255, old.b * 255)] = ("\124cff%02x%02x%02x"):format(new.r * 255, new.g * 255, new.b * 255)
end
local hooks = { }
local AddMessage = function(frame, message, ...)
if type(message) == "string" then
for old, new in pairs(colorMap) do
message = message:replace(old, new)
end
end
return hooks[frame](frame, message, ...)
end
for i = 1, NUM_CHAT_WINDOWS do
local frame = _G["ChatFrame" .. i]
hooks[frame] = frame.AddMessage
frame.AddMessage = AddMessage
end
hooks.FCF_OpenTemporaryWindow = FCF_OpenTemporaryWindow
FCF_OpenTemporaryWindow = function(...)
local frame = hooks.FCF_OpenTemporaryWindow(...)
hooks[frame] = frame.AddMessage
frame.AddMessage = AddMessage
return frame
end
Since neither method breaks any parts of the default UI, its easier (less code, and less hooking) and more efficient (no need for 10 string replaces per chat message per frame) to just overwrite GetColoredName.