Commit d748dae7 authored by Sean Anderson / Shrom's avatar Sean Anderson / Shrom
Browse files

remove duplicate alpha calculations

parent 06c1e7be
......@@ -407,36 +407,26 @@ function NP:IsBlizzardPlateOccluded(nameplate)
return E:Round(nameplate:GetParent():GetAlpha(), 2) == OccludedAlpha
end
function NP:GetNonTargetAlpha(nameplate, hasTarget)
local Alpha = NP.db.units.TARGET.nonTargetTransparency
if (nameplate.frameType == 'PLAYER') or nameplate.isTarget then
Alpha = 1
elseif (not nameplate.isTarget) and not nameplate.isUnitOccluded and NP:IsBlizzardPlateOccluded(nameplate) then
Alpha = Alpha * 0.5
elseif not hasTarget then
Alpha = 1
end
return Alpha
function NP:GetAlpha(nameplate, hasTarget)
local Alpha = NP.db.units.TARGET.nonTargetTransparency
if (nameplate.frameType == 'PLAYER') or nameplate.isTarget or not hasTarget then
Alpha = 1
elseif nameplate.isUnitOccluded and NP:IsBlizzardPlateOccluded(nameplate) then
Alpha = Alpha * 0.5
end
return Alpha
end
function NP:HandleTargetAlpha(nameplate, added)
if nameplate then
local alpha
if nameplate.frameType == 'PLAYER' then
alpha = 1
else
local hasTarget = UnitExists('target')
local newAlpha = (nameplate.isTarget and 1) or (hasTarget and NP.db.units.TARGET.nonTargetTransparency)
alpha = newAlpha or NP:GetNonTargetAlpha(nameplate, hasTarget)
end
function NP:HandleAlpha(nameplate, added)
if nameplate then
local alpha = NP:GetAlpha(nameplate, UnitExists('target'))
if added and NP.db.fadeIn then
E:UIFrameFadeIn(nameplate, 1, 0, alpha)
else
nameplate:SetAlpha(alpha)
end
end
if added and NP.db.fadeIn then
E:UIFrameFadeIn(nameplate, 1, 0, alpha)
else
nameplate:SetAlpha(alpha)
end
end
end
function NP:WatchOccluded(elapsed)
......@@ -504,7 +494,7 @@ function NP:NamePlateCallBack(nameplate, event, unit)
nameplate.OccludedWatcher:SetScript('OnUpdate', NP.WatchOccluded)
NP:HandleTargetAlpha(nameplate, true)
NP:HandleAlpha(nameplate, true)
NP:StyleFilterUpdate(nameplate, event) -- keep this at the end
elseif event == 'NAME_PLATE_UNIT_REMOVED' then
......@@ -533,7 +523,7 @@ end
NP.plateEvents = {
['PLAYER_TARGET_CHANGED'] = function(self)
self.isTarget = self.unit and UnitIsUnit(self.unit, 'target') or nil
NP:HandleTargetAlpha(self)
NP:HandleAlpha(self)
end,
['UNIT_TARGET'] = function(self, _, unit)
unit = unit or self.unit
......
......@@ -312,7 +312,7 @@ function mod:StyleFilterClearChanges(frame, HealthColorChanged, PowerColorChange
end
if AlphaChanged then
frame.AlphaChanged = nil
mod:HandleTargetAlpha(frame)
mod:HandleAlpha(frame)
end
if NameColorChanged then
frame.NameColorChanged = nil
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment