Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 64 additions & 18 deletions ElvUI_ProjectZidras/Modules/Nameplates/Elements/CastBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ local function resetAttributes(self)
self.channeling = nil
self.notInterruptible = nil
self.spellName = nil
self.delay = 0
end

local function castbarHide(frame)
frame.CastBar:Hide()
end

local function spellNameWithUnit(self, _, spellName, sourceUnit) -- self, frame, spellName, sourceUnit
Expand Down Expand Up @@ -91,33 +96,63 @@ function ZNP:Update_CastBarOnValueChanged(value)
local min, max = self:GetMinMaxValues()
local cur = castBar:GetValue()

local delta = 0
if castBar.casting and cur > value then -- keep this before setting castBar.casting
delta = cur - value -- does not produce the same results as UnitCastingInfo math, but I can't justify this being wrong
end

--castBar.spellName = self.Name:GetText()
castBar.casting = value > cur
castBar.channeling = value < cur
castBar.notInterruptible = frame.oldCastBar.Shield:IsShown()
castBar.delay = (castBar.delay or 0) + delta

castBar:SetMinMaxValues(min, max)
castBar:SetValue(value)

if castBar.channeling then
if castBar.channelTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f", abs(value - max))
elseif castBar.channelTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", abs(value - max), max)
elseif castBar.channelTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f", value)
elseif castBar.channelTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", value, max)
if castBar.delay ~= 0 then
if castBar.channeling then
if castBar.channelTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f |cffaf5050%.2f|r", abs(value - max), castBar.delay)
elseif castBar.channelTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f |cffaf5050%.2f|r", abs(value - max), max, castBar.delay)
elseif castBar.channelTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f |cffaf5050%.2f|r", value, castBar.delay)
elseif castBar.channelTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f |cffaf5050%.2f|r", value, max, max, castBar.delay)
end
else
if castBar.castTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f |cffaf5050%s %.2f|r", value, "+", castBar.delay)
elseif castBar.castTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f |cffaf5050%s %.2f|r", value, max, "+", castBar.delay)
elseif castBar.castTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f |cffaf5050%s %.2f|r", abs(value - max), "+", castBar.delay)
elseif castBar.castTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f |cffaf5050%s %.2f|r", abs(value - max), max, "+", castBar.delay)
end
end
else
if castBar.castTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f", value)
elseif castBar.castTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", value, max)
elseif castBar.castTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f", abs(value - max))
elseif castBar.castTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", abs(value - max), max)
if castBar.channeling then
if castBar.channelTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f", abs(value - max))
elseif castBar.channelTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", abs(value - max), max)
elseif castBar.channelTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f", value)
elseif castBar.channelTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", value, max)
end
else
if castBar.castTimeFormat == "CURRENT" then
castBar.Time:SetFormattedText("%.1f", value)
elseif castBar.castTimeFormat == "CURRENTMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", value, max)
elseif castBar.castTimeFormat == "REMAINING" then
castBar.Time:SetFormattedText("%.1f", abs(value - max))
elseif castBar.castTimeFormat == "REMAININGMAX" then
castBar.Time:SetFormattedText("%.1f / %.2f", abs(value - max), max)
end
end
end

Expand Down Expand Up @@ -187,8 +222,19 @@ function ZNP:Update_CastBar(frame, event, unit)
ZNP:Update_CastBarName(frame, unit) -- since on HD this is not hooked and therefore it may not have an event to run ZNP:Update_Tags
end
elseif event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" then
if frame.CastBar:IsShown() then
if frame.CastBar and frame.unit == unit then
if not frame.CastBar:IsShown() then
frame.CastBar:Show()
end

frame.CastBar:SetStatusBarColor(NP.db.colors.castInterruptedColor.r, NP.db.colors.castInterruptedColor.g, NP.db.colors.castInterruptedColor.b)
frame.CastBar.Name:SetText(event == "UNIT_SPELLCAST_FAILED" and FAILED or INTERRUPTED)

frame.CastBar.holdTime = NP.db.units[frame.UnitType].castbar.timeToHold --How long the castbar should stay visible after being interrupted, in seconds
frame.CastBar.interrupted = true

resetAttributes(frame.CastBar)
E:Delay(frame.CastBar.holdTime, castbarHide, frame)
end
end
end
Expand Down