X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/92fe6f25185f79a8c40a382d1e420fbea08f12f5..7b95a32f32a637e9e3780d45d10691fd37c64693:/OmaRF/CFrame.lua?ds=sidebyside diff --git a/OmaRF/CFrame.lua b/OmaRF/CFrame.lua index ff674d3..64db699 100644 --- a/OmaRF/CFrame.lua +++ b/OmaRF/CFrame.lua @@ -15,6 +15,7 @@ local UnitHasIncomingResurrection = UnitHasIncomingResurrection; 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; @@ -38,7 +39,6 @@ local powerColors = Frames.PowerColors; 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 @@ -48,26 +48,30 @@ local function updateHealth(frame, unit) 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 @@ -219,9 +223,23 @@ local function updateVehicle(frame) 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 @@ -247,6 +265,7 @@ local eventFuncs = { ["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, @@ -261,22 +280,26 @@ local eventFuncs = { 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); @@ -285,6 +308,7 @@ local eventFuncs = { updatePowerColor(frame, frame.displayed); updateAggro(frame, frame.displayed); updateName(frame, frame.displayed); + updateRole(frame, frame.unit); end, }; eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"]; @@ -292,6 +316,7 @@ eventFuncs["PARTY_MEMBER_DISABLE"] = eventFuncs["PARTY_MEMBER_ENABLE"]; 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 = ...;