0453a59 - Add Uldir instance ID for autologging
[wowui.git] / OmaUF / Auras.lua
index 2debeb9..f3da677 100644 (file)
@@ -3,8 +3,11 @@ local _;
 local CreateFrame = CreateFrame;
 local UnitAura = UnitAura;
 local GameTooltip = GameTooltip;
 local CreateFrame = CreateFrame;
 local UnitAura = UnitAura;
 local GameTooltip = GameTooltip;
+local GetTime = GetTime;
+local CTimerAfter = C_Timer.After;
 
 local auraFilters = {"HELPFUL", "HARMFUL"};
 
 local auraFilters = {"HELPFUL", "HARMFUL"};
+local updateAuras;
 
 local M = {};
 OmaUFAuras = M;
 
 local M = {};
 OmaUFAuras = M;
@@ -29,10 +32,6 @@ local function hideTooltip(frame)
     frame:SetScript("OnUpdate", nil);
 end
 
     frame:SetScript("OnUpdate", nil);
 end
 
-function M.UpdateAuraTooltips()
-    GameTooltip = _G["GameTooltip"];
-end
-
 local function createAura(parent, prev, anchor, name, unit)
     local aura = CreateFrame("Frame", name, parent);
     aura:SetPoint("TOPLEFT", prev, anchor);
 local function createAura(parent, prev, anchor, name, unit)
     local aura = CreateFrame("Frame", name, parent);
     aura:SetPoint("TOPLEFT", prev, anchor);
@@ -71,29 +70,40 @@ function M.CreateAuraFrame(parent, unit)
         i = i + 1;
     end
     -- max rows
         i = i + 1;
     end
     -- max rows
-    for y=0,1 do
+    for y=0,0 do
         for x=1,10 do
             local auraName = name..i;
             parent.auras[i] = createAura(parent.auras, parent.auras[y*10+x], "BOTTOMLEFT", auraName, unit);
             i = i + 1;
         end
     end
         for x=1,10 do
             local auraName = name..i;
             parent.auras[i] = createAura(parent.auras, parent.auras[y*10+x], "BOTTOMLEFT", auraName, 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)
 end
 
 function M.UpdateAuras(frame, unit)
-    local auras = frame.auras;
-    for _, aura in ipairs(auras) do
-        if not aura:IsShown() then break end
-        aura:Hide();
+    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
     end
+
+    frame.prevUpdate = current;
+    local auras = frame.auras;
     local icon, count, duration, expires, caster, id;
     local pos = 1;
     for _, filter in ipairs(auraFilters) do
         local i = 1;
         while true do
     local icon, count, duration, expires, caster, id;
     local pos = 1;
     for _, filter in ipairs(auraFilters) do
         local i = 1;
         while true do
-            _, _, icon, count, _, duration, expires, caster, _, _, id = UnitAura(unit, i, filter);
+            _, icon, count, _, duration, expires, caster, _, _, id = UnitAura(unit, i, filter);
             if not id or not auras[pos] then break end
             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;
             local aura = auras[pos];
             aura.icon:SetTexture(icon);
             aura.index = i;
@@ -114,4 +124,11 @@ function M.UpdateAuras(frame, unit)
             i = i + 1;
         end
     end
             i = i + 1;
         end
     end
+
+    while auras[pos] do
+        if not auras[pos]:IsShown() then return end
+        auras[pos]:Hide();
+        pos = pos + 1;
+    end
 end
 end
+updateAuras = M.UpdateAuras;