mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
add HookScript func as replacement for frame widget
This commit is contained in:
@@ -60,6 +60,22 @@ QuestDifficultyColors = {
|
|||||||
["header"] = {r = 0.70, g = 0.70, b = 0.70}
|
["header"] = {r = 0.70, g = 0.70, b = 0.70}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function HookScript(frame, scriptType, handler)
|
||||||
|
assert(type(frame) == "table" and frame.GetScript and type(scriptType) == "string" and type(handler) == "function", "Usage: HookScript(frame, \"type\", function)")
|
||||||
|
|
||||||
|
local original_scipt = frame:GetScript(scriptType)
|
||||||
|
if original_scipt then
|
||||||
|
frame:SetScript(scriptType, function(...)
|
||||||
|
local original_return = {original_scipt(unpack(arg))}
|
||||||
|
handler(unpack(arg))
|
||||||
|
|
||||||
|
return unpack(original_return)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
frame:SetScript(scriptType, handler)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function hooksecurefunc(arg1, arg2, arg3)
|
function hooksecurefunc(arg1, arg2, arg3)
|
||||||
local isMethod = type(arg1) == "table" and type(arg2) == "string" and type(arg1[arg2]) == "function" and type(arg3) == "function"
|
local isMethod = type(arg1) == "table" and type(arg2) == "string" and type(arg1[arg2]) == "function" and type(arg3) == "function"
|
||||||
assert(isMethod or (type(arg1) == "string" and type(_G[arg1]) == "function" and type(arg2) == "function"), "Usage: hooksecurefunc([table,] \"functionName\", hookfunc)")
|
assert(isMethod or (type(arg1) == "string" and type(_G[arg1]) == "function" and type(arg2) == "function"), "Usage: hooksecurefunc([table,] \"functionName\", hookfunc)")
|
||||||
|
|||||||
Reference in New Issue
Block a user