From e870a1697b467c131e57713b227bb4f876b1981d Mon Sep 17 00:00:00 2001 From: DanderBot Date: Mon, 1 Dec 2025 12:11:28 +0000 Subject: [PATCH] Fix countdown OnUpdate formatting syntax --- DandersFrames_Auras.lua | 124 +++++++++++++++++++++++--------------- DandersFrames_Config.lua | 36 ++++++----- DandersFrames_Options.lua | 76 ++++++++++++----------- 3 files changed, 137 insertions(+), 99 deletions(-) diff --git a/DandersFrames_Auras.lua b/DandersFrames_Auras.lua index a62ef791a..fa3ce2fb8 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, 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 @@ -131,41 +131,65 @@ function DF:ApplyAuraLayout(frame) end -- Set up OnUpdate to read cooldown times from our stored values - if not aura.dfCountdownOverlay.hasOnUpdate then - aura.dfCountdownOverlay:SetScript("OnUpdate", function(self, elapsed) - 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 - text:SetFormattedText("%.1f", remaining) - end - text:Show() - else - text:Hide() - end - else - text:Hide() - end - end) - aura.dfCountdownOverlay.hasOnUpdate = true - end + if not aura.dfCountdownOverlay.hasOnUpdate then + aura.dfCountdownOverlay:SetScript("OnUpdate", function(self, elapsed) + 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() 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 + else + text:Hide() + end + end) + aura.dfCountdownOverlay.hasOnUpdate = true + end aura.dfCountdownOverlay:Show() else @@ -257,12 +281,13 @@ function DF:ApplyAuraLayout(frame) db.raidBuffStackFont, db.raidBuffShowCountdown, db.raidBuffCountdownScale, - db.raidBuffCountdownFont, - db.raidBuffCountdownOutline, - db.raidBuffCountdownX, - db.raidBuffCountdownY, - db.raidBuffHideSwipe - ) + db.raidBuffCountdownFont, + db.raidBuffCountdownOutline, + db.raidBuffCountdownX, + db.raidBuffCountdownY, + db.raidBuffCountdownDecimalMode, + db.raidBuffHideSwipe + ) -- Apply to Debuffs ApplyLayout( @@ -284,13 +309,14 @@ function DF:ApplyAuraLayout(frame) db.raidDebuffStackFont, db.raidDebuffShowCountdown, db.raidDebuffCountdownScale, - db.raidDebuffCountdownFont, - db.raidDebuffCountdownOutline, - db.raidDebuffCountdownX, - db.raidDebuffCountdownY, - db.raidDebuffHideSwipe - ) -end + db.raidDebuffCountdownFont, + db.raidDebuffCountdownOutline, + db.raidDebuffCountdownX, + db.raidDebuffCountdownY, + db.raidDebuffCountdownDecimalMode, + db.raidDebuffHideSwipe + ) +end -- ========================================================================= -- DEMO DISPEL ICON (Custom Preview Icon) diff --git a/DandersFrames_Config.lua b/DandersFrames_Config.lua index 75e5bb4c3..b22c4d7ec 100644 --- a/DandersFrames_Config.lua +++ b/DandersFrames_Config.lua @@ -211,10 +211,11 @@ DF.PartyDefaults = { raidBuffShowCountdown = false, raidBuffCountdownScale = 1.0, raidBuffCountdownFont = "Fonts\\FRIZQT__.TTF", - raidBuffCountdownOutline = "OUTLINE", - raidBuffCountdownX = 0, - raidBuffCountdownY = 0, - raidBuffHideSwipe = false, + raidBuffCountdownOutline = "OUTLINE", + raidBuffCountdownX = 0, + raidBuffCountdownY = 0, + raidBuffCountdownDecimalMode = "TENTHS", + raidBuffHideSwipe = false, -- Debuffs raidDebuffScale = 1, @@ -236,10 +237,11 @@ DF.PartyDefaults = { raidDebuffShowCountdown = false, raidDebuffCountdownScale = 1.0, raidDebuffCountdownFont = "Fonts\\FRIZQT__.TTF", - raidDebuffCountdownOutline = "OUTLINE", - raidDebuffCountdownX = 0, - raidDebuffCountdownY = 0, - raidDebuffHideSwipe = false, + raidDebuffCountdownOutline = "OUTLINE", + raidDebuffCountdownX = 0, + raidDebuffCountdownY = 0, + raidDebuffCountdownDecimalMode = "TENTHS", + raidDebuffHideSwipe = false, -- Dispel Toggles showDispelIcon = true, @@ -443,10 +445,11 @@ DF.RaidDefaults = { raidBuffShowCountdown = false, raidBuffCountdownScale = 1.0, raidBuffCountdownFont = "Fonts\\FRIZQT__.TTF", - raidBuffCountdownOutline = "OUTLINE", - raidBuffCountdownX = 0, - raidBuffCountdownY = 0, - raidBuffHideSwipe = false, + raidBuffCountdownOutline = "OUTLINE", + raidBuffCountdownX = 0, + raidBuffCountdownY = 0, + raidBuffCountdownDecimalMode = "TENTHS", + raidBuffHideSwipe = false, -- Debuffs raidDebuffScale = 1, @@ -468,10 +471,11 @@ DF.RaidDefaults = { raidDebuffShowCountdown = false, raidDebuffCountdownScale = 1.0, raidDebuffCountdownFont = "Fonts\\FRIZQT__.TTF", - raidDebuffCountdownOutline = "OUTLINE", - raidDebuffCountdownX = 0, - raidDebuffCountdownY = 0, - raidDebuffHideSwipe = false, + raidDebuffCountdownOutline = "OUTLINE", + raidDebuffCountdownX = 0, + raidDebuffCountdownY = 0, + raidDebuffCountdownDecimalMode = "TENTHS", + raidDebuffHideSwipe = false, -- Dispel Toggles showDispelIcon = true, diff --git a/DandersFrames_Options.lua b/DandersFrames_Options.lua index 15d872710..f21847456 100644 --- a/DandersFrames_Options.lua +++ b/DandersFrames_Options.lua @@ -337,24 +337,30 @@ function DF:SetupGUIPages(GUI, CreateTab, BuildPage) bStackOut.hideOn = function(d) return not d.showAdvancedBuffOptions end -- Buff Countdown Text Options - local bCdHeader = Add(GUI:CreateHeader(self, "Buff Countdown Text"), 25, 1) - bCdHeader.hideOn = function(d) return not d.showAdvancedBuffOptions end - local bCountdown = Add(GUI:CreateCheckbox(self, "Show Countdown", db, "raidBuffShowCountdown"), 30, 1) - bCountdown.hideOn = function(d) return not d.showAdvancedBuffOptions end - local bCdScale = Add(GUI:CreateSlider(self, "Countdown Scale", 0.5, 2.0, 0.1, db, "raidBuffCountdownScale"), 60, 1) - bCdScale.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end - local bCdFont = Add(GUI:CreateDropdown(self, "Countdown Font", DF:GetFontList(), db, "raidBuffCountdownFont"), 60, 1) - bCdFont.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end - local bCdOutline = Add(GUI:CreateDropdown(self, "Countdown Outline", { - ["NONE"] = "None", ["OUTLINE"] = "Outline", ["THICKOUTLINE"] = "Thick" - }, db, "raidBuffCountdownOutline"), 60, 1) - bCdOutline.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end - local bCdOffX = Add(GUI:CreateSlider(self, "Countdown X", -20, 20, 1, db, "raidBuffCountdownX"), 60, 1) - bCdOffX.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end - local bCdOffY = Add(GUI:CreateSlider(self, "Countdown Y", -20, 20, 1, db, "raidBuffCountdownY"), 60, 1) - bCdOffY.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end - local bHideSwipe = Add(GUI:CreateCheckbox(self, "Hide Cooldown Swipe", db, "raidBuffHideSwipe"), 30, 1) - bHideSwipe.hideOn = function(d) return not d.showAdvancedBuffOptions end + local bCdHeader = Add(GUI:CreateHeader(self, "Buff Countdown Text"), 25, 1) + bCdHeader.hideOn = function(d) return not d.showAdvancedBuffOptions end + local bCountdown = Add(GUI:CreateCheckbox(self, "Show Countdown", db, "raidBuffShowCountdown"), 30, 1) + bCountdown.hideOn = function(d) return not d.showAdvancedBuffOptions end + local countdownFormats = { + ["TENTHS"] = "Tenths (<3s)", + ["WHOLE"] = "Whole Seconds", + } + local bCdScale = Add(GUI:CreateSlider(self, "Countdown Scale", 0.5, 2.0, 0.1, db, "raidBuffCountdownScale"), 60, 1) + bCdScale.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bCdFont = Add(GUI:CreateDropdown(self, "Countdown Font", DF:GetFontList(), db, "raidBuffCountdownFont"), 60, 1) + bCdFont.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bCdOutline = Add(GUI:CreateDropdown(self, "Countdown Outline", { + ["NONE"] = "None", ["OUTLINE"] = "Outline", ["THICKOUTLINE"] = "Thick" + }, db, "raidBuffCountdownOutline"), 60, 1) + bCdOutline.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bCdOffX = Add(GUI:CreateSlider(self, "Countdown X", -20, 20, 1, db, "raidBuffCountdownX"), 60, 1) + bCdOffX.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bCdOffY = Add(GUI:CreateSlider(self, "Countdown Y", -20, 20, 1, db, "raidBuffCountdownY"), 60, 1) + bCdOffY.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bCdFormat = Add(GUI:CreateDropdown(self, "Countdown Decimals", countdownFormats, db, "raidBuffCountdownDecimalMode"), 60, 1) + bCdFormat.hideOn = function(d) return not d.showAdvancedBuffOptions or not d.raidBuffShowCountdown end + local bHideSwipe = Add(GUI:CreateCheckbox(self, "Hide Cooldown Swipe", db, "raidBuffHideSwipe"), 30, 1) + bHideSwipe.hideOn = function(d) return not d.showAdvancedBuffOptions end -- COLUMN 2: Debuffs Add(GUI:CreateHeader(self, "Debuffs"), 30, 2) @@ -398,25 +404,27 @@ function DF:SetupGUIPages(GUI, CreateTab, BuildPage) dStackOut.hideOn = function(d) return not d.showAdvancedDebuffOptions end -- Debuff Countdown Text Options - local dCdHeader = Add(GUI:CreateHeader(self, "Debuff Countdown Text"), 25, 2) - dCdHeader.hideOn = function(d) return not d.showAdvancedDebuffOptions end - local dCountdown = Add(GUI:CreateCheckbox(self, "Show Countdown", db, "raidDebuffShowCountdown"), 30, 2) - dCountdown.hideOn = function(d) return not d.showAdvancedDebuffOptions end - local dCdScale = Add(GUI:CreateSlider(self, "Countdown Scale", 0.5, 2.0, 0.1, db, "raidDebuffCountdownScale"), 60, 2) + local dCdHeader = Add(GUI:CreateHeader(self, "Debuff Countdown Text"), 25, 2) + dCdHeader.hideOn = function(d) return not d.showAdvancedDebuffOptions end + local dCountdown = Add(GUI:CreateCheckbox(self, "Show Countdown", db, "raidDebuffShowCountdown"), 30, 2) + dCountdown.hideOn = function(d) return not d.showAdvancedDebuffOptions end + local dCdScale = Add(GUI:CreateSlider(self, "Countdown Scale", 0.5, 2.0, 0.1, db, "raidDebuffCountdownScale"), 60, 2) dCdScale.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end local dCdFont = Add(GUI:CreateDropdown(self, "Countdown Font", DF:GetFontList(), db, "raidDebuffCountdownFont"), 60, 2) dCdFont.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end - local dCdOutline = Add(GUI:CreateDropdown(self, "Countdown Outline", { - ["NONE"] = "None", ["OUTLINE"] = "Outline", ["THICKOUTLINE"] = "Thick" - }, db, "raidDebuffCountdownOutline"), 60, 2) - dCdOutline.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end - local dCdOffX = Add(GUI:CreateSlider(self, "Countdown X", -20, 20, 1, db, "raidDebuffCountdownX"), 60, 2) - dCdOffX.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end - local dCdOffY = Add(GUI:CreateSlider(self, "Countdown Y", -20, 20, 1, db, "raidDebuffCountdownY"), 60, 2) - dCdOffY.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end - local dHideSwipe = Add(GUI:CreateCheckbox(self, "Hide Cooldown Swipe", db, "raidDebuffHideSwipe"), 30, 2) - dHideSwipe.hideOn = function(d) return not d.showAdvancedDebuffOptions end - end) + local dCdOutline = Add(GUI:CreateDropdown(self, "Countdown Outline", { + ["NONE"] = "None", ["OUTLINE"] = "Outline", ["THICKOUTLINE"] = "Thick" + }, db, "raidDebuffCountdownOutline"), 60, 2) + dCdOutline.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end + local dCdOffX = Add(GUI:CreateSlider(self, "Countdown X", -20, 20, 1, db, "raidDebuffCountdownX"), 60, 2) + dCdOffX.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end + local dCdOffY = Add(GUI:CreateSlider(self, "Countdown Y", -20, 20, 1, db, "raidDebuffCountdownY"), 60, 2) + dCdOffY.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end + local dCdFormat = Add(GUI:CreateDropdown(self, "Countdown Decimals", countdownFormats, db, "raidDebuffCountdownDecimalMode"), 60, 2) + dCdFormat.hideOn = function(d) return not d.showAdvancedDebuffOptions or not d.raidDebuffShowCountdown end + local dHideSwipe = Add(GUI:CreateCheckbox(self, "Hide Cooldown Swipe", db, "raidDebuffHideSwipe"), 30, 2) + dHideSwipe.hideOn = function(d) return not d.showAdvancedDebuffOptions end + end) -- TAB 2.5: DISPELS BuildPage(CreateTab("dispels", "Dispels"), function(self, db, Add, AddSpace)