diff --git a/modules/addonbuttons.lua b/modules/addonbuttons.lua index 2b84bb93..e58c3143 100644 --- a/modules/addonbuttons.lua +++ b/modules/addonbuttons.lua @@ -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() diff --git a/modules/minimap.lua b/modules/minimap.lua index 29748fd9..9f4abdd9 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -131,18 +131,16 @@ pfUI:RegisterModule("minimap", function () -- Create coordinates text frame with location configurable pfUI.minimapCoordinates = CreateFrame("Frame", "pfMinimapCoord", pfUI.minimap) - pfUI.minimapCoordinates:SetScript("OnUpdate", function() - -- Throttle to update coords every 0.1 seconds - if ( this.tick or 0) > GetTime() then return end - this.tick = GetTime() + .1 - + -- Update coords every 0.1 seconds + C_Timer.NewTicker(0.1, function() if C.appearance.minimap.coordstext == "off" then return end - this.posX, this.posY = GetPlayerMapPosition("player") - if this.posX ~= 0 and this.posY ~= 0 then - this.text:SetText(string.format("%.1f, %.1f", round(this.posX * 100, 1), round(this.posY * 100, 1))) + local coord = pfUI.minimapCoordinates + coord.posX, coord.posY = GetPlayerMapPosition("player") + 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 - this.text:SetText("|cffffaaaaN/A") + coord.text:SetText("|cffffaaaaN/A") end end) diff --git a/modules/panel.lua b/modules/panel.lua index fc5c5ebf..4a369c0a 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -46,9 +46,7 @@ pfUI:RegisterModule("panel", function() widget.timerFrame.Snapshot = GetTime() end end - widget:SetScript("OnUpdate",function() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - + C_Timer.NewTicker(1, function() local secondsenabled = C.panel.seconds == "1" local fmt if C.global.twentyfour == "0" then @@ -103,11 +101,9 @@ pfUI:RegisterModule("panel", function() pfUI.panel:OutputPanel("combat", T["Combat"] .. ": " .. NOT_APPLICABLE) end end) - widget.combat:SetScript("OnUpdate", function() - if not this.tick then this.tick = GetTime() end - if GetTime() <= this.tick + 1 then return else this.tick = GetTime() end - if this.combat then - pfUI.panel:OutputPanel("combat", "|cffffaaaa" .. SecondsToTime(ceil(GetTime() - this.combat))) + C_Timer.NewTicker(1, function() + if widget.combat.combat then + pfUI.panel:OutputPanel("combat", "|cffffaaaa" .. SecondsToTime(ceil(GetTime() - widget.combat.combat))) end end) end @@ -153,9 +149,7 @@ pfUI:RegisterModule("panel", function() pfUI.addons:Show() end end - widget:SetScript("OnUpdate",function() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - + C_Timer.NewTicker(1, function() fps = floor(GetFramerate()) _, _, lag = GetNetStats() @@ -346,7 +340,7 @@ pfUI:RegisterModule("panel", function() widget:RegisterEvent("PLAYER_GUILD_UPDATE") widget.Tooltip = function() -- skip without guild - if not GetGuildInfo("player") then return end + if not IsInGuild() then return end local raidparty = {} for i=1,4 do -- detect people in group @@ -398,7 +392,7 @@ pfUI:RegisterModule("panel", function() end widget.Click = function() ToggleFriendsFrame(3) end widget:SetScript("OnEvent", function() - if GetGuildInfo("player") then + if IsInGuild() then local count = 0 for i = 1, GetNumGuildMembers() do local _, _, _, _, _, _, _, _, online = GetGuildRosterInfo(i) @@ -411,9 +405,8 @@ pfUI:RegisterModule("panel", function() end end) - widget:SetScript("OnUpdate",function() - if ( this.tick or 60) > GetTime() then return else this.tick = GetTime() + 60 end - if GetGuildInfo("player") then GuildRoster() end + C_Timer.NewTicker(60, function() + if IsInGuild() then GuildRoster() end end) end diff --git a/modules/turtle-wow.lua b/modules/turtle-wow.lua index 613d7802..7d74c4a6 100644 --- a/modules/turtle-wow.lua +++ b/modules/turtle-wow.lua @@ -80,10 +80,7 @@ pfUI:RegisterModule("turtle-wow", function () end) end - local delay = CreateFrame("Frame") - delay:SetScript("OnUpdate", function() - this:Hide() - + RunNextFrame(function() -- correct positions of new game menu layout if GameMenuButtonShop and (GameMenuButtonPFUI or GameMenuButtonPFUIAddOns) then -- calculate new offset for the shop button