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 = ...;
function M.RegisterEvents(frame)
-- events are taken from FrameXML/CompactUnitFrame.lua
- -- TODO vehicle support, ready check support, raid marker support,
+ -- TODO ready check support, raid marker support,
-- player flags support (/afk, /dnd)
- -- TODO only update for vehicle events here
local displayed = frame.unit ~= frame.displayed and frame.displayed or nil;
- frame:RegisterEvent("PARTY_MEMBER_ENABLE");
- frame:RegisterEvent("PARTY_MEMBER_DISABLE");
- frame:RegisterEvent("UNIT_ENTERED_VEHICLE");
- frame:RegisterEvent("UNIT_EXITED_VEHICLE");
- frame:RegisterEvent("UNIT_PET");
frame:RegisterUnitEvent("UNIT_HEALTH", frame.unit, displayed);
frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", frame.unit, displayed);
frame:RegisterUnitEvent("UNIT_MAXHEALTH", frame.unit, displayed);
local registerEvents = M.RegisterEvents;
local function frameShow(frame)
+ frame:RegisterEvent("PARTY_MEMBER_ENABLE");
+ frame:RegisterEvent("PARTY_MEMBER_DISABLE");
+ frame:RegisterEvent("UNIT_ENTERED_VEHICLE");
+ frame:RegisterEvent("UNIT_EXITED_VEHICLE");
+ frame:RegisterEvent("UNIT_PET");
+ frame:RegisterEvent("PLAYER_ROLES_ASSIGNED");
+ frame:RegisterEvent("GROUP_ROSTER_UPDATE");
registerEvents(frame);
frame:SetScript("OnUpdate", unitUpdate);
unitEvent(frame, "UPDATE_ALL_BARS", frame.displayed);
frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
frame.healabsorb:Hide();
+ frame.role = frame:CreateTexture(nil, "ARTWORK");
+ frame.role:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", -2, 2);
+ frame.role:SetPoint("TOPLEFT", frame.background, "BOTTOMRIGHT", -14, 14);
+ frame.role:SetTexCoord(0.75, 1, 0, 1);
+ frame.role:SetTexture("Interface\\LFGFRAME\\LFGROLE");
+ frame.role:Hide();
frame.overlay = frame:CreateTexture(nil, "ARTWORK", nil, 1);
frame.overlay:SetPoint("TOPLEFT", frame.background, "TOPLEFT");
frame.overlay:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", 0, 2);