mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-03 12:10:01 +00:00
Replace fixed-interval OnUpdate polls with C_Timer/RunNextFrame
Swap hand-rolled per-frame throttles for the modern timer primitives: - turtle-wow: one-shot next-frame defer (self-hiding OnUpdate frame) -> RunNextFrame - panel: clock, combat, and fps widgets -> NewTicker(1); guild roster -> NewTicker(60) - minimap: coordinates text -> NewTicker(0.1) - addonbuttons: one-shot init -> RunNextFrame; 5s button rescan -> NewTicker(5), guarded by IsShown() to preserve the old "paused while hidden" behavior Ticker callbacks reference frames via upvalue since 'this' is unbound outside OnUpdate. Genuine per-frame work (bar fills, fades, drag) and polls already coordinated through pfUI.throttle are left as-is.
This commit is contained in:
+16
-13
@@ -397,22 +397,25 @@ pfUI:RegisterModule("addonbuttons", function ()
|
||||
pfUI.addonbuttons:ProcessButtons()
|
||||
end)
|
||||
|
||||
pfUI.addonbuttons:SetScript("OnUpdate", function()
|
||||
-- Initial setup on the next frame, once other addons' minimap buttons exist
|
||||
RunNextFrame(function()
|
||||
-- check if the panel should be shown by default
|
||||
if not this.initialized then
|
||||
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then
|
||||
pfUI.addonbuttons:Show()
|
||||
else
|
||||
pfUI.addonbuttons:Hide()
|
||||
end
|
||||
|
||||
-- update all buttons
|
||||
pfUI.addonbuttons:ProcessButtons()
|
||||
this.initialized = true
|
||||
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then
|
||||
pfUI.addonbuttons:Show()
|
||||
else
|
||||
pfUI.addonbuttons:Hide()
|
||||
end
|
||||
|
||||
-- throttle updates to once per 5 seconds
|
||||
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 5 end
|
||||
-- update all buttons and apply workarounds
|
||||
pfUI.addonbuttons:ProcessButtons()
|
||||
for k, v in pairs(pfUI.addonbuttons.overrides) do
|
||||
_G[k] = v
|
||||
end
|
||||
end)
|
||||
|
||||
-- Rescan minimap buttons every 5 seconds while the panel is shown
|
||||
C_Timer.NewTicker(5, function()
|
||||
if not pfUI.addonbuttons:IsShown() then return end
|
||||
|
||||
-- reload/rescan minimap buttons
|
||||
pfUI.addonbuttons:ProcessButtons()
|
||||
|
||||
Reference in New Issue
Block a user