4fb3576 - Add pet and target frames
[wowui.git] / kehys / events.lua
index 3c15fcf..ff6c4c9 100644 (file)
@@ -33,7 +33,9 @@ local width = 80;
 function addon.RegisterEvents(frame)
     frame:RegisterEvent("PLAYER_ENTERING_WORLD");
     frame:RegisterEvent("RAID_TARGET_UPDATE");
+    if frame.unit == "player" then frame:RegisterEvent("PLAYER_ALIVE") end
     if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end
+    if frame.unit == "target" then frame:RegisterEvent("PLAYER_TARGET_CHANGED") end
     if not frame.nonraid then
         frame:RegisterEvent("PLAYER_REGEN_DISABLED");
         frame:RegisterEvent("READY_CHECK");
@@ -48,7 +50,10 @@ function addon.RegisterUnitEvents(frame)
     frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_PET", frame.unit, displayed);
-    if frame.unit ~= "player" then
+    if frame.unit == "focus" or frame.unit == "target" then
+        frame:RegisterUnitEvent("UNIT_TARGETABLE_CHANGED", frame.unit, displayed);
+    end
+    if not frame.nonraid or frame.unit ~= "player" then
         frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed);
     end
     if not frame.nonraid then
@@ -86,7 +91,7 @@ addon.Events.UpdateAggro = updateAggro;
 
 local function updateVehicle(frame)
     local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and
-        UnitTargetsVehicleInRaidUI(frame.unit) and UnitExists(frame.vehicle);
+        UnitTargetsVehicleInRaidUI(frame.unit) and frame.vehicle and UnitExists(frame.vehicle);
     if shouldTargetVehicle then
         if not frame.inVehicle then
             frame.inVehicle = true;
@@ -176,13 +181,14 @@ local eventFuncs = {
             frame.stacks = {};
             frame.heal = {};
             frame.buff1 = {};
+            frame.buff2 = {};
             addon.SetAuras(frame.unit, frame.guid);
         end
     end,
     ["UPDATE_ALL_BARS"] = function(frame)
         updateVehicle(frame);
         updateRaidMarker(frame, frame.displayed);
-        if frame.unit ~= "player" then
+        if not frame.nonraid or frame.unit ~= "player" then
             updateName(frame, frame.unit);
         end
         if not frame.nonraid then
@@ -201,6 +207,7 @@ local eventFuncs = {
             frame.stacks = {};
             frame.heal = {};
             frame.buff1 = {};
+            frame.buff2 = {};
             addon.SetAuras(frame.unit, frame.guid);
         end
     end,
@@ -213,6 +220,9 @@ eventFuncs["UNIT_PET"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["GROUP_ROSTER_UPDATE"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["PLAYER_ENTERING_WORLD"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["PLAYER_FOCUS_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"];
+eventFuncs["PLAYER_TARGET_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"];
+eventFuncs["UNIT_TARGETABLE_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"];
+eventFuncs["PLAYER_ALIVE"] = eventFuncs["UPDATE_ALL_BARS"];
 
 function addon.UnitEvent(self, event)
     return eventFuncs[event](self);