a296877 - Add option to iterate over UnitAura instead of aura list
[wowui.git] / OmaRF / Events.lua
index 26565ab..af49cd4 100644 (file)
@@ -11,11 +11,11 @@ local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND;
 local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs;
 local UnitThreatSituation, GetThreatStatusColor = UnitThreatSituation, GetThreatStatusColor;
 local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected;
 local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs;
 local UnitThreatSituation, GetThreatStatusColor = UnitThreatSituation, GetThreatStatusColor;
 local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected;
-local UnitHasIncomingResurrection = UnitHasIncomingResurrection;
 local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs;
 local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI;
 local GetReadyCheckTimeLeft, GetReadyCheckStatus = GetReadyCheckTimeLeft, GetReadyCheckStatus;
 local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
 local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs;
 local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI;
 local GetReadyCheckTimeLeft, GetReadyCheckStatus = GetReadyCheckTimeLeft, GetReadyCheckStatus;
 local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
+local GetRaidTargetIndex, SetRaidTargetIconTexture = GetRaidTargetIndex, SetRaidTargetIconTexture;
 local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
 local READY_CHECK_READY_TEXTURE = READY_CHECK_READY_TEXTURE;
 local READY_CHECK_NOT_READY_TEXTURE = READY_CHECK_NOT_READY_TEXTURE;
 local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
 local READY_CHECK_READY_TEXTURE = READY_CHECK_READY_TEXTURE;
 local READY_CHECK_NOT_READY_TEXTURE = READY_CHECK_NOT_READY_TEXTURE;
@@ -39,6 +39,7 @@ function M.RegisterEvents(frame)
     frame:RegisterEvent("READY_CHECK");
     frame:RegisterEvent("READY_CHECK_FINISHED");
     frame:RegisterEvent("GROUP_ROSTER_UPDATE");
     frame:RegisterEvent("READY_CHECK");
     frame:RegisterEvent("READY_CHECK_FINISHED");
     frame:RegisterEvent("GROUP_ROSTER_UPDATE");
+    frame:RegisterEvent("RAID_TARGET_UPDATE");
     if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end
 end
 
     if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end
 end
 
@@ -70,7 +71,6 @@ end
 
 function M.RegisterUnitEvents(frame)
     -- events are taken from FrameXML/CompactUnitFrame.lua
 
 function M.RegisterUnitEvents(frame)
     -- events are taken from FrameXML/CompactUnitFrame.lua
