Libs/oUF: Nameplates now have native UNIT events

This commit is contained in:
andrew6180
2024-04-19 09:05:53 -07:00
parent a5d90d5ed9
commit 0b4c66e6a2
24 changed files with 17 additions and 313 deletions
-13
View File
@@ -356,13 +356,6 @@ local function filterIcons(element, unit, filter, limit, isDebuff, offset, dontH
end
local function UpdateAuras(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local auras = self.Auras
@@ -509,12 +502,6 @@ local function UpdateAuras(self, event, unit)
end
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
UpdateAuras(self, event, unit)
+11 -75
View File
@@ -114,12 +114,6 @@ end
-- end block
local function CastStart(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Castbar
@@ -213,12 +207,6 @@ local function CastStart(self, event, unit)
end
local function CastUpdate(self, event, unit, _, _, castID)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Castbar
@@ -272,12 +260,6 @@ local function CastUpdate(self, event, unit, _, _, castID)
end
local function CastStop(self, event, unit, _, _, castID)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Castbar
@@ -307,12 +289,6 @@ local function CastStop(self, event, unit, _, _, castID)
end
local function CastFail(self, event, unit, _, _, castID)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Castbar
@@ -350,12 +326,6 @@ local function CastFail(self, event, unit, _, _, castID)
end
local function CastInterruptible(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Castbar
@@ -440,43 +410,22 @@ local function ForceUpdate(element)
return Update(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function NamePlateCastBarOnShow(self)
if C_NamePlateManager.IsNamePlateMoving(self) then return end
CastStart(self, "UNIT_SPELLCAST_START", self.unit)
end
local function NamePlateCastBarOnHide(self)
if C_NamePlateManager.IsNamePlateMoving(self) then return end
CastFail(self, "UNIT_SPELLCAST_FAILED", self.unit, nil, nil, self.Castbar.castID)
end
local function NamePlateCastBarOnValueChanged(self)
CastUpdate(self, nil, self.unit, nil, nil, self.Castbar.castID)
end
local function Enable(self, unit)
local element = self.Castbar
if(element and unit and not unit:match('%wtarget$')) then
element.__owner = self
element.ForceUpdate = ForceUpdate
if self.isNamePlate then
local castBar = self.nameplateAnchor.CastBar
castBar:SetScript("OnShow", GenerateClosure(NamePlateCastBarOnShow, self))
castBar:SetScript("OnHide", GenerateClosure(NamePlateCastBarOnHide, self))
castBar:SetScript("OnValueChanged", GenerateClosure(NamePlateCastBarOnValueChanged, self))
else
self:RegisterEvent('UNIT_SPELLCAST_START', CastStart)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', CastStart)
self:RegisterEvent('UNIT_SPELLCAST_STOP', CastStop)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop)
self:RegisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate)
self:RegisterEvent('UNIT_SPELLCAST_FAILED', CastFail)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible)
self:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible)
end
self:RegisterEvent('UNIT_SPELLCAST_START', CastStart)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', CastStart)
self:RegisterEvent('UNIT_SPELLCAST_STOP', CastStop)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop)
self:RegisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate)
self:RegisterEvent('UNIT_SPELLCAST_FAILED', CastFail)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible)
self:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible)
-- ElvUI block
self:RegisterEvent('UNIT_SPELLCAST_SENT', UNIT_SPELLCAST_SENT, true)
@@ -521,13 +470,7 @@ local function Disable(self)
if(element) then
element:Hide()
if self.isNamePlate then
local castBar = self.nameplateAnchor.CastBar
castBar:SetScript("OnShow", nil)
castBar:SetScript("OnHide", nil)
castBar:SetScript("OnValueChanged", nil)
else
self:UnregisterEvent('UNIT_SPELLCAST_START', CastStart)
self:UnregisterEvent('UNIT_SPELLCAST_START', CastStart)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_START', CastStart)
self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate)
@@ -537,7 +480,6 @@ local function Disable(self)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible)
self:UnregisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible)
end
element:SetScript('OnUpdate', nil)
@@ -561,12 +503,6 @@ end)
oUF:AddElement('Castbar', Update, Enable, Disable)
function CastingBarFrame_SetUnit(self, unit, showTradeSkills, showShield)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then
self.unit = unit
self.showTradeSkills = showTradeSkills
@@ -37,12 +37,6 @@ local UnitHasVehicleUI = UnitHasVehicleUI
local MAX_COMBO_POINTS = MAX_COMBO_POINTS
local function Update(self, event, unit)
if self.isNamePlate then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(unit == 'pet') then return end
local element = self.ComboPoints
@@ -30,12 +30,6 @@ local GetPetHappiness = GetPetHappiness
local HasPetUI = HasPetUI
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(not unit or self.unit ~= unit) then return end
local element = self.HappinessIndicator
+1 -38
View File
@@ -142,25 +142,7 @@ local function ColorPath(self, ...)
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
--]]
local _, unit = ...
local args
if unit and self.isNamePlate then
if ((event == "UNIT_THREAT_SITUATION_UPDATE" or event == "UNIT_FLAGS") and unit == "player") or event == "UNIT_THREAT_LIST_UPDATE" then
args = { ... }
args[2] = self.unit
elseif unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
args = { ... }
args[2] = self.unit
end
end
end
if args then
(self.Health.UpdateColor or UpdateColor) (self, unpack(args))
else
(self.Health.UpdateColor or UpdateColor) (self, ...)
end
(self.Health.UpdateColor or UpdateColor) (self, ...)
end
local function Update(self, event, unit)
@@ -218,13 +200,6 @@ local function Path(self, ...)
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
--]]
local _, unit = ...
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
(self.Health.Override or Update) (self, ...);
ColorPath(self, ...)
end
@@ -397,18 +372,6 @@ local function Enable(self, unit)
self:RegisterEvent('UNIT_MAXHEALTH', Path)
if self.isNamePlate then
local healthBar = self.nameplateAnchor.HealthBar
healthBar:SetScript("OnValueChanged", function()
Path(self, "UNIT_HEALTH", self.unit)
end)
healthBar:SetScript("OnMinMaxChanged", function()
Path(self, "UNIT_MAXHEALTH", self.unit)
end)
self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', Path)
self:RegisterEvent('UNIT_FLAGS', Path)
end
if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then
element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
@@ -43,12 +43,6 @@ local UnitIsUnit = UnitIsUnit
local UnitIsVisible = UnitIsVisible
local function Update(self, event, unit)
if self.isNamePlate then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(not unit or not UnitIsUnit(self.unit, unit)) then return end
local element = self.Portrait
-12
View File
@@ -100,12 +100,6 @@ local UnitPowerType = UnitPowerType
local UnitReaction = UnitReaction
local function UpdateColor(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Power
@@ -176,12 +170,6 @@ local function ColorPath(self, ...)
end
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Power
@@ -17,12 +17,6 @@ local UnitPowerType = UnitPowerType
local UnitReaction = UnitReaction
local function UpdateColor(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Energy
@@ -90,12 +84,6 @@ local function ColorPath(self, ...)
end
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if(self.unit ~= unit) then return end
local element = self.Energy
+3 -34
View File
@@ -80,22 +80,7 @@ local function ColorPath(self, ...)
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
--]]
local _, unit = ...
local args
if unit and self.isNamePlate then
if unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
args = { ... }
args[2] = self.unit
end
end
end
if args then
return (self.Rage.UpdateColor or UpdateColor) (self, unpack(args))
else
return (self.Rage.UpdateColor or UpdateColor) (self, ...)
end
return (self.Rage.UpdateColor or UpdateColor) (self, ...)
end
local function Update(self, event, unit)
@@ -152,24 +137,8 @@ local function Path(self, ...)
* unit - the unit accompanying the event (string)
* ... - the arguments accompanying the event
--]]
local _, unit = ...
local args
if unit and self.isNamePlate then
if unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
args = { ... }
args[2] = self.unit
end
end
end
if args then
(self.Rage.Override or Update) (self, unpack(args));
ColorPath(self, unpack(args))
else
(self.Rage.Override or Update) (self, ...);
ColorPath(self, ...)
end
(self.Rage.Override or Update) (self, ...);
ColorPath(self, ...)
end
local function ForceUpdate(element)
+1 -16
View File
@@ -87,22 +87,7 @@ local function Path(self, ...)
* event - the event triggering the update (string)
* ... - the arguments accompanying the event
--]]
local _, unit = ...
local args
if unit and self.isNamePlate then
if unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
args = { ... }
args[2] = self.unit
end
end
end
if args then
return (self.PvPIndicator.Override or Update) (self, unpack(args))
else
return (self.PvPIndicator.Override or Update) (self, ...)
end
return (self.PvPIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
@@ -96,22 +96,7 @@ local function Path(self, ...)
* event - the event triggering the update (string)
* ... - the arguments accompanying the event
--]]
local _, unit = ...
local args
if unit and self.isNamePlate then
if unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
args = { ... }
args[2] = self.unit
end
end
end
if args then
return (self.ThreatIndicator.Override or Update) (self, unpack(args))
else
return (self.ThreatIndicator.Override or Update) (self, ...)
end
return (self.ThreatIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
@@ -190,12 +190,6 @@ local function sortByTime(a, b)
end
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if self.unit ~= unit then return end
local element = self.AuraBars
@@ -258,12 +258,6 @@ end
local found = {}
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local guid = UnitGUID(unit)
@@ -83,12 +83,6 @@ local function Shared_UpdateCheckReturn(self, element, updateType, ...)
return (not element.enabled or not self.cur) or element.ready or not maxV
elseif (updateType == POST) then
local curV, maxV, unit = ...
if unit and element.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = element.unit and UnitIsUnit(element.unit, unit)
if isUnit then
unit = element.unit
end
end
return (not element.enabled or not element.cur) or (not element.ready or not curV or not maxV) or element.unit ~= unit
else
return false
@@ -26,12 +26,6 @@ local function GetDebuffType(unit, filterTable)
end
local function Update(object, event, unit)
if unit and object.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = object.unit and UnitIsUnit(object.unit, unit)
if isUnit then
unit = object.unit
end
end
if unit ~= object.unit then return end
local debuffType, texture, wasFiltered, style, color = GetDebuffType(unit, object.DebuffHighlightFilterTable)
@@ -62,12 +62,6 @@ local function Update(self, _, unit)
end
unit = unit or self.unit
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if self.unit ~= unit then return end
-- range fader
@@ -161,12 +161,6 @@ local function UpdateDebuff(self, name, icon, count, debuffType, duration, endTi
end
local function Update(self, event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if unit ~= self.unit then return end
local element = self.RaidDebuffs
@@ -37,12 +37,6 @@ local UnitName = UnitName
local enabledUF, enabled = {}
local function Update(self, event, unit, succeeded)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local element = self.ResurrectIndicator
@@ -12,12 +12,6 @@ local UnitIsConnected = UnitIsConnected
local CreateFrame = CreateFrame
function NP:Health_UpdateColor(_, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local element = self.Health
@@ -13,12 +13,6 @@ local UnitPowerType = UnitPowerType
local POWERTYPE_ALTERNATE = 10
function NP:Power_UpdateColor(_, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if self.unit ~= unit then return end
local element = self.Power
-7
View File
@@ -1512,13 +1512,6 @@ do -- oUF style filter inject watch functions without actually registering any e
local update = function(frame, event, arg1, arg2, arg3, ...)
local eventFunc = mod.StyleFilterEventFunctions[event]
if arg1 and frame.isNamePlate and arg1:sub(1, 9) ~= "nameplate" then
local isUnit = frame.unit and UnitIsUnit(frame.unit, arg1)
if isUnit then
arg1 = frame.unit
end
end
if eventFunc then
eventFunc(frame, event, arg1, arg2, arg3, ...)
end
@@ -65,12 +65,6 @@ function UF:Configure_Happiness(frame)
end
function UF:HappinessOverride(event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local db = self.db
@@ -30,12 +30,6 @@ function UF:Configure_PVPIcon(frame)
end
function UF:UpdateOverridePvP(event, unit)
if unit and self.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = self.unit and UnitIsUnit(self.unit, unit)
if isUnit then
unit = self.unit
end
end
if not unit or self.unit ~= unit then return end
local element = self.PvPIndicator
@@ -95,12 +95,6 @@ end
function UF:UpdateThreat(unit, status, r, g, b)
local parent = self:GetParent()
if unit and parent.isNamePlate and unit:sub(1, 9) ~= "nameplate" then
local isUnit = parent.unit and UnitIsUnit(parent.unit, unit)
if isUnit then
unit = parent.unit
end
end
if (parent.unit ~= unit) or not unit then return end
local db = parent.db