From: Aleksi Blinnikka Date: Sat, 20 Jan 2018 22:29:36 +0000 (+0200) Subject: Add role icon X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/7b95a32f32a637e9e3780d45d10691fd37c64693?ds=sidebyside;hp=92fe6f25185f79a8c40a382d1e420fbea08f12f5 Add role icon --- 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 = ...; diff --git a/OmaRF/FrameInit.lua b/OmaRF/FrameInit.lua index df34967..35de1d1 100644 --- a/OmaRF/FrameInit.lua +++ b/OmaRF/FrameInit.lua @@ -102,15 +102,9 @@ end 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); @@ -129,6 +123,13 @@ end 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); @@ -184,6 +185,12 @@ local function setupFrame(frame, secure, unit) 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);