mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-18 10:40:48 +00:00
api: allow multiple hooks
This commit is contained in:
Vendored
+10
-11
@@ -50,25 +50,24 @@ end
|
|||||||
-- code instead of prepending it
|
-- code instead of prepending it
|
||||||
function pfUI.api.Hook(name, func, append)
|
function pfUI.api.Hook(name, func, append)
|
||||||
if not _G[name] then return end
|
if not _G[name] then return end
|
||||||
if pfUI.hooks[name] then return end
|
|
||||||
|
|
||||||
pfUI.hooks[name] = {}
|
pfUI.hooks[tostring(func)] = {}
|
||||||
pfUI.hooks[name]["old"] = _G[name]
|
pfUI.hooks[tostring(func)]["old"] = _G[name]
|
||||||
pfUI.hooks[name]["new"] = func
|
pfUI.hooks[tostring(func)]["new"] = func
|
||||||
|
|
||||||
if append then
|
if append then
|
||||||
pfUI.hooks[name]["function"] = function(...)
|
pfUI.hooks[tostring(func)]["function"] = function(...)
|
||||||
pfUI.hooks[name]["old"](unpack(arg))
|
pfUI.hooks[tostring(func)]["old"](unpack(arg))
|
||||||
pfUI.hooks[name]["new"](unpack(arg))
|
pfUI.hooks[tostring(func)]["new"](unpack(arg))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
pfUI.hooks[name]["function"] = function(...)
|
pfUI.hooks[tostring(func)]["function"] = function(...)
|
||||||
pfUI.hooks[name]["new"](unpack(arg))
|
pfUI.hooks[tostring(func)]["new"](unpack(arg))
|
||||||
pfUI.hooks[name]["old"](unpack(arg))
|
pfUI.hooks[tostring(func)]["old"](unpack(arg))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_G[name] = pfUI.hooks[name]["function"]
|
_G[name] = pfUI.hooks[tostring(func)]["function"]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [ Create Gold String ]
|
-- [ Create Gold String ]
|
||||||
|
|||||||
Reference in New Issue
Block a user