-    -- TODO raid marker support
     local displayed = frame.unit ~= frame.displayed and frame.displayed or nil;
     frame:RegisterUnitEvent("UNIT_HEALTH", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", frame.unit, displayed);
     local displayed = frame.unit ~= frame.displayed and frame.displayed or nil;
     frame:RegisterUnitEvent("UNIT_HEALTH", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", frame.unit, displayed);
@@ -82,13 +82,11 @@ function M.RegisterUnitEvents(frame)
     frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_CONNECTION", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_CONNECTION", frame.unit, displayed);
-    frame:RegisterUnitEvent("INCOMING_RESURRECT_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("PLAYER_FLAGS_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("READY_CHECK_CONFIRM", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_PET", frame.unit, displayed);
     frame:RegisterUnitEvent("PLAYER_FLAGS_CHANGED", frame.unit, displayed);
     frame:RegisterUnitEvent("READY_CHECK_CONFIRM", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", frame.unit, displayed);
     frame:RegisterUnitEvent("UNIT_PET", frame.unit, displayed);
-    frame:RegisterUnitEvent("RAID_TARGET_UPDATE", frame.unit, displayed);
 end
 local registerUnitEvents = M.RegisterUnitEvents;
 
 end
 local registerUnitEvents = M.RegisterUnitEvents;
 
@@ -142,11 +140,6 @@ local function updateText(frame, unit)
     end
 end
 
     end
 end
 
-local function updateIncomingRes(frame, unit)
-    if UnitHasIncomingResurrection(unit) then frame.rez:Show();
-    else frame.rez:Hide(); end
-end
-
 local function updateMaxPower(frame, unit)
     frame.mana.max = UnitPowerMax(unit);
 end
 local function updateMaxPower(frame, unit)
     frame.mana.max = UnitPowerMax(unit);
 end
@@ -169,6 +162,7 @@ local function updatePowerColor(frame, unit)
     frame.mana:SetVertexColor(unpack(powerColors[UnitPowerType(unit)]));
 end
 
     frame.mana:SetVertexColor(unpack(powerColors[UnitPowerType(unit)]));
 end
 
+-- TODO maybe add a prefix when in vehicle
 local function updateName(frame, unit)
     local name = UnitName(unit);
     if not name then return end
 local function updateName(frame, unit)
     local name = UnitName(unit);
     if not name then return end
@@ -287,22 +281,20 @@ local function updateRole(frame, unit)
     if role == "HEALER" then
         frame.role:SetTexCoord(0.75, 1, 0, 1);
         frame.role:Show();
     if role == "HEALER" then
         frame.role:SetTexCoord(0.75, 1, 0, 1);
         frame.role:Show();
-        if not frame.role.healer then
-            registerPower(frame);
-            frame.role.healer = true;
-        end
+        registerPower(frame);
+        frame.role.healer = true;
     elseif role == "TANK" then
         frame.role:SetTexCoord(0.5, 0.75, 0, 1);
         frame.role:Show();
         if frame.role.healer then
     elseif role == "TANK" then
         frame.role:SetTexCoord(0.5, 0.75, 0, 1);
         frame.role:Show();
         if frame.role.healer then
-            unregisterPower(frame);
             frame.role.healer = false;
             frame.role.healer = false;
+            unregisterPower(frame);
         end
     else
         frame.role:Hide();
         if frame.role.healer then
         end
     else
         frame.role:Hide();
         if frame.role.healer then
-            unregisterPower(frame);
             frame.role.healer = false;
             frame.role.healer = false;
+            unregisterPower(frame);
         end
     end
 end
         end
     end
 end
@@ -324,7 +316,13 @@ local function updateReadyCheck(frame, unit)
 end
 
 local function updateRaidMarker(frame, unit)
 end
 
 local function updateRaidMarker(frame, unit)
-    --print(unit, "marker");
+    local index = GetRaidTargetIndex(unit);
+    if index then
+        SetRaidTargetIconTexture(frame.targeticon, index);
+        frame.targeticon:Show();
+    else
+        frame.targeticon:Hide();
+    end
 end
 
 local eventFuncs = {
 end
 
 local eventFuncs = {
@@ -334,9 +332,10 @@ local eventFuncs = {
         updateShield(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
         -- no heal prediction update, that doesn't overflow too much
         updateShield(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
         -- no heal prediction update, that doesn't overflow too much
-        -- raid marker update here, because marker is removed when unit dies
+        -- raid marker update here, if needed
+        -- because marker is removed when unit dies
         -- without a RAID_TARGET_UPDATE event
         -- without a RAID_TARGET_UPDATE event
-        updateRaidMarker(frame, frame.unit);
+        --updateRaidMarker(frame, frame.unit);
     end,
     ["UNIT_POWER"] = function(frame)
         updatePower(frame, frame.displayed);
     end,
     ["UNIT_POWER"] = function(frame)
         updatePower(frame, frame.displayed);
@@ -373,14 +372,11 @@ local eventFuncs = {
         updatePower(frame, frame.displayed);
     end,
     ["UNIT_NAME_UPDATE"] = function(frame)
         updatePower(frame, frame.displayed);
     end,
     ["UNIT_NAME_UPDATE"] = function(frame)
-        updateName(frame, frame.displayed);
+        updateName(frame, frame.unit);
     end,
     ["UNIT_CONNECTION"] = function(frame)
         updateText(frame, frame.displayed);
     end,
     end,
     ["UNIT_CONNECTION"] = function(frame)
         updateText(frame, frame.displayed);
     end,
-    ["INCOMING_RESURRECT_CHANGED"] = function(frame)
-        updateIncomingRes(frame, frame.unit);
-    end,
     ["PARTY_MEMBER_ENABLE"] = function(frame)
         -- new power info possibly (FrameXML/CompactUnitFrame.lua)
         updateMaxPower(frame, frame.displayed);
     ["PARTY_MEMBER_ENABLE"] = function(frame)
         -- new power info possibly (FrameXML/CompactUnitFrame.lua)
         updateMaxPower(frame, frame.displayed);
@@ -393,7 +389,7 @@ local eventFuncs = {
         updateReadyCheck(frame, frame.unit);
     end,
     ["RAID_TARGET_UPDATE"] = function(frame)
         updateReadyCheck(frame, frame.unit);
     end,
     ["RAID_TARGET_UPDATE"] = function(frame)
-        updateRaidMarker(frame, frame.unit);
+        updateRaidMarker(frame, frame.displayed);
     end,
     ["UPDATE_ALL_BARS"] = function(frame)
         updateRole(frame, frame.unit);
     end,
     ["UPDATE_ALL_BARS"] = function(frame)
         updateRole(frame, frame.unit);
@@ -411,10 +407,9 @@ local eventFuncs = {
         updateHealPred(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
         updateAggro(frame, frame.displayed);
         updateHealPred(frame, frame.displayed);
         updateHealAbsorb(frame, frame.displayed);
         updateAggro(frame, frame.displayed);
-        updateName(frame, frame.displayed);
-        updateIncomingRes(frame, frame.unit);
+        updateName(frame, frame.unit);
         updateReadyCheck(frame, frame.unit);
         updateReadyCheck(frame, frame.unit);
-        updateRaidMarker(frame, frame.unit);
+        updateRaidMarker(frame, frame.displayed);
     end,
 };
 eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];
     end,
 };
 eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];