更新配置相关显示等
This commit is contained in:
112
Units/Target.lua
112
Units/Target.lua
@@ -819,27 +819,69 @@ end
|
||||
|
||||
function SFrames.Target:TickAuras()
|
||||
if not UnitExists("target") then return end
|
||||
|
||||
|
||||
local timeNow = GetTime()
|
||||
|
||||
local npFormat = NanamiPlates_Auras and NanamiPlates_Auras.FormatTime
|
||||
local hasNP = NanamiPlates_SpellDB and NanamiPlates_SpellDB.FindEffectData
|
||||
|
||||
local targetName, targetLevel, targetGUID
|
||||
if hasNP then
|
||||
targetName = UnitName("target")
|
||||
targetLevel = UnitLevel("target") or 0
|
||||
targetGUID = UnitGUID and UnitGUID("target")
|
||||
end
|
||||
|
||||
-- Buffs
|
||||
for i = 1, 16 do
|
||||
local b = self.frame.buffs[i]
|
||||
if b:IsShown() and b.expirationTime then
|
||||
local timeLeft = b.expirationTime - timeNow
|
||||
if timeLeft > 0 and timeLeft < 3600 then
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
if npFormat then
|
||||
local text, r, g, bc, a = npFormat(timeLeft)
|
||||
b.cdText:SetText(text)
|
||||
if r then b.cdText:SetTextColor(r, g, bc, a or 1) end
|
||||
else
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
end
|
||||
else
|
||||
b.cdText:SetText("")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Debuffs: re-query SpellDB for live-accurate timers
|
||||
for i = 1, 16 do
|
||||
local b = self.frame.debuffs[i]
|
||||
if b:IsShown() and b.expirationTime then
|
||||
local timeLeft = b.expirationTime - timeNow
|
||||
if timeLeft > 0 and timeLeft < 3600 then
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
if b:IsShown() then
|
||||
local timeLeft = nil
|
||||
|
||||
if hasNP and b.effectName then
|
||||
local data = targetGUID and NanamiPlates_SpellDB:FindEffectData(targetGUID, targetLevel, b.effectName)
|
||||
if not data and targetName then
|
||||
data = NanamiPlates_SpellDB:FindEffectData(targetName, targetLevel, b.effectName)
|
||||
end
|
||||
if data and data.start and data.duration then
|
||||
local remaining = data.duration + data.start - timeNow
|
||||
if remaining > 0 then
|
||||
timeLeft = remaining
|
||||
b.expirationTime = timeNow + remaining
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not timeLeft and b.expirationTime then
|
||||
timeLeft = b.expirationTime - timeNow
|
||||
end
|
||||
|
||||
if timeLeft and timeLeft > 0 and timeLeft < 3600 then
|
||||
if npFormat then
|
||||
local text, r, g, bc, a = npFormat(timeLeft)
|
||||
b.cdText:SetText(text)
|
||||
if r then b.cdText:SetTextColor(r, g, bc, a or 1) end
|
||||
else
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
end
|
||||
else
|
||||
b.cdText:SetText("")
|
||||
end
|
||||
@@ -895,29 +937,65 @@ function SFrames.Target:UpdateAuras()
|
||||
end
|
||||
|
||||
-- Debuffs
|
||||
local hasNP = NanamiPlates_SpellDB and NanamiPlates_SpellDB.UnitDebuff
|
||||
local npFormat = NanamiPlates_Auras and NanamiPlates_Auras.FormatTime
|
||||
|
||||
for i = 1, 16 do
|
||||
local texture = UnitDebuff("target", i)
|
||||
local b = self.frame.debuffs[i]
|
||||
b:SetID(i) -- Ensure ID is set for tooltips
|
||||
b:SetID(i)
|
||||
if texture then
|
||||
b.icon:SetTexture(texture)
|
||||
|
||||
-- Scrape tooltip for duration
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:ClearLines()
|
||||
SFrames.Tooltip:SetUnitDebuff("target", i)
|
||||
local timeLeft = SFrames:GetAuraTimeLeft("target", i, false)
|
||||
|
||||
local timeLeft = 0
|
||||
local effectName = nil
|
||||
|
||||
if hasNP then
|
||||
local effect, rank, _, stacks, dtype, duration, npTimeLeft, isOwn = NanamiPlates_SpellDB:UnitDebuff("target", i)
|
||||
effectName = effect
|
||||
if npTimeLeft and npTimeLeft > 0 then
|
||||
timeLeft = npTimeLeft
|
||||
elseif effect and effect ~= "" and duration and duration > 0
|
||||
and NanamiPlates_Auras and NanamiPlates_Auras.timers then
|
||||
local unitKey = (UnitGUID and UnitGUID("target")) or UnitName("target") or ""
|
||||
local cached = NanamiPlates_Auras.timers[unitKey .. "_" .. effect]
|
||||
if not cached and UnitName("target") then
|
||||
cached = NanamiPlates_Auras.timers[UnitName("target") .. "_" .. effect]
|
||||
end
|
||||
if cached and cached.startTime and cached.duration then
|
||||
local remaining = cached.duration - (GetTime() - cached.startTime)
|
||||
if remaining > 0 then timeLeft = remaining end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if timeLeft <= 0 then
|
||||
SFrames.Tooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
SFrames.Tooltip:ClearLines()
|
||||
SFrames.Tooltip:SetUnitDebuff("target", i)
|
||||
timeLeft = SFrames:GetAuraTimeLeft("target", i, false)
|
||||
end
|
||||
|
||||
if timeLeft and timeLeft > 0 then
|
||||
b.expirationTime = GetTime() + timeLeft
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
b.effectName = effectName
|
||||
if npFormat then
|
||||
local text, r, g, bc, a = npFormat(timeLeft)
|
||||
b.cdText:SetText(text)
|
||||
if r then b.cdText:SetTextColor(r, g, bc, a or 1) end
|
||||
else
|
||||
b.cdText:SetText(SFrames:FormatTime(timeLeft))
|
||||
end
|
||||
else
|
||||
b.expirationTime = nil
|
||||
b.effectName = nil
|
||||
b.cdText:SetText("")
|
||||
end
|
||||
|
||||
|
||||
b:Show()
|
||||
else
|
||||
b.expirationTime = nil
|
||||
b.effectName = nil
|
||||
b.cdText:SetText("")
|
||||
b:Hide()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user