mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
feat: add hooksecurefunc, UIParent, and noop stubs for addon compat
- hooksecurefunc(tblOrName, name, hook) — hook any function to run additional code after it executes without replacing the original. Supports both global and table method forms. - UIParent, WorldFrame — standard parent frames that many addons reference as parents for their own frames. - Noop stubs: SetDesaturation, SetPortraitTexture, PlaySound, PlaySoundFile — prevent errors from addons that call these visual/audio functions which don't have implementations yet.
This commit is contained in:
parent
0a62529b55
commit
3ff43a530f
1 changed files with 30 additions and 0 deletions
|
|
@ -932,6 +932,36 @@ void LuaEngine::registerCoreAPI() {
|
||||||
"end\n"
|
"end\n"
|
||||||
"ChatFrame1 = DEFAULT_CHAT_FRAME\n"
|
"ChatFrame1 = DEFAULT_CHAT_FRAME\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// hooksecurefunc — hook a function to run additional code after it
|
||||||
|
luaL_dostring(L_,
|
||||||
|
"function hooksecurefunc(tblOrName, nameOrFunc, funcOrNil)\n"
|
||||||
|
" local tbl, name, hook\n"
|
||||||
|
" if type(tblOrName) == 'table' then\n"
|
||||||
|
" tbl, name, hook = tblOrName, nameOrFunc, funcOrNil\n"
|
||||||
|
" else\n"
|
||||||
|
" tbl, name, hook = _G, tblOrName, nameOrFunc\n"
|
||||||
|
" end\n"
|
||||||
|
" local orig = tbl[name]\n"
|
||||||
|
" if type(orig) ~= 'function' then return end\n"
|
||||||
|
" tbl[name] = function(...)\n"
|
||||||
|
" local r = {orig(...)}\n"
|
||||||
|
" hook(...)\n"
|
||||||
|
" return unpack(r)\n"
|
||||||
|
" end\n"
|
||||||
|
"end\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Noop stubs for commonly called functions that don't need implementation
|
||||||
|
luaL_dostring(L_,
|
||||||
|
"function SetDesaturation() end\n"
|
||||||
|
"function SetPortraitTexture() end\n"
|
||||||
|
"function PlaySound() end\n"
|
||||||
|
"function PlaySoundFile() end\n"
|
||||||
|
"function UIParent_OnEvent() end\n"
|
||||||
|
"UIParent = CreateFrame('Frame', 'UIParent')\n"
|
||||||
|
"WorldFrame = CreateFrame('Frame', 'WorldFrame')\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Event System ----
|
// ---- Event System ----
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue