mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-04 17:56:56 +00:00
One-shot event handlers: use EventUtil.RegisterOnceFrameEventAndCallback instead of self-unregistering frames
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
pfUI:RegisterModule("chatcopy", function ()
|
||||
local f = CreateFrame("Frame")
|
||||
f:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
f:SetScript("OnEvent", function()
|
||||
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
|
||||
if not pfUI.chat then return end
|
||||
|
||||
local button = CreateFrame("Button", "pfChatCopyButton", pfUI.chat.left.panelTop)
|
||||
@@ -99,7 +97,5 @@ pfUI:RegisterModule("chatcopy", function ()
|
||||
|
||||
frame.scroll = scroll
|
||||
end
|
||||
|
||||
this:UnregisterAllEvents()
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -801,11 +801,7 @@ pfUI:RegisterModule("thirdparty-vanilla", function()
|
||||
HookAddon("SortBags", function()
|
||||
if C.thirdparty.sortbags.enable == "0" then return end
|
||||
|
||||
local sort = CreateFrame("Frame", nil)
|
||||
sort:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
sort:SetScript("OnEvent", function()
|
||||
this:UnregisterAllEvents()
|
||||
|
||||
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
|
||||
pfUI.thirdparty.RegisterBagSort("SortBags",
|
||||
function()
|
||||
SortBags()
|
||||
|
||||
@@ -142,11 +142,7 @@ pfUI:RegisterModule("thirdparty", function()
|
||||
HookAddon("MrPlow", function()
|
||||
if C.thirdparty.mrplow.enable == "0" then return end
|
||||
|
||||
local sort = CreateFrame("Frame", nil)
|
||||
sort:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
sort:SetScript("OnEvent", function()
|
||||
this:UnregisterAllEvents()
|
||||
|
||||
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
|
||||
local MrPlowL = AceLibrary and AceLibrary("AceLocale-2.2"):new("MrPlow")
|
||||
if not (MrPlowL and MrPlowL["Bank"]) then return end
|
||||
|
||||
|
||||
+1
-27
@@ -180,33 +180,7 @@ pfUI:RegisterModule("unitxp", function ()
|
||||
CreateTargetIndicators()
|
||||
|
||||
-- Also try on PLAYER_ENTERING_WORLD in case target frame wasn't ready
|
||||
local initFrame = CreateFrame("Frame")
|
||||
initFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
initFrame:RegisterEvent("PLAYER_LOGOUT")
|
||||
initFrame:SetScript("OnEvent", function()
|
||||
-- Handle shutdown to prevent crash 132
|
||||
if event == "PLAYER_LOGOUT" then
|
||||
this:UnregisterAllEvents()
|
||||
this:SetScript("OnEvent", nil)
|
||||
-- Stop indicator OnUpdate scripts
|
||||
if pfUI.uf and pfUI.uf.target then
|
||||
if pfUI.uf.target.behindIndicator then
|
||||
pfUI.uf.target.behindIndicator:SetScript("OnUpdate", nil)
|
||||
end
|
||||
if pfUI.uf.target.distanceIndicator then
|
||||
pfUI.uf.target.distanceIndicator:SetScript("OnUpdate", nil)
|
||||
end
|
||||
-- free-frame mode polls from its own scanner frame, not the indicator
|
||||
if pfUI.uf.target.distanceScanner then
|
||||
pfUI.uf.target.distanceScanner:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
CreateTargetIndicators()
|
||||
this:UnregisterAllEvents()
|
||||
end)
|
||||
EventUtil.RegisterOnceFrameEventAndCallback("PLAYER_ENTERING_WORLD", CreateTargetIndicators)
|
||||
|
||||
-- OS Notification Support
|
||||
if C.unitframes.unitxp_notify == "1" then
|
||||
|
||||
Reference in New Issue
Block a user