mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-21 11:50:49 +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()
|
pfUI.addonbuttons:ProcessButtons()
|
||||||
end)
|
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
|
-- check if the panel should be shown by default
|
||||||
if not this.initialized then
|
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then
|
||||||
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then
|
pfUI.addonbuttons:Show()
|
||||||
pfUI.addonbuttons:Show()
|
else
|
||||||
else
|
pfUI.addonbuttons:Hide()
|
||||||
pfUI.addonbuttons:Hide()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- update all buttons
|
|
||||||
pfUI.addonbuttons:ProcessButtons()
|
|
||||||
this.initialized = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- throttle updates to once per 5 seconds
|
-- update all buttons and apply workarounds
|
||||||
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 5 end
|
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
|
-- reload/rescan minimap buttons
|
||||||
pfUI.addonbuttons:ProcessButtons()
|
pfUI.addonbuttons:ProcessButtons()
|
||||||
|
|||||||
+7
-9
@@ -131,18 +131,16 @@ pfUI:RegisterModule("minimap", function ()
|
|||||||
|
|
||||||
-- Create coordinates text frame with location configurable
|
-- Create coordinates text frame with location configurable
|
||||||
pfUI.minimapCoordinates = CreateFrame("Frame", "pfMinimapCoord", pfUI.minimap)
|
pfUI.minimapCoordinates = CreateFrame("Frame", "pfMinimapCoord", pfUI.minimap)
|
||||||
pfUI.minimapCoordinates:SetScript("OnUpdate", function()
|
-- Update coords every 0.1 seconds
|
||||||
-- Throttle to update coords every 0.1 seconds
|
C_Timer.NewTicker(0.1, function()
|
||||||
if ( this.tick or 0) > GetTime() then return end
|
|
||||||
this.tick = GetTime() + .1
|
|
||||||
|
|
||||||
if C.appearance.minimap.coordstext == "off" then return end
|
if C.appearance.minimap.coordstext == "off" then return end
|
||||||
|
|
||||||
this.posX, this.posY = GetPlayerMapPosition("player")
|
local coord = pfUI.minimapCoordinates
|
||||||
if this.posX ~= 0 and this.posY ~= 0 then
|
coord.posX, coord.posY = GetPlayerMapPosition("player")
|
||||||
this.text:SetText(string.format("%.1f, %.1f", round(this.posX * 100, 1), round(this.posY * 100, 1)))
|
if coord.posX ~= 0 and coord.posY ~= 0 then
|
||||||
|
coord.text:SetText(string.format("%.1f, %.1f", round(coord.posX * 100, 1), round(coord.posY * 100, 1)))
|
||||||
else
|
else
|
||||||
this.text:SetText("|cffffaaaaN/A")
|
coord.text:SetText("|cffffaaaaN/A")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
+9
-16
@@ -46,9 +46,7 @@ pfUI:RegisterModule("panel", function()
|
|||||||
widget.timerFrame.Snapshot = GetTime()
|
widget.timerFrame.Snapshot = GetTime()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
widget:SetScript("OnUpdate",function()
|
C_Timer.NewTicker(1, function()
|
||||||
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end
|
|
||||||
|
|
||||||
local secondsenabled = C.panel.seconds == "1"
|
local secondsenabled = C.panel.seconds == "1"
|
||||||
local fmt
|
local fmt
|
||||||
if C.global.twentyfour == "0" then
|
if C.global.twentyfour == "0" then
|
||||||
@@ -103,11 +101,9 @@ pfUI:RegisterModule("panel", function()
|
|||||||
pfUI.panel:OutputPanel("combat", T["Combat"] .. ": " .. NOT_APPLICABLE)
|
pfUI.panel:OutputPanel("combat", T["Combat"] .. ": " .. NOT_APPLICABLE)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
widget.combat:SetScript("OnUpdate", function()
|
C_Timer.NewTicker(1, function()
|
||||||
if not this.tick then this.tick = GetTime() end
|
if widget.combat.combat then
|
||||||
if GetTime() <= this.tick + 1 then return else this.tick = GetTime() end
|
pfUI.panel:OutputPanel("combat", "|cffffaaaa" .. SecondsToTime(ceil(GetTime() - widget.combat.combat)))
|
||||||
if this.combat then
|
|
||||||
pfUI.panel:OutputPanel("combat", "|cffffaaaa" .. SecondsToTime(ceil(GetTime() - this.combat)))
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -153,9 +149,7 @@ pfUI:RegisterModule("panel", function()
|
|||||||
pfUI.addons:Show()
|
pfUI.addons:Show()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
widget:SetScript("OnUpdate",function()
|
C_Timer.NewTicker(1, function()
|
||||||
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end
|
|
||||||
|
|
||||||
fps = floor(GetFramerate())
|
fps = floor(GetFramerate())
|
||||||
_, _, lag = GetNetStats()
|
_, _, lag = GetNetStats()
|
||||||
|
|
||||||
@@ -346,7 +340,7 @@ pfUI:RegisterModule("panel", function()
|
|||||||
widget:RegisterEvent("PLAYER_GUILD_UPDATE")
|
widget:RegisterEvent("PLAYER_GUILD_UPDATE")
|
||||||
widget.Tooltip = function()
|
widget.Tooltip = function()
|
||||||
-- skip without guild
|
-- skip without guild
|
||||||
if not GetGuildInfo("player") then return end
|
if not IsInGuild() then return end
|
||||||
|
|
||||||
local raidparty = {}
|
local raidparty = {}
|
||||||
for i=1,4 do -- detect people in group
|
for i=1,4 do -- detect people in group
|
||||||
@@ -398,7 +392,7 @@ pfUI:RegisterModule("panel", function()
|
|||||||
end
|
end
|
||||||
widget.Click = function() ToggleFriendsFrame(3) end
|
widget.Click = function() ToggleFriendsFrame(3) end
|
||||||
widget:SetScript("OnEvent", function()
|
widget:SetScript("OnEvent", function()
|
||||||
if GetGuildInfo("player") then
|
if IsInGuild() then
|
||||||
local count = 0
|
local count = 0
|
||||||
for i = 1, GetNumGuildMembers() do
|
for i = 1, GetNumGuildMembers() do
|
||||||
local _, _, _, _, _, _, _, _, online = GetGuildRosterInfo(i)
|
local _, _, _, _, _, _, _, _, online = GetGuildRosterInfo(i)
|
||||||
@@ -411,9 +405,8 @@ pfUI:RegisterModule("panel", function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
widget:SetScript("OnUpdate",function()
|
C_Timer.NewTicker(60, function()
|
||||||
if ( this.tick or 60) > GetTime() then return else this.tick = GetTime() + 60 end
|
if IsInGuild() then GuildRoster() end
|
||||||
if GetGuildInfo("player") then GuildRoster() end
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,7 @@ pfUI:RegisterModule("turtle-wow", function ()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local delay = CreateFrame("Frame")
|
RunNextFrame(function()
|
||||||
delay:SetScript("OnUpdate", function()
|
|
||||||
this:Hide()
|
|
||||||
|
|
||||||
-- correct positions of new game menu layout
|
-- correct positions of new game menu layout
|
||||||
if GameMenuButtonShop and (GameMenuButtonPFUI or GameMenuButtonPFUIAddOns) then
|
if GameMenuButtonShop and (GameMenuButtonPFUI or GameMenuButtonPFUIAddOns) then
|
||||||
-- calculate new offset for the shop button
|
-- calculate new offset for the shop button
|
||||||
|
|||||||
Reference in New Issue
Block a user