X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/330739114047596de17fabf5182c25b065ebde39..ba69982de70da5d761e9f1bda67f94ab0e218fe7:/OmaUF/Auras.lua diff --git a/OmaUF/Auras.lua b/OmaUF/Auras.lua index 172e3d4..0ca1e0a 100644 --- a/OmaUF/Auras.lua +++ b/OmaUF/Auras.lua @@ -3,8 +3,11 @@ local _; local CreateFrame = CreateFrame; local UnitAura = UnitAura; local GameTooltip = GameTooltip; +local GetTime = GetTime; +local CTimerAfter = C_Timer.After; local auraFilters = {"HELPFUL", "HARMFUL"}; +local updateAuras; local M = {}; OmaUFAuras = M; @@ -74,9 +77,25 @@ function M.CreateAuraFrame(parent, unit) i = i + 1; end end + + parent.throttle = function() + parent.throttled = nil; + if UnitExists(unit) then + return updateAuras(parent, unit); + end + end; end function M.UpdateAuras(frame, unit) + local current = GetTime(); + if frame.throttled then + return; + elseif frame.prevUpdate and current - frame.prevUpdate < 0.2 then + frame.throttled = true; + return CTimerAfter(0.1, frame.throttle); -- faster timer here to reduce the delay, gets called twice + end + + frame.prevUpdate = current; local auras = frame.auras; local icon, count, duration, expires, caster, id; local pos = 1; @@ -85,7 +104,6 @@ function M.UpdateAuras(frame, unit) while true do _, _, icon, count, _, duration, expires, caster, _, _, id = UnitAura(unit, i, filter); if not id or not auras[pos] then break end - -- aura filter self-applied, player-applied, list of important auras TODO local aura = auras[pos]; aura.icon:SetTexture(icon); aura.index = i; @@ -113,3 +131,4 @@ function M.UpdateAuras(frame, unit) pos = pos + 1; end end +updateAuras = M.UpdateAuras;