local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs;
local IsInGroup, IsInRaid = IsInGroup, IsInRaid;
local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI;
+local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
local CTimerAfter = C_Timer.After;
local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
local function updateHealth(frame, unit)
local current, max = UnitHealth(unit), frame.health.max;
- local healthLost = max - current;
frame.health:Show();
-- sanity check, occasionally UnitHealthMax gives zero
if current > max then
if current > max then
-- error state, still over maximum
frame.health:SetWidth(width);
- frame.text:Hide();
return;
end
elseif max > 0 then
frame.health:SetWidth(current/frame.health.max*width);
else
frame.health:SetWidth(width);
- frame.text:Hide();
return;
end
if UnitIsDeadOrGhost(unit) then
frame.health:Hide();
+ end
+end
+
+local function updateText(frame, unit)
+ local current, max = UnitHealth(unit), frame.health.max;
+ local healthLost = max - current;
+ if UnitIsDeadOrGhost(unit) then
if UnitHasIncomingResurrection(unit) then
frame.text:SetText("Rez");
else
frame.text:SetText("Dead");
end
elseif not UnitIsConnected(unit) then
- frame.health:Hide();
frame.text:SetText("DC");
elseif healthLost > 0 then
if healthLost > 1200000000 then -- 1.2B
end
end
+local function updateRole(frame, unit)
+ local role = UnitGroupRolesAssigned(unit);
+ if role == "HEALER" then
+ frame.role:SetTexCoord(0.75, 1, 0, 1);
+ frame.role:Show();
+ elseif role == "TANK" then
+ frame.role:SetTexCoord(0.5, 0.75, 0, 1);
+ frame.role:Show();
+ else
+ frame.role:Hide();
+ end
+end
+
local eventFuncs = {
["UNIT_HEALTH"] = function(frame)
updateHealth(frame, frame.displayed);
+ updateText(frame, frame.displayed);
updateShield(frame, frame.displayed);
updateHealAbsorb(frame, frame.displayed);
-- no heal prediction update, that doesn't overflow too much
["UNIT_MAXHEALTH"] = function(frame)
updateMaxHealth(frame, frame.displayed);
updateHealth(frame, frame.displayed);
+ updateText(frame, frame.displayed);
updateShield(frame, frame.displayed);
updateHealAbsorb(frame, frame.displayed);
end,
updateName(frame, frame.displayed);
end,
["UNIT_CONNECTION"] = function(frame)
- updateHealth(frame, frame.displayed);
+ updateText(frame, frame.displayed);
end,
["INCOMING_RESURRECT_CHANGED"] = function(frame)
-- TODO have an icon
- updateHealth(frame, frame.displayed);
+ updateText(frame, frame.displayed);
end,
["PARTY_MEMBER_ENABLE"] = function(frame)
-- new power info possibly (FrameXML/CompactUnitFrame.lua)
updateMaxPower(frame, frame.displayed);
updatePowerColor(frame, frame.displayed);
end,
+ ["PLAYER_ROLES_ASSIGNED"] = function(frame)
+ updateRole(frame, frame.unit);
+ end,
["UPDATE_ALL_BARS"] = function(frame)
updateVehicle(frame);
updateMaxHealth(frame, frame.displayed);
updateMaxPower(frame, frame.displayed);
updateHealth(frame, frame.displayed);
+ updateText(frame, frame.displayed);
updatePower(frame, frame.displayed);
updateAuras(frame, frame.displayed);
updateShield(frame, frame.displayed);
updatePowerColor(frame, frame.displayed);
updateAggro(frame, frame.displayed);
updateName(frame, frame.displayed);
+ updateRole(frame, frame.unit);
end,
};
eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"];
eventFuncs["UNIT_ENTERED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"];
eventFuncs["UNIT_EXITED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"];
eventFuncs["UNIT_PET"] = eventFuncs["UPDATE_ALL_BARS"];
+eventFuncs["GROUP_ROSTER_UPDATE"] = eventFuncs["UPDATE_ALL_BARS"];
--local function unitEvent(self, event, ...)
local function unitEvent(self, event)
--local arg1, arg2, arg3, arg4 = ...;