Centralize cooldown setup and settings

Every pfUI cooldown is now made by CreateCooldown(parent, kind) in the
new api/cooldown.lua, which replaces the cooldown module. A kind names
what the cooldown times: actionbar, bags, blizzard (spellbook and
character), unitframe, indicator, nameplate, buff, tooltip, totem or
lossofcontrol. The pfCooldownType, pfCooldownStyleText,
pfCooldownStyleAnimation and pfCooldownSize fields are gone. The new
file owns everything the cooldowns share:
- the numbers' font and size
- the formatter
- each kind's numbers, sweep and sweep direction
- the GCD threshold for spell kinds
- the CooldownFrame_SetTimer hook for other addons' Cooldown frames
UpdateCooldowns applies changed settings to every cooldown at once.
GetAuraTimer moves here from the unit frames.

All settings live in one C.cooldown table, on one page: Settings ->
Cooldown. It has the shared font, size, threshold, tenths and colors,
then "Show Numbers On", "Show Sweep On" and "Reverse Sweep On" lists
with a checkbox per kind. The per-module options are removed:
- each unit frame's timer text, animation and reverse, and the
  indicators' "Show Time Left"
- the nameplate debuff timer options
- the Blizzard and foreign font sizes and toggles
- Action Bars' cooldown text size
- the reverse options of bars, bags, buffs and totems
The old appearance.cd settings are not migrated.

