Nameplate Overhaul (#38)

* ElvUI/NamePlates: initial nameplate conversions

* More nameplate work

* Modules/Cooldowns: various CD fixes, nameplates cant show 'swipe' texture

* ElvUI/NamePlates: final nameplate polish

* Modules/Misc: add space before interrupted announcement
This commit is contained in:
Andrew
2023-05-22 19:18:59 -07:00
committed by GitHub
parent 5d51f92ed3
commit 8edf2d7f8a
75 changed files with 8870 additions and 8088 deletions
+32
View File
@@ -14,6 +14,10 @@ local hiddenParent = CreateFrame('Frame', nil, UIParent)
hiddenParent:SetAllPoints()
hiddenParent:Hide()
local offScreenParent = CreateFrame('Frame', nil, UIParent)
offScreenParent:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", 0, -128)
offScreenParent:SetFrameLevel(0)
local function handleFrame(baseName)
local frame
if(type(baseName) == 'string') then
@@ -51,6 +55,34 @@ local function handleFrame(baseName)
end
end
function oUF:DisableBlizzardNamePlate(nameplate)
-- we have to preserve the base frame since the unit frame will attach to it
local blizzElements = {nameplate:GetRegions()}
local healthBar, castBar = nameplate:GetChildren()
tinsert(blizzElements, healthBar)
nameplate.blizzHighlight = blizzElements[6]
nameplate.HealthBar = healthBar
nameplate.CastBar = castBar
for _, child in ipairs(blizzElements) do
child:SetParent(hiddenParent)
child:SetAlpha(0)
child:Hide()
if child.SetTexture then
child:SetTexture()
elseif child.SetStatusBarTexture then
child:SetStatusBarTexture(nil) -- this needs nil
end
end
-- cast bar has to be special because we need onhide / onshow to fire still
castBar:SetParent(offScreenParent)
castBar:SetStatusBarTexture(nil)
castBar:SetAlpha(0)
castBar:Hide()
end
function oUF:DisableBlizzard(unit)
if(not unit) then return end
+5 -5
View File
@@ -31,15 +31,15 @@ local colors = {
}
for classToken, color in next, RAID_CLASS_COLORS do
colors.class[classToken] = {color.r, color.g, color.b}
colors.class[classToken] = {color.r, color.g, color.b, r = color.r, g = color.g, b = color.b}
end
for debuffType, color in next, DebuffTypeColor do
colors.debuff[debuffType] = {color.r, color.g, color.b}
colors.debuff[debuffType] = {color.r, color.g, color.b, r = color.r, g = color.g, b = color.b}
end
for eclass, color in next, FACTION_BAR_COLORS do
colors.reaction[eclass] = {color.r, color.g, color.b}
colors.reaction[eclass] = {color.r, color.g, color.b, r = color.r, g = color.g, b = color.b}
end
for power, color in next, PowerBarColor do
@@ -48,10 +48,10 @@ for power, color in next, PowerBarColor do
colors.power[power] = {}
for index, color in next, color do
colors.power[power][index] = {color.r, color.g, color.b}
colors.power[power][index] = {color.r, color.g, color.b, r = color.r, g = color.g, b = color.b}
end
else
colors.power[power] = {color.r, color.g, color.b, atlas = color.atlas}
colors.power[power] = {color.r, color.g, color.b, atlas = color.atlas, r = color.r, g = color.g, b = color.b}
end
end
end
+13
View File
@@ -356,6 +356,13 @@ 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
@@ -502,6 +509,12 @@ 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)
+89 -23
View File
@@ -103,6 +103,7 @@ local function resetAttributes(self)
self.channeling = nil
self.notInterruptible = nil
self.spellName = nil -- ElvUI
self.spellID = nil
end
-- ElvUI block
@@ -113,13 +114,19 @@ 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
local name, _, _, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
local name, _, _, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit)
event = 'UNIT_SPELLCAST_START'
if(not name) then
name, _, _, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo(unit)
name, _, _, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID = UnitChannelInfo(unit)
event = 'UNIT_SPELLCAST_CHANNEL_START'
end
@@ -141,6 +148,7 @@ local function CastStart(self, event, unit)
element.notInterruptible = notInterruptible
element.holdTime = 0
element.castID = castID
element.spellID = spellID
element.spellName = name -- ElvUI
if(element.casting) then
@@ -205,6 +213,12 @@ 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
@@ -258,6 +272,12 @@ 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
@@ -287,6 +307,12 @@ 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
@@ -324,6 +350,12 @@ 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
@@ -408,22 +440,43 @@ 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
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)
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
-- ElvUI block
self:RegisterEvent('UNIT_SPELLCAST_SENT', UNIT_SPELLCAST_SENT, true)
@@ -454,7 +507,7 @@ local function Enable(self, unit)
local safeZone = element.SafeZone
if(safeZone and safeZone:IsObjectType('Texture') and not safeZone:GetTexture()) then
safeZone:SetColorTexture(1, 0, 0)
safeZone:SetTexture(1, 0, 0)
end
element:Hide()
@@ -468,16 +521,23 @@ local function Disable(self)
if(element) then
element:Hide()
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)
self:UnregisterEvent('UNIT_SPELLCAST_STOP', CastStop)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop)
self:UnregisterEvent('UNIT_SPELLCAST_FAILED', CastFail)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible)
self:UnregisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible)
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_CHANNEL_START', CastStart)
self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', CastUpdate)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', CastUpdate)
self:UnregisterEvent('UNIT_SPELLCAST_STOP', CastStop)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', CastStop)
self:UnregisterEvent('UNIT_SPELLCAST_FAILED', CastFail)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', CastFail)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE', CastInterruptible)
self:UnregisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE', CastInterruptible)
end
element:SetScript('OnUpdate', nil)
@@ -501,6 +561,12 @@ 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,6 +37,12 @@ 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,6 +30,12 @@ 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
+41 -1
View File
@@ -86,6 +86,12 @@ 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
@@ -146,7 +152,14 @@ 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(not unit or self.unit ~= unit) then return end
local element = self.Health
--[[ Callback: Health:PreUpdate(unit)
@@ -200,7 +213,6 @@ local function Path(self, ...)
* unit - the unit accompanying the event (string)
--]]
(self.Health.Override or Update) (self, ...);
ColorPath(self, ...)
end
@@ -242,6 +254,23 @@ local function SetColorHappiness(element, state)
end
end
--[[ Health:SetColorSelection(state, isForced)
Used to toggle coloring by the unit's selection.
* self - the Health element
* state - the desired state (boolean)
* isForced - forces the event update even if the state wasn't changed (boolean)
--]]
local function SetColorSelection(element, state, isForced)
if(element.colorSelection ~= state or isForced) then
element.colorSelection = state
if(state) then
element.__owner:RegisterEvent('UNIT_FLAGS', ColorPath)
else
element.__owner:UnregisterEvent('UNIT_FLAGS', ColorPath)
end
end
end
--[[ Health:SetColorTapping(state)
Used to toggle coloring if the unit isn't tapped by the player.
@@ -320,6 +349,7 @@ local function Enable(self, unit)
element.__owner = self
element.ForceUpdate = ForceUpdate
element.SetColorDisconnected = SetColorDisconnected
element.SetColorSelection = SetColorSelection
element.SetColorHappiness = SetColorHappiness
element.SetColorTapping = SetColorTapping
element.SetColorThreat = SetColorThreat
@@ -354,6 +384,16 @@ 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)
end
if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then
element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
@@ -43,6 +43,12 @@ 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,6 +100,12 @@ 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
@@ -170,6 +176,12 @@ 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,6 +17,12 @@ 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
@@ -84,6 +90,12 @@ 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
@@ -17,6 +17,12 @@ 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
@@ -84,6 +90,12 @@ 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.Rage
@@ -33,6 +33,12 @@ 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
@@ -36,7 +36,14 @@ local UnitExists = UnitExists
local UnitThreatSituation = UnitThreatSituation
local function Update(self, event, unit)
if(not unit or self.unit ~= unit) then return end
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
--[[ Callback: ThreatIndicator:PreUpdate(unit)
+114 -1
View File
@@ -311,6 +311,10 @@ local function togglemenu(self, unit)
end
local function onShow(self)
if self.isNamePlate then
local nameplate = C_NamePlate.GetNamePlateForUnit(self.unit)
if nameplate and C_NamePlateManager.IsNamePlateMoving(nameplate.unitFrame) then return end
end
if(not updateActiveUnit(self, 'OnShow')) then
return self:UpdateAllElements('OnShow')
end
@@ -417,7 +421,6 @@ local function initObject(unit, style, styleFunc, header, ...)
activeElements[object] = {} -- ElvUI: styleFunc on headers break before this is set when they try to enable elements before it's set.
Private.UpdateUnits(object, objectUnit)
styleFunc(object, objectUnit, not header)
object:HookScript('OnAttributeChanged', onAttributeChanged)
@@ -761,6 +764,116 @@ function oUF:Spawn(unit, overrideName)
return object
end
--[[ oUF:SpawnNamePlates(prefix, callback, variables)
Used to create nameplates and apply the currently active style to them.
* self - the global oUF object
* prefix - prefix for the global name of the nameplate. Defaults to an auto-generated prefix (string?)
* callback - function to be called after a nameplate unit or the player's target has changed. The arguments passed to
the callback are the updated nameplate, if any, the event that triggered the update, and the new unit
(function?)
* variables - list of console variable-value pairs to be set when the player logs in (table?)
--]]
local nameplateUnitToFrame = {}
function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars)
argcheck(nameplateCallback, 3, 'function', 'nil')
argcheck(nameplateCVars, 4, 'table', 'nil')
if(not style) then return error('Unable to create frame. No styles have been registered.') end
if(_G.oUF_NamePlateDriver) then return error('oUF nameplate driver has already been initialized.') end
local style = style
local prefix = namePrefix or generateName()
local eventHandler = CreateFrame('Frame', 'oUF_NamePlateDriver')
eventHandler:RegisterEvent('NAME_PLATE_UNIT_ADDED')
eventHandler:RegisterEvent('NAME_PLATE_UNIT_REMOVED')
eventHandler:RegisterEvent('PLAYER_TARGET_CHANGED')
eventHandler:RegisterEvent('UNIT_FACTION')
eventHandler:RegisterEvent('UNIT_FLAGS')
if(IsLoggedIn()) then
if(nameplateCVars) then
for cvar, value in next, nameplateCVars do
SetCVar(cvar, value)
end
end
else
eventHandler:RegisterEvent('PLAYER_LOGIN')
end
C_NamePlateManager.SetEnableResizeNamePlates(true)
eventHandler:SetScript('OnEvent', function(_, event, unit)
if(event == 'PLAYER_LOGIN') then
if(nameplateCVars) then
for cvar, value in next, nameplateCVars do
SetCVar(cvar, value)
end
end
elseif(event == 'PLAYER_TARGET_CHANGED') then
local nameplate = C_NamePlate.GetNamePlateForUnit('target')
if(nameplateCallback) then
nameplateCallback(nameplate and nameplate.unitFrame, event, 'target')
end
-- UAE is called after the callback to reduce the number of
-- ForceUpdate calls layout devs have to do themselves
if(nameplate) then
nameplate.unitFrame:UpdateAllElements(event)
end
elseif(event == 'UNIT_FACTION' and unit) then
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
if(not nameplate) then return end
if(nameplateCallback) then
nameplateCallback(nameplate.unitFrame, event, unit)
end
elseif(event == 'NAME_PLATE_UNIT_ADDED' and unit) then
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
if(not nameplate) then return end
nameplateUnitToFrame[unit] = nameplate
if(not nameplate.unitFrame) then
self:DisableBlizzardNamePlate(nameplate)
nameplate.style = style
nameplate.isNamePlate = true
nameplate.unitFrame = CreateFrame('Button', prefix..tostring(nameplate), nameplate)
nameplate.unitFrame:EnableMouse(false)
nameplate.unitFrame.isNamePlate = true
nameplate.unitFrame.nameplateAnchor = nameplate
Private.UpdateUnits(nameplate.unitFrame, unit)
walkObject(nameplate.unitFrame, unit)
C_NamePlateManager.ApplyFPSIncrease(nameplate.unitFrame)
else
-- for _, child in ipairs(nameplate.blizzElements) do
-- ClearNamePlateElement(child)
-- end
Private.UpdateUnits(nameplate.unitFrame, unit)
end
nameplate.unitFrame:SetAttribute('unit', unit)
if(nameplateCallback) then
nameplateCallback(nameplate.unitFrame, event, unit)
end
-- UAE is called after the callback to reduce the number of
-- ForceUpdate calls layout devs have to do themselves
nameplate.unitFrame:UpdateAllElements(event)
elseif(event == 'NAME_PLATE_UNIT_REMOVED' and unit) then
local nameplate = nameplateUnitToFrame[unit]
if(not nameplate) then return end
nameplateUnitToFrame[unit] = nil
nameplate.unitFrame:SetAttribute('unit', nil)
if(nameplateCallback) then
nameplateCallback(nameplate.unitFrame, event, unit)
end
end
end)
end
--[[ oUF:AddElement(name, update, enable, disable)
Used to register an element with oUF.
@@ -190,6 +190,12 @@ 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,6 +258,12 @@ 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,6 +83,12 @@ 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,6 +26,12 @@ 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,6 +62,12 @@ 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
@@ -129,6 +135,7 @@ local function HoverScript(self)
end
local function TargetScript(self)
if self.isNamePlate and C_NamePlateManager.IsNamePlateMoving(self) then return end
if self.Fader and self.Fader.TargetHooked == 1 then
if self:IsShown() then
self.Fader:ForceUpdate()
@@ -161,6 +161,12 @@ 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,6 +37,12 @@ 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