diff --git a/DandersFrames_Auras.lua b/DandersFrames_Auras.lua index abe3f3cf4..58a395569 100644 --- a/DandersFrames_Auras.lua +++ b/DandersFrames_Auras.lua @@ -36,7 +36,7 @@ function DF:ApplyAuraLayout(frame) -- Parse "PRIMARY_SECONDARY" growth strings (e.g., "LEFT_DOWN") -- Added stackFont argument and countdown arguments - local function ApplyLayout(auraFrames, scale, alpha, anchor, growthString, limit, offX, offY, maxCount, clickThrough, stackScale, stackAnchor, stackX, stackY, stackOutline, stackFont, showCountdown, countdownScale, countdownFont, countdownOutline, countdownX, countdownY, countdownDecimalMode, hideSwipe) + local function ApplyLayout(auraFrames, scale, alpha, anchor, growthString, limit, offX, offY, maxCount, clickThrough, stackScale, stackAnchor, stackX, stackY, stackOutline, stackFont, showCountdown, countdownScale, countdownFont, countdownOutline, countdownX, countdownY, countdownDecimalMode, hideSwipe) if not auraFrames then return end -- Split growth direction string @@ -136,34 +136,50 @@ function DF:ApplyAuraLayout(frame) self.elapsed = (self.elapsed or 0) + elapsed if self.elapsed < 0.1 then return end self.elapsed = 0 - + local cd = self.cooldown local text = self:GetParent().dfCountdownText - + -- Use our stored values instead of API calls - if cd and cd:IsShown() and cd.dfStart and cd.dfDuration and cd.dfDuration > 0 then - local remaining = (cd.dfStart + cd.dfDuration) - GetTime() - - if remaining > 0.5 then - if remaining >= 3600 then - text:SetText(math.floor(remaining / 3600) .. "h") - elseif remaining >= 60 then - text:SetText(math.floor(remaining / 60) .. "m") - elseif remaining >= 10 then - text:SetText(math.floor(remaining)) - elseif remaining >= 3 then - text:SetFormattedText("%.0f", remaining) - else - if countdownDecimalMode == "WHOLE" then - text:SetFormattedText("%.0f", remaining) - else - text:SetFormattedText("%.1f", remaining) - end - end - text:Show() - else - text:Hide() - end + if cd and cd:IsShown() then + -- Capture any cooldown values we might have missed before the SetCooldown hook ran + if (not cd.dfStart or not cd.dfDuration) and cd.GetCooldownTimes then + local start, duration = cd:GetCooldownTimes() + if start and duration then + -- GetCooldownTimes returns milliseconds + start = start / 1000 + duration = duration / 1000 + + if duration > 0 then + cd.dfStart = start + cd.dfDuration = duration + end + end + end + + if cd.dfStart and cd.dfDuration and cd.dfDuration > 0 then + local remaining = (cd.dfStart + cd.dfDuration) - GetTime() + + if remaining > 0.5 then + if remaining >= 3600 then + text:SetText(math.floor(remaining / 3600) .. "h") + elseif remaining >= 60 then + text:SetText(math.floor(remaining / 60) .. "m") + elseif remaining >= 10 then + text:SetText(math.floor(remaining)) + elseif remaining >= 3 then + text:SetFormattedText("%.0f", remaining) + else + if countdownDecimalMode == "WHOLE" then + text:SetFormattedText("%.0f", remaining) + else + text:SetFormattedText("%.1f", remaining) + end + end + text:Show() + else + text:Hide() + end else text:Hide() end @@ -261,13 +277,13 @@ function DF:ApplyAuraLayout(frame) db.raidBuffStackFont, db.raidBuffShowCountdown, db.raidBuffCountdownScale, - db.raidBuffCountdownFont, - db.raidBuffCountdownOutline, - db.raidBuffCountdownX, - db.raidBuffCountdownY, - db.raidBuffCountdownDecimalMode, - db.raidBuffHideSwipe - ) + db.raidBuffCountdownFont, + db.raidBuffCountdownOutline, + db.raidBuffCountdownX, + db.raidBuffCountdownY, + db.raidBuffCountdownDecimalMode, + db.raidBuffHideSwipe + ) -- Apply to Debuffs ApplyLayout( @@ -289,14 +305,14 @@ function DF:ApplyAuraLayout(frame) db.raidDebuffStackFont, db.raidDebuffShowCountdown, db.raidDebuffCountdownScale, - db.raidDebuffCountdownFont, - db.raidDebuffCountdownOutline, - db.raidDebuffCountdownX, - db.raidDebuffCountdownY, - db.raidDebuffCountdownDecimalMode, - db.raidDebuffHideSwipe - ) -end + db.raidDebuffCountdownFont, + db.raidDebuffCountdownOutline, + db.raidDebuffCountdownX, + db.raidDebuffCountdownY, + db.raidDebuffCountdownDecimalMode, + db.raidDebuffHideSwipe + ) +end -- ========================================================================= -- DEMO DISPEL ICON (Custom Preview Icon)