The player buff frame and the tooltip aura icons now show the native
countdown too, which replaces their own text and OnUpdate ticking. The
buff frame keeps its inside or below-the-icon placement. Weapon
enchants report only their time left, so they start through
SetCooldownTimeLeft: numbers, no sweep. A slim poll remains for their
charges and renewals, since no event reports those. Buff indicators
now take the aura's real duration, which gives them a correct sweep.
The spellbook and character slots now hide GCD numbers like the other
spell cooldowns.
This commit is contained in:
Brues
2026-10-31 19:17:14 -05:00
parent 149c8cb3c3
commit 907d282a68
26 changed files with 535 additions and 546 deletions
-48
View File
@@ -1425,54 +1425,6 @@ function pfUI.api.DisableAutohide(frame)
frame:SetAlpha(1)
end
-- [ GetCountdownFormatter ] --
-- The C_StringUtil formatter behind pfUI's times: the number in its unit's
-- cooldown color, rounded up, with a unit (m/h/d) once the unit below
-- passes 99. Cooldown frames share it instead of copying it, so new
-- breakpoints reach every countdown on its next update.
-- return the shared NumericRuleFormatter
local countdown_formatter
local function ColorCode(color)
local r, g, b = pfUI.api.GetStringColor(color)
return pfUI.api.rgbhex(r, g, b)
end
local function UpdateCountdownFormatter()
local cd = C.appearance.cd
local up = Enum.NumericRuleFormatRounding.Up
local tenths = cd.milliseconds == "1"
countdown_formatter:SetBreakpoints({
{ threshold = 0, step = tenths and .1 or 1, rounding = up, format = ColorCode(cd.lowcolor) .. (tenths and "%.1f" or "%d") .. "|r" },
{ threshold = 5, step = 1, rounding = up, format = ColorCode(cd.normalcolor) .. "%d|r" },
{ threshold = 99, format = ColorCode(cd.minutecolor) .. "%d|rm", components = { { div = 60, step = 1, rounding = up } } },
{ threshold = 5940, format = ColorCode(cd.hourcolor) .. "%d|rh", components = { { div = 3600, step = 1, rounding = up } } },
{ threshold = 356400, format = ColorCode(cd.daycolor) .. "%d|rd", components = { { div = 86400, step = 1, rounding = up } } },
})
end
function pfUI.api.GetCountdownFormatter()
if not countdown_formatter then
countdown_formatter = C_StringUtil.CreateNumericRuleFormatter()
UpdateCountdownFormatter()
end
return countdown_formatter
end
pfUI.events:RegisterCallback("config:changed", function(_, category)
if countdown_formatter and category == C.appearance.cd then
UpdateCountdownFormatter()
end
end)
-- [ GetColoredTime ] --
-- 'remaining' the time in seconds that should be converted
-- return a colored string including a time unit (m/h/d)
function pfUI.api.GetColoredTimeString(remaining)
return pfUI.api.GetCountdownFormatter():FormatNumber(remaining)
end
-- [ GetColorGradient ] --
-- 'perc' percentage (0-1)
-- return r,g,b and hexcolor
+45 -35
View File
@@ -71,8 +71,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("buffs", nil, "debuffrowsize", "16")
pfUI:UpdateConfig("buffs", nil, "textinside", "0")
pfUI:UpdateConfig("buffs", nil, "fontsize", "-1")
pfUI:UpdateConfig("buffs", nil, "cooldown_anim", "1")
pfUI:UpdateConfig("buffs", nil, "cooldown_reverse", "1")
pfUI:UpdateConfig("buffbar", "pbuff", "enable", "0")
pfUI:UpdateConfig("buffbar", "pbuff", "use_unitfonts", "0")
@@ -140,21 +138,50 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("appearance", "border", "panels", "-1")
pfUI:UpdateConfig("appearance", "border", "chat", "-1")
pfUI:UpdateConfig("appearance", "border", "bags", "-1")
pfUI:UpdateConfig("appearance", "cd", "lowcolor", "1,.2,.2,1")
pfUI:UpdateConfig("appearance", "cd", "normalcolor", "1,1,1,1")
pfUI:UpdateConfig("appearance", "cd", "minutecolor", ".2,1,1,1")
pfUI:UpdateConfig("appearance", "cd", "hourcolor", ".2,.5,1,1")
pfUI:UpdateConfig("appearance", "cd", "daycolor", ".2,.2,1,1")
pfUI:UpdateConfig("appearance", "cd", "threshold", "2")
pfUI:UpdateConfig("appearance", "cd", "font_size", "12")
pfUI:UpdateConfig("appearance", "cd", "font_size_blizz", "12")
pfUI:UpdateConfig("appearance", "cd", "font_size_foreign","12")
pfUI:UpdateConfig("appearance", "cd", "blizzard", "1")
pfUI:UpdateConfig("appearance", "cd", "foreign", "0")
pfUI:UpdateConfig("appearance", "cd", "milliseconds", "1")
pfUI:UpdateConfig("appearance", "cd", "hideanim", "0")
pfUI:UpdateConfig("appearance", "cd", "font", "Interface\\AddOns\\pfUI\\fonts\\BigNoodleTitling.ttf")
pfUI:UpdateConfig("appearance", "cd", "dynamicsize", "1")
pfUI:UpdateConfig("cooldown", nil, "font", "Interface\\AddOns\\pfUI\\fonts\\BigNoodleTitling.ttf")
pfUI:UpdateConfig("cooldown", nil, "font_size", "12")
pfUI:UpdateConfig("cooldown", nil, "dynamicsize", "1")
pfUI:UpdateConfig("cooldown", nil, "threshold", "2")
pfUI:UpdateConfig("cooldown", nil, "milliseconds", "1")
pfUI:UpdateConfig("cooldown", nil, "lowcolor", "1,.2,.2,1")
pfUI:UpdateConfig("cooldown", nil, "normalcolor", "1,1,1,1")
pfUI:UpdateConfig("cooldown", nil, "minutecolor", ".2,1,1,1")
pfUI:UpdateConfig("cooldown", nil, "hourcolor", ".2,.5,1,1")
pfUI:UpdateConfig("cooldown", nil, "daycolor", ".2,.2,1,1")
pfUI:UpdateConfig("cooldown", "actionbar", "text", "1")
pfUI:UpdateConfig("cooldown", "actionbar", "animation", "1")
pfUI:UpdateConfig("cooldown", "actionbar", "reverse", "0")
pfUI:UpdateConfig("cooldown", "bags", "text", "1")
pfUI:UpdateConfig("cooldown", "bags", "animation", "1")
pfUI:UpdateConfig("cooldown", "bags", "reverse", "0")
pfUI:UpdateConfig("cooldown", "blizzard", "text", "1")
pfUI:UpdateConfig("cooldown", "blizzard", "animation", "1")
pfUI:UpdateConfig("cooldown", "blizzard", "reverse", "0")
pfUI:UpdateConfig("cooldown", "unitframe", "text", "1")
pfUI:UpdateConfig("cooldown", "unitframe", "animation", "0")
pfUI:UpdateConfig("cooldown", "unitframe", "reverse", "1")
pfUI:UpdateConfig("cooldown", "indicator", "text", "1")
pfUI:UpdateConfig("cooldown", "indicator", "animation", "0")
pfUI:UpdateConfig("cooldown", "indicator", "reverse", "0")
pfUI:UpdateConfig("cooldown", "nameplate", "text", "1")
pfUI:UpdateConfig("cooldown", "nameplate", "animation", "0")
pfUI:UpdateConfig("cooldown", "nameplate", "reverse", "1")
pfUI:UpdateConfig("cooldown", "buff", "text", "1")
pfUI:UpdateConfig("cooldown", "buff", "animation", "1")
pfUI:UpdateConfig("cooldown", "buff", "reverse", "1")
pfUI:UpdateConfig("cooldown", "tooltip", "text", "1")
pfUI:UpdateConfig("cooldown", "tooltip", "animation", "0")
pfUI:UpdateConfig("cooldown", "tooltip", "reverse", "0")
pfUI:UpdateConfig("cooldown", "totem", "text", "1")
pfUI:UpdateConfig("cooldown", "totem", "animation", "1")
pfUI:UpdateConfig("cooldown", "totem", "reverse", "1")
pfUI:UpdateConfig("cooldown", "lossofcontrol", "text", "1")
pfUI:UpdateConfig("cooldown", "lossofcontrol", "animation", "1")
pfUI:UpdateConfig("cooldown", "lossofcontrol", "reverse", "0")
pfUI:UpdateConfig("cooldown", "foreign", "text", "0")
pfUI:UpdateConfig("cooldown", "foreign", "animation", "1")
pfUI:UpdateConfig("appearance", "castbar", "castbarcolor", ".7,.7,.9,.8")
pfUI:UpdateConfig("appearance", "castbar", "channelcolor", ".9,.9,.7,.8")
pfUI:UpdateConfig("appearance", "castbar", "failcolor", "1,.2,.2,.8")
@@ -175,7 +202,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("appearance", "bags", "abovechat", "0")
pfUI:UpdateConfig("appearance", "bags", "hidechat", "0")
pfUI:UpdateConfig("appearance", "bags", "icon_size", "-1")
pfUI:UpdateConfig("appearance", "bags", "cooldown_reverse", "0")
pfUI:UpdateConfig("appearance", "bags", "bagrowlength", "10")
pfUI:UpdateConfig("appearance", "bags", "bankrowlength", "10")
pfUI:UpdateConfig("appearance", "bags", "autoSortOnOpen", "0")
@@ -519,9 +545,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", unit, "portraitwidth", "-1")
pfUI:UpdateConfig("unitframes", unit, "panchor", "TOP")
pfUI:UpdateConfig("unitframes", unit, "pspace", "-3")
pfUI:UpdateConfig("unitframes", unit, "cooldown_text", "1")
pfUI:UpdateConfig("unitframes", unit, "cooldown_anim", "0")
pfUI:UpdateConfig("unitframes", unit, "cooldown_reverse", "1")
pfUI:UpdateConfig("unitframes", unit, "buffs", "TOPLEFT")
pfUI:UpdateConfig("unitframes", unit, "buffsize", "20")
pfUI:UpdateConfig("unitframes", unit, "bufflimit", "32")
@@ -552,7 +575,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", unit, "show_procs", "0")
pfUI:UpdateConfig("unitframes", unit, "show_totems", "0")
pfUI:UpdateConfig("unitframes", unit, "all_procs", "0")
pfUI:UpdateConfig("unitframes", unit, "indicator_time", "1")
pfUI:UpdateConfig("unitframes", unit, "indicator_stacks", "1")
pfUI:UpdateConfig("unitframes", unit, "indicator_size", "10")
pfUI:UpdateConfig("unitframes", unit, "indicator_spacing","1")
@@ -687,8 +709,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("bars", nil, "count_color", ".2,1,.8,1")
pfUI:UpdateConfig("bars", nil, "bind_size", "8")
pfUI:UpdateConfig("bars", nil, "bind_color", "1,1,0,1")
pfUI:UpdateConfig("bars", nil, "cd_size", "12")
pfUI:UpdateConfig("bars", nil, "cooldown_reverse", "0")
pfUI:UpdateConfig("bars", "gryphons", "texture", "None")
pfUI:UpdateConfig("bars", "gryphons", "color", ".6,.6,.6,1")
@@ -702,7 +722,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("totems", nil, "iconsize", "26")
pfUI:UpdateConfig("totems", nil, "spacing", "3")
pfUI:UpdateConfig("totems", nil, "showbg", "0")
pfUI:UpdateConfig("totems", nil, "cooldown_reverse", "1")
pfUI:UpdateConfig("panel", nil, "use_unitfonts", "0")
pfUI:UpdateConfig("panel", nil, "hide_leftchat", "0")
@@ -948,10 +967,6 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("nameplates", "debuffs", "blacklist", "")
pfUI:UpdateConfig("nameplates", "debuffs", "showstacks", "0")
pfUI:UpdateConfig("nameplates", "debuffs", "position", "BOTTOM")
pfUI:UpdateConfig("nameplates", nil, "debufftimers", "1")
pfUI:UpdateConfig("nameplates", nil, "debufftext", "1")
pfUI:UpdateConfig("nameplates", nil, "debuffanim", "0")
pfUI:UpdateConfig("nameplates", nil, "debreverse", "1")
pfUI:UpdateConfig("abuttons", nil, "enable", "1")
pfUI:UpdateConfig("abuttons", nil, "position", "bottom")
@@ -1351,7 +1366,7 @@ function pfUI:MigrateConfig()
-- migrate buff indicators into seperate options (> 4.6.2)
if checkversion(4, 6, 2) and pfUI_config.unitframes.show_hots then
local unitframes = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback", "tttarget" }
local options = { "show_hots", "all_hots", "show_procs", "show_totems", "all_procs", "indicator_time", "indicator_stacks", "indicator_size" }
local options = { "show_hots", "all_hots", "show_procs", "show_totems", "all_procs", "indicator_stacks", "indicator_size" }
for _, unitframe in pairs(unitframes) do
for _, option in pairs(options) do
@@ -1398,11 +1413,6 @@ function pfUI:MigrateConfig()
end
end
-- migrate cooldown font from unit_font to separate setting
if checkversion(5, 4, 18) then
pfUI_config.appearance.cd.font = pfUI_config.global.font_unit
end
-- migrate combopoint size to separate settings
if checkversion(5, 4, 18) then
if pfUI_config.unitframes.combosize then
+194
View File
@@ -0,0 +1,194 @@
-- load pfUI environment
setfenv(1, pfUI:GetEnvironment())
-- Every pfUI cooldown is a Cooldown frame from CreateCooldown, made for one
-- kind of timer. Settings -> Cooldown (C.cooldown) sets for each kind its
-- countdown numbers, its sweep and the sweep's direction, and shares one font
-- and one formatter between them all. The numbers are the frame's own
-- countdown (ClassicAPI): the engine ticks them, gated by the
-- countdownForCooldowns cvar. Other addons' Cooldown frames take the
-- "foreign" settings as their timers start.
-- kinds that time spells or items: no numbers for the global cooldown
local spell = { actionbar = true, bags = true, blizzard = true, foreign = true }
-- every cooldown CreateCooldown made, for UpdateCooldowns
local cooldowns = {}
local function ColorCode(color)
local r, g, b = pfUI.api.GetStringColor(color)
return pfUI.api.rgbhex(r, g, b)
end
-- The formatter behind every pfUI time: the number in its unit's color,
-- rounded up, with a unit (m/h/d) once the unit below passes 99. Cooldown
-- frames share it instead of copying it, so new breakpoints reach every
-- countdown on its next update.
local formatter
local function UpdateFormatter()
local up = Enum.NumericRuleFormatRounding.Up
local tenths = C.cooldown.milliseconds == "1"
formatter:SetBreakpoints({
{ threshold = 0, step = tenths and .1 or 1, rounding = up, format = ColorCode(C.cooldown.lowcolor) .. (tenths and "%.1f" or "%d") .. "|r" },
{ threshold = 5, step = 1, rounding = up, format = ColorCode(C.cooldown.normalcolor) .. "%d|r" },
{ threshold = 99, format = ColorCode(C.cooldown.minutecolor) .. "%d|rm", components = { { div = 60, step = 1, rounding = up } } },
{ threshold = 5940, format = ColorCode(C.cooldown.hourcolor) .. "%d|rh", components = { { div = 3600, step = 1, rounding = up } } },
{ threshold = 356400, format = ColorCode(C.cooldown.daycolor) .. "%d|rd", components = { { div = 86400, step = 1, rounding = up } } },
})
end
local function GetFormatter()
if not formatter then
formatter = C_StringUtil.CreateNumericRuleFormatter()
UpdateFormatter()
end
return formatter
end
-- [ GetCooldownFontSize ] --
-- 'height' [number] the height of the frame the numbers sit on
-- return [number] the font size of cooldown numbers on that frame
function pfUI.api.GetCooldownFontSize(height)
local size = tonumber(C.cooldown.font_size)
if C.cooldown.dynamicsize == "1" and height > 0 then
size = math.max(height * .64, size)
end
return size
end
-- sizes the numbers to the cooldown's parent; the size follows its height,
-- so a timer start calls this again whenever that height changed
local function UpdateFont(cooldown)
local height = (cooldown:GetParent() or cooldown):GetHeight()
cooldown.pfCountdownHeight = height
cooldown:GetCountdownFontString():SetFont(pfUI.media[C.cooldown.font], pfUI.api.GetCooldownFontSize(height), "OUTLINE")
end
-- applies the settings of its kind to one of pfUI's cooldowns
local function SetupCooldown(cooldown)
local kind = cooldown.pfCooldownKind
local config = C.cooldown[kind]
local sweep = config.animation == "1" and not cooldown.pfTimeLeftOnly
cooldown:SetHideCountdownNumbers(config.text ~= "1")
cooldown:SetDrawSwipe(sweep)
cooldown:SetDrawBling(sweep)
cooldown:SetReverse(config.reverse == "1")
cooldown:SetMinimumCountdownDuration(spell[kind] and tonumber(C.cooldown.threshold) * 1000 or 0)
cooldown:SetCountdownFormatter(GetFormatter())
UpdateFont(cooldown)
end
-- applies the "foreign" settings to another addon's cooldown. They only take
-- the numbers or the sweep away, which the addon may have set up itself, so
-- turning one back on needs a reload.
local function SetupForeign(cooldown)
local config = C.cooldown.foreign
if config.animation ~= "1" then
cooldown:SetDrawSwipe(false)
cooldown:SetDrawBling(false)
end
-- omnicc's flag for cooldowns that want no numbers
if config.text ~= "1" or cooldown.noCooldownCount then
cooldown:SetHideCountdownNumbers(true)
return
end
cooldown:SetMinimumCountdownDuration(tonumber(C.cooldown.threshold) * 1000)
cooldown:SetCountdownFormatter(GetFormatter())
UpdateFont(cooldown)
end
-- runs as a pfUI cooldown's timer starts: a timer with a total brings back
-- the sweep a time-left-only one took away, and the font follows a changed
-- height
local function StartTimer(cooldown, timeleftOnly)
if cooldown.pfTimeLeftOnly ~= timeleftOnly then
cooldown.pfTimeLeftOnly = timeleftOnly
SetupCooldown(cooldown)
elseif cooldown:GetParent():GetHeight() ~= cooldown.pfCountdownHeight then
UpdateFont(cooldown)
end
end
-- every timer, pfUI's or another addon's, Cooldown frame or 1.12 indicator
-- Model, is started through CooldownFrame_SetTimer
hooksecurefunc("CooldownFrame_SetTimer", function(cooldown)
-- the Models have no numbers and keep the stock timer
if not cooldown:IsObjectType("Cooldown") then return end
if cooldown.pfCooldownKind then
StartTimer(cooldown, nil)
else
SetupForeign(cooldown)
end
end)
-- [ CreateCooldown ] --
-- Creates one of pfUI's cooldowns: a Cooldown frame over all of 'parent'
-- with the settings of its kind. Start it with CooldownFrame_SetTimer.
-- 'parent' [frame] the frame the cooldown covers
-- 'kind' [string] what it times, a group of C.cooldown: actionbar,
-- bags, blizzard, unitframe, indicator, nameplate,
-- buff, tooltip, totem or lossofcontrol
-- 'name' [string] optional frame name
-- return [frame] the Cooldown frame
function pfUI.api.CreateCooldown(parent, kind, name)
local cooldown = CreateFrame("Cooldown", name, parent, "CooldownFrameTemplate")
cooldown.pfCooldownKind = kind
table.insert(cooldowns, cooldown)
SetupCooldown(cooldown)
return cooldown
end
-- [ SetCooldownTimeLeft ] --
-- Starts a cooldown from its time left alone, for timers that report no
-- total (weapon enchants): the numbers show, the sweep stays off until a
-- timer with a total starts.
-- 'cooldown' [frame] a cooldown from CreateCooldown
-- 'timeleft' [number] the seconds left
function pfUI.api.SetCooldownTimeLeft(cooldown, timeleft)
StartTimer(cooldown, true)
cooldown:SetCooldown(GetTime(), timeleft)
end
-- [ UpdateCooldowns ] --
-- Applies changed cooldown settings to every pfUI cooldown.
function pfUI.api.UpdateCooldowns()
if formatter then UpdateFormatter() end
for _, cooldown in ipairs(cooldowns) do
SetupCooldown(cooldown)
end
end
-- [ GetAuraTimer ] --
-- The cooldown start and duration of an aura from C_UnitAuras, 0, 0 when it
-- has none. Talent-extended auras run past their Spell.dbc base duration, and
-- a start in the future would hold the timer until then, so the start is
-- capped to now.
-- 'duration' [number] the aura's duration
-- 'expirationTime' [number] the aura's expiration time
-- return [number] start, duration
function pfUI.api.GetAuraTimer(duration, expirationTime)
if expirationTime <= 0 then return 0, 0 end
local now = GetTime()
local start, dur = expirationTime - duration, duration
if start > now or dur <= 0 then
start, dur = now, expirationTime - now
end
if dur <= 0 then return 0, 0 end
return start, dur
end
-- [ GetColoredTimeString ] --
-- 'remaining' [number] the time in seconds that should be converted
-- return [string] the time as cooldown numbers show it
function pfUI.api.GetColoredTimeString(remaining)
return GetFormatter():FormatNumber(remaining)
end
+17 -60
View File
@@ -69,23 +69,6 @@ local function LayoutAuras(unit, unitstr)
end
end
-- Returns the cooldown start and duration of an aura, 0, 0 when it has none.
-- Start is capped to now: talent-extended auras run past their Spell.dbc base
-- duration, and a start in the future trips the cooldown text's 2^32
-- wraparound branch.
local function AuraTimer(duration, expirationTime)
if expirationTime <= 0 then return 0, 0 end
local now = GetTime()
local start, dur = expirationTime - duration, duration
if start > now or dur <= 0 then
start, dur = now, expirationTime - now
end
if dur <= 0 then return 0, 0 end
return start, dur
end
-- Starts the timers RefreshUnit stored on the shown icons of an aura block.
local function StartAuraTimers(icons)
if not icons then return end
@@ -109,7 +92,7 @@ local function RetimeAuras(icons, unitstr)
local _, _, count, _, duration, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, icons[i].slot)
if count then
icons[i].stacks:SetText(count > 1 and count or "")
icons[i].auraStart, icons[i].auraDuration = AuraTimer(duration, expirationTime)
icons[i].auraStart, icons[i].auraDuration = GetAuraTimer(duration, expirationTime)
end
i = i + 1
end
@@ -550,10 +533,6 @@ function pfUI.uf:UpdateConfig()
-- aura icon backdrops sit outside the icon, so gaps clear both borders
local aura_border = (C.appearance.border.force_blizz == "1" and 1 or 2) * default_border
local cooldown_text = tonumber(f.config.cooldown_text)
local cooldown_anim = tonumber(f.config.cooldown_anim)
local cooldown_reverse = f.config.cooldown_reverse == "1"
local relative_point = "BOTTOM"
if f.config.panchor == "TOPLEFT" then
relative_point = "BOTTOMLEFT"
@@ -920,17 +899,8 @@ function pfUI.uf:UpdateConfig()
f.buffs[i]:SetFrameLevel(12)
f.buffs[i]:RegisterForClicks("RightButtonUp")
f.buffs[i].cd = f.buffs[i].cd or CreateFrame("Cooldown", f.buffs[i]:GetName() .. "Cooldown", f.buffs[i], "CooldownFrameTemplate")
f.buffs[i].cd = f.buffs[i].cd or CreateCooldown(f.buffs[i], "unitframe", f.buffs[i]:GetName() .. "Cooldown")
f.buffs[i].cd:SetFrameLevel(14)
f.buffs[i].cd.pfCooldownType = "ALL"
f.buffs[i].cd.pfCooldownStyleText = cooldown_text
f.buffs[i].cd.pfCooldownStyleAnimation = cooldown_anim
f.buffs[i].cd:SetDrawSwipe(cooldown_anim == 1)
f.buffs[i].cd:SetDrawBling(cooldown_anim == 1)
f.buffs[i].cd:SetReverse(cooldown_reverse)
-- immediately show/hide existing cooldown text
f.buffs[i].cd:SetHideCountdownNumbers(cooldown_text == 0)
f.buffs[i].id = i
f.buffs[i]:Hide()
@@ -980,17 +950,8 @@ function pfUI.uf:UpdateConfig()
f.debuffs[i]:RegisterForClicks("RightButtonUp")
f.debuffs[i]:SetNormalTexture(nil)
f.debuffs[i].cd = f.debuffs[i].cd or CreateFrame("Cooldown", f.debuffs[i]:GetName() .. "Cooldown", f.debuffs[i], "CooldownFrameTemplate")
f.debuffs[i].cd = f.debuffs[i].cd or CreateCooldown(f.debuffs[i], "unitframe", f.debuffs[i]:GetName() .. "Cooldown")
f.debuffs[i].cd:SetFrameLevel(14)
f.debuffs[i].cd.pfCooldownType = "ALL"
f.debuffs[i].cd.pfCooldownStyleText = cooldown_text
f.debuffs[i].cd.pfCooldownStyleAnimation = cooldown_anim
f.debuffs[i].cd:SetDrawSwipe(cooldown_anim == 1)
f.debuffs[i].cd:SetDrawBling(cooldown_anim == 1)
f.debuffs[i].cd:SetReverse(cooldown_reverse)
-- immediately show/hide existing cooldown text
f.debuffs[i].cd:SetHideCountdownNumbers(cooldown_text == 0)
f.debuffs[i].id = i
f.debuffs[i]:Hide()
@@ -1936,7 +1897,7 @@ function pfUI.uf:RefreshUnit(unit, component)
unit.buffs[i].stacks:SetText("")
end
unit.buffs[i].auraStart, unit.buffs[i].auraDuration = AuraTimer(duration, expirationTime)
unit.buffs[i].auraStart, unit.buffs[i].auraDuration = GetAuraTimer(duration, expirationTime)
else
unit.buffs[i]:Hide()
end
@@ -1980,7 +1941,7 @@ function pfUI.uf:RefreshUnit(unit, component)
unit.debuffs[i].slot = auraSlots[i]
unit.debuffs[i]:Show()
unit.debuffs[i].auraStart, unit.debuffs[i].auraDuration = AuraTimer(duration, expirationTime)
unit.debuffs[i].auraStart, unit.debuffs[i].auraDuration = GetAuraTimer(duration, expirationTime)
if stacks > 1 then
unit.debuffs[i].stacks:SetText(stacks)
@@ -2151,7 +2112,7 @@ function pfUI.uf:RefreshUnit(unit, component)
if table.getn(unit.indicators) > 0 then
local n = ScanAuraSlots(unitstr, "HELPFUL", auraSlots)
for i=1,n do
local name, icon, count, _, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
local name, icon, count, _, duration, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
if not name then break end
local timeleft = expirationTime > 0 and (expirationTime - GetTime()) or nil
@@ -2161,7 +2122,7 @@ function pfUI.uf:RefreshUnit(unit, component)
local start, duration, prediction = libpredict:GetHotDuration(unitstr, filter.predict)
pfUI.uf:AddIcon(unit, pos, icon, timeleft or prediction, count, tonumber(start), tonumber(duration))
else
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count)
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count, GetAuraTimer(duration, expirationTime))
end
pos = pos + 1
break
@@ -2173,13 +2134,13 @@ function pfUI.uf:RefreshUnit(unit, component)
if table.getn(unit.indicator_custom) > 0 then
local n = ScanAuraSlots(unitstr, "HELPFUL", auraSlots)
for i=1,n do
local name, icon, count, _, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
local name, icon, count, _, duration, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
if not name then break end
local timeleft = expirationTime > 0 and (expirationTime - GetTime()) or nil
local lowerName = name:lower()
for _, filter in pairs(unit.indicator_custom) do
if filter == lowerName then
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count)
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count, GetAuraTimer(duration, expirationTime))
pos = pos + 1
break
end
@@ -2189,12 +2150,12 @@ function pfUI.uf:RefreshUnit(unit, component)
local debuffFilter = unit.config.selfdebuff == "1" and "HARMFUL|PLAYER" or "HARMFUL"
n = ScanAuraSlots(unitstr, debuffFilter, auraSlots)
for i=1,n do -- scan for custom debuffs
local name, icon, count, _, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
local name, icon, count, _, duration, expirationTime = C_UnitAuras.UnitAuraBySlot(unitstr, auraSlots[i])
if name then
local timeleft = expirationTime > 0 and (expirationTime - GetTime()) or nil
for _, filter in pairs(unit.indicator_custom) do
if filter == name:lower() then
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count)
pfUI.uf:AddIcon(unit, pos, icon, timeleft, count, GetAuraTimer(duration, expirationTime))
pos = pos + 1
break
end
@@ -2425,7 +2386,6 @@ function pfUI.uf:EnableClickCast()
end
function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks, start, duration)
local showtime = frame.config.indicator_time == "1" and true or nil
local showstacks = frame.config.indicator_stacks == "1" and true or nil
local position = frame.config.indicator_pos or "TOPLEFT"
local iconsize = tonumber(frame.config.indicator_size)
@@ -2448,11 +2408,7 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks, start, duration)
frame.icon[pos].stacks:SetJustifyH("RIGHT")
frame.icon[pos].stacks:SetJustifyV("BOTTOM")
frame.icon[pos].cd = CreateFrame("Cooldown", nil, frame.icon[pos], "CooldownFrameTemplate")
frame.icon[pos].cd.pfCooldownStyleAnimation = 0
frame.icon[pos].cd:SetDrawSwipe(false)
frame.icon[pos].cd:SetDrawBling(false)
frame.icon[pos].cd.pfCooldownType = "ALL"
frame.icon[pos].cd = CreateCooldown(frame.icon[pos], "indicator")
frame.icon[pos].cd:SetFrameLevel(48)
end
@@ -2471,11 +2427,12 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks, start, duration)
frame.icon[pos].icon = icon
end
-- show remaining time if config is set
if showtime and start and duration and timeleft < 100 and iconsize > 9 then
-- start the timer from the aura's duration, or from its time left alone
-- when a prediction has no duration; icons this small have no room for it
if iconsize > 9 and duration and duration > 0 then
CooldownFrame_SetTimer(frame.icon[pos].cd, start, duration, 1)
elseif showtime and timeleft and timeleft < 100 and iconsize > 9 then
CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), timeleft, 1)
elseif iconsize > 9 and timeleft and timeleft > 0 then
SetCooldownTimeLeft(frame.icon[pos].cd, timeleft)
else
CooldownFrame_SetTimer(frame.icon[pos].cd, GetTime(), 0, 1)
end