From 14a26b8301740611ab469f9fd6530a1ac281738d Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat, 31 Oct 2026 19:47:41 -0500 Subject: [PATCH] Replace saved-handler wrappers with HookScript; use intrinsic pre/postcall bindings for barbershop and SetHighlight --- api/ui-widgets.lua | 16 ++-------------- libs/libpredict.lua | 4 +--- modules/marktracking.lua | 8 ++------ modules/thirdparty-vanilla.lua | 11 +++-------- skins/blizzard/barbershop.lua | 12 ++++-------- skins/blizzard/transmog.lua | 4 +--- skins/blizzard/turtle_shop.lua | 6 +----- 7 files changed, 14 insertions(+), 47 deletions(-) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index eb6095df..16169b56 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -257,20 +257,8 @@ function pfUI.api.SetHighlight(frame, cr, cg, cb) frame.rr, frame.rg, frame.rb, frame.ra = GetStringColor(pfUI_config.appearance.border.color) if not frame.pfEnterLeave then - local enter, leave = frame:GetScript("OnEnter"), frame:GetScript("OnLeave") - - if enter then - frame:HookScript("OnEnter", SetHighlightEnter) - else - frame:SetScript("OnEnter", SetHighlightEnter) - end - - if leave then - frame:HookScript("OnLeave", SetHighlightLeave) - else - frame:SetScript("OnLeave", SetHighlightLeave) - end - + frame:HookScript("OnEnter", SetHighlightEnter, LE_SCRIPT_BINDING_TYPE_INTRINSIC_POSTCALL) + frame:HookScript("OnLeave", SetHighlightLeave, LE_SCRIPT_BINDING_TYPE_INTRINSIC_POSTCALL) frame.pfEnterLeave = true end end diff --git a/libs/libpredict.lua b/libs/libpredict.lua index 38cc57fb..b45800b1 100644 --- a/libs/libpredict.lua +++ b/libs/libpredict.lua @@ -96,12 +96,10 @@ end libpredict:RegisterEvent("PLAYER_ENTERING_WORLD") libpredict:RegisterEvent("RAID_ROSTER_UPDATE") libpredict:RegisterEvent("PARTY_MEMBERS_CHANGED") -local origOnEvent = libpredict:GetScript("OnEvent") -libpredict:SetScript("OnEvent", function() +libpredict:HookScript("OnEvent", function() if event == "PLAYER_ENTERING_WORLD" or event == "RAID_ROSTER_UPDATE" or event == "PARTY_MEMBERS_CHANGED" then cacheRaidNames() end - if origOnEvent then origOnEvent() end end) -- Own cast-time spell started (heals + rez) diff --git a/modules/marktracking.lua b/modules/marktracking.lua index 4736495e..09a5485f 100644 --- a/modules/marktracking.lua +++ b/modules/marktracking.lua @@ -258,9 +258,7 @@ pfUI.marktracking = CreateFrame("Frame", "pfMarkTracking", UIParent) -- Unlock mode: show fixed 1-row placeholder so positioning works correctly if pfUI.unlock then - local origShow = pfUI.unlock:GetScript("OnShow") - pfUI.unlock:SetScript("OnShow", function() - if origShow then origShow() end + pfUI.unlock:HookScript("OnShow", function() isUnlocked = true -- hide all rows, show container at 1-row height as drag handle for i = 1, 8 do @@ -270,9 +268,7 @@ pfUI.marktracking = CreateFrame("Frame", "pfMarkTracking", UIParent) pfUI.marktracking:Show() end) - local origHide = pfUI.unlock:GetScript("OnHide") - pfUI.unlock:SetScript("OnHide", function() - if origHide then origHide() end + pfUI.unlock:HookScript("OnHide", function() isUnlocked = false UpdateDisplay() end) diff --git a/modules/thirdparty-vanilla.lua b/modules/thirdparty-vanilla.lua index f0ff2601..cccfd8bc 100644 --- a/modules/thirdparty-vanilla.lua +++ b/modules/thirdparty-vanilla.lua @@ -885,18 +885,15 @@ pfUI:RegisterModule("thirdparty-vanilla", function() end -- hook events to include SuperMacro refreshs - local ButtonEnter = pfUI.bars[1][1]:GetScript("OnEnter") local function NewButtonEnter() - ButtonEnter() - local actionid = ActionButton_GetPagedID(this) - SM_ActionButton_SetTooltip(actionid) + SM_ActionButton_SetTooltip(ActionButton_GetPagedID(this)) end -- reassign the new event handler for i=1,10 do for j=1,12 do pfUI.bars[i][j]:SetScript("OnEvent", NewButtonEvent) - pfUI.bars[i][j]:SetScript("OnEnter", NewButtonEnter) + pfUI.bars[i][j]:HookScript("OnEnter", NewButtonEnter) end end @@ -1045,9 +1042,7 @@ pfUI:RegisterModule("thirdparty-vanilla", function() if pfUI.uf.player then -- set tooltip function for player frame - local oldfunc = pfUI.uf.player:GetScript("OnEnter") - pfUI.uf.player:SetScript("OnEnter", function() - oldfunc() + pfUI.uf.player:HookScript("OnEnter", function() mrpDisplayTooltip("player", "PLAYER") end) end diff --git a/skins/blizzard/barbershop.lua b/skins/blizzard/barbershop.lua index 8abaa67b..0c82682c 100644 --- a/skins/blizzard/barbershop.lua +++ b/skins/blizzard/barbershop.lua @@ -62,8 +62,7 @@ pfUI:RegisterSkin("Barbershop", function () -- to prevent SetUnitDebuff crash (TargetFrame is hidden but scripts remain active) local savedOnEnter = {} - local origOnShow = BarbershopFrame:GetScript("OnShow") - BarbershopFrame:SetScript("OnShow", function() + BarbershopFrame:HookScript("OnShow", function() for i = 1, 16 do local debuff = _G["TargetFrameDebuff" .. i] if debuff then @@ -71,17 +70,14 @@ pfUI:RegisterSkin("Barbershop", function () debuff:SetScript("OnEnter", nil) end end - if origOnShow then origOnShow() end - end) + end, LE_SCRIPT_BINDING_TYPE_INTRINSIC_PRECALL) - local origOnHide = BarbershopFrame:GetScript("OnHide") - BarbershopFrame:SetScript("OnHide", function() + BarbershopFrame:HookScript("OnHide", function() for i = 1, 16 do local debuff = _G["TargetFrameDebuff" .. i] if debuff and savedOnEnter[i] then debuff:SetScript("OnEnter", savedOnEnter[i]) end end - if origOnHide then origOnHide() end - end) + end, LE_SCRIPT_BINDING_TYPE_INTRINSIC_PRECALL) end) diff --git a/skins/blizzard/transmog.lua b/skins/blizzard/transmog.lua index 26bef677..5393359a 100644 --- a/skins/blizzard/transmog.lua +++ b/skins/blizzard/transmog.lua @@ -87,9 +87,7 @@ pfUI:RegisterSkin("Transmog", function () end end - local origOnShow = TransmogFrame:GetScript("OnShow") - TransmogFrame:SetScript("OnShow", function() - if origOnShow then origOnShow() end + TransmogFrame:HookScript("OnShow", function() for i = 1, 20 do SkinLookButton(_G["TransmogFrameLook" .. i]) end diff --git a/skins/blizzard/turtle_shop.lua b/skins/blizzard/turtle_shop.lua index 92604134..cf043da3 100644 --- a/skins/blizzard/turtle_shop.lua +++ b/skins/blizzard/turtle_shop.lua @@ -67,11 +67,7 @@ pfUI:RegisterSkin("Turtle Shop", function () -- ============================================================ SkinEntryFrames() - local origOnShow = ShopFrame:GetScript("OnShow") - ShopFrame:SetScript("OnShow", function() - if origOnShow then origOnShow() end - SkinEntryFrames() - end) + ShopFrame:HookScript("OnShow", SkinEntryFrames) -- ============================================================ -- ShopDressUpFrame