f2bb494 - Change to coloring health bar instead of name in UF
[wowui.git] / OmaRF / Events.lua
index faeff80..d4f3e77 100644 (file)
@@ -7,6 +7,7 @@ local UnitName, UnitClass, UnitExists = UnitName, UnitClass, UnitExists;
 local UnitDebuff, UnitIsCharmed = UnitDebuff, UnitIsCharmed;
 local UnitPower, UnitPowerMax, UnitPowerType = UnitPower, UnitPowerMax, UnitPowerType;
 local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax;
 local UnitDebuff, UnitIsCharmed = UnitDebuff, UnitIsCharmed;
 local UnitPower, UnitPowerMax, UnitPowerType = UnitPower, UnitPowerMax, UnitPowerType;
 local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax;
+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;
@@ -34,8 +35,7 @@ local M = {};
 OmaRFEvents = M;
 function M.RegisterEvents(frame)
     -- events are taken from FrameXML/CompactUnitFrame.lua
 OmaRFEvents = M;
 function M.RegisterEvents(frame)
     -- events are taken from FrameXML/CompactUnitFrame.lua
-    -- TODO raid marker support,
-    -- player flags support (/afk, /dnd)
+    -- 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);
@@ -51,6 +51,7 @@ function M.RegisterEvents(frame)
     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("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);
 end
 local registerEvents = M.RegisterEvents;
 
 end
 local registerEvents = M.RegisterEvents;
 
@@ -88,6 +89,12 @@ local function updateText(frame, unit)
     elseif not UnitIsConnected(unit) then
         frame.text:SetText("DC");
         frame.text:Show();
     elseif not UnitIsConnected(unit) then
         frame.text:SetText("DC");
         frame.text:Show();
+    elseif UnitIsAFK(unit) then
+        frame.text:SetText("afk");
+        frame.text:Show();
+    elseif UnitIsDND(unit) and healthLost == 0 then
+        frame.text:SetText("dnd");
+        frame.text:Show();
     elseif healthLost > 0 then
         if healthLost > 1200000000 then -- 1.2B
             frame.text:SetFormattedText("-%.1fB", healthLost / 1000000000);
     elseif healthLost > 0 then
         if healthLost > 1200000000 then -- 1.2B
             frame.text:SetFormattedText("-%.1fB", healthLost / 1000000000);
@@ -260,7 +267,6 @@ local function updateRole(frame, unit)
 end
 
 local function updateReadyCheck(frame, unit)
 end
 
 local function updateReadyCheck(frame, unit)
-    if GetReadyCheckTimeLeft() <= 0 then return end
     local status = GetReadyCheckStatus(unit);
     if status == "ready" then
         frame.ready:SetTexture(READY_CHECK_READY_TEXTURE);
     local status = GetReadyCheckStatus(unit);
     if status == "ready" then
         frame.ready:SetTexture(READY_CHECK_READY_TEXTURE);
@@ -357,6 +363,7 @@ local eventFuncs = {
 };
 eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];
 eventFuncs["PARTY_MEMBER_DISABLE"] = eventFuncs["PARTY_MEMBER_ENABLE"];
 };
 eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];
 eventFuncs["PARTY_MEMBER_DISABLE"] = eventFuncs["PARTY_MEMBER_ENABLE"];
+eventFuncs["PLAYER_FLAGS_CHANGED"] = eventFuncs["UNIT_CONNECTION"];
 eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"];
 eventFuncs["READY_CHECK_FINISHED"] = eventFuncs["READY_CHECK"];
 eventFuncs["UNIT_ENTERED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"];
 eventFuncs["READY_CHECK_FINISHED"] = eventFuncs["READY_CHECK"];
 eventFuncs["UNIT_ENTERED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"];
@@ -364,6 +371,7 @@ eventFuncs["UNIT_EXITED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["UNIT_PET"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["GROUP_ROSTER_UPDATE"] = eventFuncs["UPDATE_ALL_BARS"];
 eventFuncs["PLAYER_ENTERING_WORLD"] = eventFuncs["UPDATE_ALL_BARS"];
 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"];
 
 function M.UnitEvent(self, event)
     eventFuncs[event](self);
 
 function M.UnitEvent(self, event)
     eventFuncs[event](self);