Modules/NamePlates: fix issues with threat coloring / other non target elements
This commit is contained in:
@@ -86,12 +86,6 @@ local oUF = ns.oUF
|
||||
local Private = oUF.Private
|
||||
|
||||
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(not unit or self.unit ~= unit) then return end
|
||||
local element = self.Health
|
||||
|
||||
@@ -148,16 +142,28 @@ local function ColorPath(self, ...)
|
||||
* event - the event triggering the update (string)
|
||||
* unit - the unit accompanying the event (string)
|
||||
--]]
|
||||
(self.Health.UpdateColor or UpdateColor) (self, ...)
|
||||
local _, unit = ...
|
||||
local args
|
||||
if unit and self.isNamePlate then
|
||||
if (event == "UNIT_THREAT_SITUATION_UPDATE" or event == "UNIT_FLAGS") and unit == "player" 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
|
||||
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(not unit or self.unit ~= unit) then return end
|
||||
|
||||
local element = self.Health
|
||||
@@ -212,6 +218,13 @@ 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
|
||||
@@ -392,6 +405,8 @@ local function Enable(self, unit)
|
||||
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
|
||||
@@ -419,6 +434,7 @@ local function Disable(self)
|
||||
self:UnregisterEvent('UNIT_FACTION', ColorPath)
|
||||
self:UnregisterEvent('UNIT_HAPPINESS', ColorPath)
|
||||
self:UnregisterEvent('UNIT_THREAT_LIST_UPDATE', ColorPath)
|
||||
self:UnregisterEvent(')UNIT_THREAT_SITUATION_UPDATE', ColorPath)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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.Rage
|
||||
|
||||
@@ -86,16 +80,25 @@ local function ColorPath(self, ...)
|
||||
* event - the event triggering the update (string)
|
||||
* unit - the unit accompanying the event (string)
|
||||
--]]
|
||||
(self.Rage.UpdateColor or UpdateColor) (self, ...)
|
||||
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
|
||||
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.Rage
|
||||
|
||||
@@ -149,9 +152,24 @@ local function Path(self, ...)
|
||||
* unit - the unit accompanying the event (string)
|
||||
* ... - the arguments accompanying the event
|
||||
--]]
|
||||
(self.Rage.Override or Update) (self, ...);
|
||||
|
||||
ColorPath(self, ...)
|
||||
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
|
||||
end
|
||||
|
||||
local function ForceUpdate(element)
|
||||
|
||||
@@ -33,12 +33,6 @@ local FFA_ICON = [[Interface\TargetingFrame\UI-PVP-FFA]]
|
||||
local FACTION_ICON = [[Interface\TargetingFrame\UI-PVP-]]
|
||||
|
||||
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.PvPIndicator
|
||||
@@ -93,7 +87,22 @@ local function Path(self, ...)
|
||||
* event - the event triggering the update (string)
|
||||
* ... - the arguments accompanying the event
|
||||
--]]
|
||||
return (self.PvPIndicator.Override or Update) (self, ...)
|
||||
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
|
||||
end
|
||||
|
||||
local function ForceUpdate(element)
|
||||
|
||||
@@ -36,13 +36,6 @@ local UnitExists = UnitExists
|
||||
local UnitThreatSituation = UnitThreatSituation
|
||||
|
||||
local function Update(self, event, unit)
|
||||
if not unit then return end
|
||||
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.ThreatIndicator
|
||||
@@ -103,7 +96,22 @@ local function Path(self, ...)
|
||||
* event - the event triggering the update (string)
|
||||
* ... - the arguments accompanying the event
|
||||
--]]
|
||||
return (self.ThreatIndicator.Override or Update) (self, ...)
|
||||
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
|
||||
end
|
||||
|
||||
local function ForceUpdate(element)
|
||||
|
||||
@@ -539,6 +539,7 @@ function NP:ConfigureAll(init)
|
||||
end
|
||||
|
||||
function NP:PlateFade(nameplate, timeToFade, startAlpha, endAlpha)
|
||||
if not nameplate.nameplateAnchor:IsShown() then return end
|
||||
-- we need our own function because we want a smooth transition and dont want it to force update every pass.
|
||||
-- its controlled by fadeTimer which is reset when UIFrameFadeOut or UIFrameFadeIn code runs.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user