6a32145 - Update aura state on combat start and all bars update
[wowui.git] / kehys / events.lua
index 32241e4..b194192 100644 (file)
@@ -23,6 +23,7 @@ local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE;
 
 local _, addon = ...;
 addon.Events = {};
+local guids = addon.FrameGuids;
 local baseColor = {0, 0, 0};
 local overlayColorDispel = {1, 0.5, 0, 0.5};
 local overlayColorCharm = {0.8, 0, 1, 0.5};
@@ -31,6 +32,7 @@ local width = 80;
 
 function addon.RegisterEvents(frame)
     frame:RegisterEvent("PLAYER_ENTERING_WORLD");
+    frame:RegisterEvent("PLAYER_REGEN_DISABLED");
     frame:RegisterEvent("READY_CHECK");
     frame:RegisterEvent("READY_CHECK_FINISHED");
     frame:RegisterEvent("GROUP_ROSTER_UPDATE");
@@ -141,6 +143,13 @@ local eventFuncs = {
     end,
     ["UNIT_NAME_UPDATE"] = function(frame)
         updateName(frame, frame.unit);
+        if frame.guid then
+            guids[frame.guid] = nil;
+        end
+        frame.guid = UnitGUID(frame.unit);
+        if frame.guid then
+            guids[frame.guid] = frame;
+        end
     end,
     ["PLAYER_ROLES_ASSIGNED"] = function(frame)
         updateRole(frame, frame.unit);
@@ -151,6 +160,15 @@ local eventFuncs = {
     ["RAID_TARGET_UPDATE"] = function(frame)
         updateRaidMarker(frame, frame.displayed);
     end,
+    ["PLAYER_REGEN_DISABLED"] = function(frame)
+        -- clear buff status on entering combat, should also use UnitAura to re-fill
+        frame.tankcd = {};
+        frame.alert = {};
+        frame.stacks = {};
+        frame.heal = {};
+        frame.buff1 = {};
+        addon.SetAuras(frame.unit, frame.guid);
+    end,
     ["UPDATE_ALL_BARS"] = function(frame)
         updateRole(frame, frame.unit);
         updateVehicle(frame);
@@ -158,6 +176,20 @@ local eventFuncs = {
         updateName(frame, frame.unit);
         updateReadyCheck(frame, frame.unit);
         updateRaidMarker(frame, frame.displayed);
+
+        if frame.guid then
+            guids[frame.guid] = nil;
+        end
+        frame.guid = UnitGUID(frame.unit);
+        if frame.guid then
+            guids[frame.guid] = frame;
+        end
+        frame.tankcd = {};
+        frame.alert = {};
+        frame.stacks = {};
+        frame.heal = {};
+        frame.buff1 = {};
+        addon.SetAuras(frame.unit, frame.guid);
     end,
 };
 eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"];