For those of you who don't know this already.
It is possible to hook functions like "SetAlpha", "SetVertexColor" or "SetPoint" for a specific frame/button.
This comes in very handy if you rewrite Blizzard stuff and want to make sure it stays the way you want it.
Thanks to "hooksecurefunc" it won't cause tainting aswell.
Code:
----------------------
--FUNCTIONS
----------------------
local function am(text)
DEFAULT_CHAT_FRAME:AddMessage(text)
end
local function mySetVertexColorFunc(self, r, g, b, a)
--do stuff
am("setvertexcol")
if r then
am(r)
end
end
local function mySetStatusBarColorFunc(self, r, g, b, a)
--do stuff
am("setstatusbarcol")
if r then
am(r)
if r > 0.3 then
self:SetStatusBarColor(0.2,0.2,0.2,1)
end
end
end
local function mySetAlphaFunc(self, a)
--do stuff
am("setalpha")
if a then
am(a)
end
end
----------------------
--FRAMES
----------------------
--set colors for any kind of frame/button
frame1:SetVertexColor(1,0.2,0.2,1)
frame2:SetStatusBarColor(0.2,0.2,1,1)
----------------------
--HOOKS
----------------------
--hook functions for that frame/button
hooksecurefunc(frame1, "SetVertexColor", mySetVertexColorFunc)
hooksecurefunc(frame1, "SetAlpha", mySetAlphaFunc)
hooksecurefunc(frame2, "SetStatusBarColor", mySetStatusBarColorFunc)
hooksecurefunc(frame2, "SetAlpha", mySetAlphaFunc)
That way you can rewrite anything Blizzard does again.
Think of a frame that you want to stay at Alpha(0.2) but Blizzard always sets it to Alpha(1), so just hook SetAlpha() and you can set it to "0.2" again.