Pick cooldown timers per feature with one dropdown

Each feature's settings page now picks its own timers - None, Numbers,
Sweep, or Numbers And Sweep - in place of the "Show Numbers On", "Show
Sweep On" and "Reverse Sweep On" lists on Settings -> Cooldown. Unit
frames get theirs per frame again ("Buff And Debuff Timers" and
"Indicator Timers"), so party and pet can drop their numbers while the
target keeps them. The other dropdowns sit on Action Bars, Bags & Bank,
Buff/Debuff Icons, Totem Icons, Tooltip and Nameplates.

Settings -> Cooldown keeps the shared font, size, threshold, tenths and
colors, plus the timers of Spellbook And Character, Loss Of Control and
Other Addons, which have no page of their own.

CreateCooldown(parent, kind, config, key, name) reads its mode from
config[key]. The kind says only what it times: "spell" hides numbers on
the global cooldown, "aura" drains its sweep, "timer" fills it. The
reverse option is gone; the direction follows the kind.

The migration carries every old setting into its timers: the
C.cooldown kind tables, appearance.cd's foreign and Blizzard toggles,
the buff frame's sweep, the nameplate debuff options, and each unit
frame's timer text, sweep and "Show Time Left" from before the kinds,
so frames that had their own settings keep them. Reverse options are
dropped.
This commit is contained in:
Brues
2026-11-02 16:07:41 -06:00
parent 494f176f18
commit 001e09c1b7
21 changed files with 231 additions and 224 deletions
+82 -74
View File
@@ -71,6 +71,7 @@ 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, "timers", "both")
pfUI:UpdateConfig("buffbar", "pbuff", "enable", "0")
pfUI:UpdateConfig("buffbar", "pbuff", "use_unitfonts", "0")
@@ -149,38 +150,9 @@ function pfUI:LoadConfig()
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("cooldown", nil, "blizzard_timers", "both")
pfUI:UpdateConfig("cooldown", nil, "lossofcontrol_timers", "both")
pfUI:UpdateConfig("cooldown", nil, "foreign_timers", "sweep")
pfUI:UpdateConfig("appearance", "castbar", "castbarcolor", ".7,.7,.9,.8")
pfUI:UpdateConfig("appearance", "castbar", "channelcolor", ".9,.9,.7,.8")
@@ -207,6 +179,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("appearance", "bags", "autoSortOnOpen", "0")
pfUI:UpdateConfig("appearance", "bags", "sortreverse", "0")
pfUI:UpdateConfig("appearance", "bags", "sortprioreverse", "0")
pfUI:UpdateConfig("appearance", "bags", "timers", "both")
pfUI:UpdateConfig("appearance", "minimap", "size", "140")
pfUI:UpdateConfig("appearance", "minimap", "arrowscale", "1")
pfUI:UpdateConfig("appearance", "minimap", "zonetext", "off")
@@ -564,6 +537,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", unit, "debuffoffy", "0")
pfUI:UpdateConfig("unitframes", unit, "debuffspacingx", "1")
pfUI:UpdateConfig("unitframes", unit, "debuffspacingy", "1")
pfUI:UpdateConfig("unitframes", unit, "aura_timers", "text")
pfUI:UpdateConfig("unitframes", unit, "invert_healthbar", "0")
pfUI:UpdateConfig("unitframes", unit, "verticalbar", "0")
pfUI:UpdateConfig("unitframes", unit, "buff_indicator", "0")
@@ -584,6 +558,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", unit, "indicator_size", "10")
pfUI:UpdateConfig("unitframes", unit, "indicator_spacing","1")
pfUI:UpdateConfig("unitframes", unit, "indicator_pos", "TOPLEFT")
pfUI:UpdateConfig("unitframes", unit, "indicator_timers", "text")
pfUI:UpdateConfig("unitframes", unit, "clickcast", "0")
pfUI:UpdateConfig("unitframes", unit, "faderange", "0")
@@ -714,6 +689,7 @@ 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, "timers", "both")
pfUI:UpdateConfig("bars", "gryphons", "texture", "None")
pfUI:UpdateConfig("bars", "gryphons", "color", ".6,.6,.6,1")
@@ -727,6 +703,7 @@ 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, "timers", "both")
pfUI:UpdateConfig("panel", nil, "use_unitfonts", "0")
pfUI:UpdateConfig("panel", nil, "hide_leftchat", "0")
@@ -839,6 +816,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("tooltip", "statusbar", "texture", "Interface\\AddOns\\pfUI\\img\\bar")
pfUI:UpdateConfig("tooltip", nil, "font_tooltip", "Interface\\AddOns\\pfUI\\fonts\\Myriad-Pro.ttf")
pfUI:UpdateConfig("tooltip", nil, "font_tooltip_size", "12")
pfUI:UpdateConfig("tooltip", nil, "aura_timers", "text")
-- Throttle Settings
@@ -963,6 +941,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("nameplates", nil, "glowcolor", "1,1,1,1")
pfUI:UpdateConfig("nameplates", nil, "targetzoom", "0")
pfUI:UpdateConfig("nameplates", nil, "targetzoomval", ".40")
pfUI:UpdateConfig("nameplates", nil, "debuff_timers", "text")
pfUI:UpdateConfig("nameplates", nil, "notargalpha", ".75")
pfUI:UpdateConfig("nameplates", nil, "healthtexture", "Interface\\AddOns\\pfUI\\img\\bar")
pfUI:UpdateConfig("nameplates", "name", "fontstyle", "OUTLINE")
@@ -1436,9 +1415,32 @@ function pfUI:MigrateConfig()
pfUI_config.unitframes.always2dportrait = nil
end
-- migrate the scattered cooldown settings into the cooldown table; keyed
-- on the old settings rather than the version, like the portrait style
-- migrate the old cooldown settings into each feature's timers setting;
-- keyed on the old settings rather than the version, like the portrait
-- style. Reverse options are dropped: the direction follows what a
-- cooldown times.
local cooldown = pfUI_config.cooldown
-- 'mode' with its numbers and sweep replaced by 'text' and 'sweep' ("1" or
-- "0"), each kept when nil
local function timers(mode, text, sweep)
local numbers = mode == "text" or mode == "both"
local swipe = mode == "sweep" or mode == "both"
if text then numbers = text == "1" end
if sweep then swipe = sweep == "1" end
if numbers and swipe then return "both" end
return numbers and "text" or swipe and "sweep" or "off"
end
-- every unit frame's settings
local function units(func)
for _, unit in pairs(pfUI_config.unitframes) do
if type(unit) == "table" and unit.aura_timers then func(unit) end
end
end
-- the shared look and the foreign and Blizzard toggles of appearance.cd
local cd = pfUI_config.appearance.cd
if cd then
for _, entry in pairs({ "font", "font_size", "dynamicsize", "threshold", "milliseconds",
@@ -1446,17 +1448,12 @@ function pfUI:MigrateConfig()
cooldown[entry] = cd[entry] or cooldown[entry]
end
cooldown.foreign.text = cd.foreign or cooldown.foreign.text
if cd.hideanim then
cooldown.foreign.animation = cd.hideanim == "1" and "0" or "1"
end
local sweep = cd.hideanim and (cd.hideanim == "1" and "0" or "1")
cooldown.foreign_timers = timers(cooldown.foreign_timers, cd.foreign, sweep)
-- spellbook and character slots took the foreign sweep, and with the
-- Blizzard toggle off the foreign numbers too
cooldown.blizzard.animation = cooldown.foreign.animation
if cd.blizzard == "0" then
cooldown.blizzard.text = cooldown.foreign.text
end
cooldown.blizzard_timers = timers(cooldown.blizzard_timers, cd.blizzard == "0" and (cd.foreign or "0") or nil, sweep)
-- pfUI drew its own numbers before; the native countdown shows them
-- only with this cvar on, which only the first-run setup sets
@@ -1465,40 +1462,51 @@ function pfUI:MigrateConfig()
pfUI_config.appearance.cd = nil
end
local function move(config, old, kind, entry)
if config[old] then
cooldown[kind][entry] = config[old]
config[old] = nil
-- the options of each module
local buffs, nameplates = pfUI_config.buffs, pfUI_config.nameplates
buffs.timers = timers(buffs.timers, nil, buffs.cooldown_anim)
nameplates.debuff_timers = timers(nameplates.debuff_timers, nameplates.debufftext, nameplates.debuffanim)
if nameplates.debufftimers == "0" then nameplates.debuff_timers = "off" end
units(function(unit)
unit.aura_timers = timers(unit.aura_timers, unit.cooldown_text, unit.cooldown_anim)
unit.indicator_timers = timers(unit.indicator_timers, unit.indicator_time)
unit.cooldown_text, unit.cooldown_anim, unit.cooldown_reverse, unit.indicator_time = nil, nil, nil, nil
end)
pfUI_config.bars.cooldown_reverse = nil
pfUI_config.appearance.bags.cooldown_reverse = nil
pfUI_config.totems.cooldown_reverse = nil
buffs.cooldown_anim, buffs.cooldown_reverse = nil, nil
nameplates.debufftext, nameplates.debuffanim, nameplates.debreverse, nameplates.debufftimers = nil, nil, nil, nil
-- the cooldown kinds of Settings -> Cooldown, each with its numbers and
-- sweep, into the setting that replaced it
local kinds = {
actionbar = { pfUI_config.bars, "timers" },
bags = { pfUI_config.appearance.bags, "timers" },
blizzard = { cooldown, "blizzard_timers" },
nameplate = { nameplates, "debuff_timers" },
buff = { buffs, "timers" },
tooltip = { pfUI_config.tooltip, "aura_timers" },
totem = { pfUI_config.totems, "timers" },
lossofcontrol = { cooldown, "lossofcontrol_timers" },
foreign = { cooldown, "foreign_timers" },
unitframe = "aura_timers",
indicator = "indicator_timers",
}
for kind, target in pairs(kinds) do
local old = cooldown[kind]
if type(old) == "table" then
if type(target) == "string" then
units(function(unit) unit[target] = timers(unit[target], old.text, old.animation) end)
else
target[1][target[2]] = timers(target[1][target[2]], old.text, old.animation)
end
cooldown[kind] = nil
end
end
move(pfUI_config.bars, "cooldown_reverse", "actionbar", "reverse")
move(pfUI_config.appearance.bags, "cooldown_reverse", "bags", "reverse")
move(pfUI_config.buffs, "cooldown_anim", "buff", "animation")
move(pfUI_config.buffs, "cooldown_reverse", "buff", "reverse")
move(pfUI_config.totems, "cooldown_reverse", "totem", "reverse")
move(pfUI_config.nameplates, "debufftext", "nameplate", "text")
move(pfUI_config.nameplates, "debuffanim", "nameplate", "animation")
move(pfUI_config.nameplates, "debreverse", "nameplate", "reverse")
if pfUI_config.nameplates.debufftimers == "0" then
cooldown.nameplate.text, cooldown.nameplate.animation = "0", "0"
end
-- one setting now covers every unit frame: the target frame's auras and
-- the raid frames' indicators stand for the rest
move(pfUI_config.unitframes.target, "cooldown_text", "unitframe", "text")
move(pfUI_config.unitframes.target, "cooldown_anim", "unitframe", "animation")
move(pfUI_config.unitframes.target, "cooldown_reverse", "unitframe", "reverse")
move(pfUI_config.unitframes.raid, "indicator_time", "indicator", "text")
for _, unit in pairs(pfUI_config.unitframes) do
if type(unit) == "table" then
unit.cooldown_text, unit.cooldown_anim, unit.cooldown_reverse, unit.indicator_time = nil, nil, nil, nil
end
end
pfUI_config.nameplates.debufftimers = nil
pfUI_config.bars.cd_size = nil
-- Remove "Show only own debuffs" from unitframes and nameplates
+34 -25
View File
@@ -1,16 +1,20 @@
-- 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.
-- Every pfUI cooldown is a Cooldown frame from CreateCooldown. The settings
-- of the feature it belongs to pick its timers: none, numbers, sweep or both.
-- Settings -> Cooldown (C.cooldown) sets one font and one formatter for 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" timers 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 }
local function ShowNumbers(mode)
return mode == "text" or mode == "both"
end
local function ShowSweep(mode)
return mode == "sweep" or mode == "both"
end
-- every cooldown CreateCooldown made, for UpdateCooldowns
local cooldowns = {}
@@ -69,34 +73,34 @@ local function OnSizeChanged(cooldown, width, height)
UpdateFont(cooldown, height)
end
-- applies the settings of its kind to one of pfUI's cooldowns
-- applies its timers setting 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
local mode = cooldown.pfCooldownConfig[cooldown.pfCooldownKey]
local sweep = ShowSweep(mode) and not cooldown.pfTimeLeftOnly
cooldown:SetHideCountdownNumbers(config.text ~= "1")
cooldown:SetHideCountdownNumbers(not ShowNumbers(mode))
cooldown:SetDrawSwipe(sweep)
cooldown:SetDrawBling(sweep)
cooldown:SetReverse(config.reverse == "1")
cooldown:SetMinimumCountdownDuration(spell[kind] and tonumber(C.cooldown.threshold) * 1000 or 0)
cooldown:SetReverse(kind == "aura")
cooldown:SetMinimumCountdownDuration(kind == "spell" and tonumber(C.cooldown.threshold) * 1000 or 0)
cooldown:SetCountdownFormatter(GetFormatter())
UpdateFont(cooldown, cooldown:GetParent():GetHeight())
end
-- applies the "foreign" settings to another addon's cooldown. They only take
-- applies the "foreign" timers 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
local mode = C.cooldown.foreign_timers
if config.animation ~= "1" then
if not ShowSweep(mode) 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
if not ShowNumbers(mode) or cooldown.noCooldownCount then
cooldown:SetHideCountdownNumbers(true)
return
end
@@ -129,17 +133,22 @@ hooksecurefunc("CooldownFrame_SetTimer", function(cooldown)
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.
-- Creates one of pfUI's cooldowns: a Cooldown frame over all of 'parent'.
-- 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
-- 'kind' [string] what it times: "spell" (spells and items: the sweep
-- fills, no numbers for the global cooldown), "aura"
-- (the sweep drains) or "timer" (the sweep fills)
-- 'config' [table] the settings that hold its timers
-- 'key' [string] the timers setting in 'config': "off", "text",
-- "sweep" or "both"
-- 'name' [string] optional frame name
-- return [frame] the Cooldown frame
function pfUI.api.CreateCooldown(parent, kind, name)
function pfUI.api.CreateCooldown(parent, kind, config, key, name)
local cooldown = CreateFrame("Cooldown", name, parent, "CooldownFrameTemplate")
cooldown.pfCooldownKind = kind
cooldown.pfCooldownConfig = config
cooldown.pfCooldownKey = key
cooldown:SetScript("OnSizeChanged", OnSizeChanged)
table.insert(cooldowns, cooldown)
SetupCooldown(cooldown)
+4 -3
View File
@@ -946,7 +946,7 @@ function pfUI.uf:UpdateConfig()
f.buffs[i]:SetFrameLevel(12)
f.buffs[i]:RegisterForClicks("RightButtonUp")
f.buffs[i].cd = f.buffs[i].cd or CreateCooldown(f.buffs[i], "unitframe", f.buffs[i]:GetName() .. "Cooldown")
f.buffs[i].cd = f.buffs[i].cd or CreateCooldown(f.buffs[i], "aura", f.config, "aura_timers", f.buffs[i]:GetName() .. "Cooldown")
f.buffs[i].cd:SetFrameLevel(14)
f.buffs[i].id = i
@@ -999,7 +999,7 @@ function pfUI.uf:UpdateConfig()
f.debuffs[i]:RegisterForClicks("RightButtonUp")
f.debuffs[i]:SetNormalTexture(nil)
f.debuffs[i].cd = f.debuffs[i].cd or CreateCooldown(f.debuffs[i], "unitframe", f.debuffs[i]:GetName() .. "Cooldown")
f.debuffs[i].cd = f.debuffs[i].cd or CreateCooldown(f.debuffs[i], "aura", f.config, "aura_timers", f.debuffs[i]:GetName() .. "Cooldown")
f.debuffs[i].cd:SetFrameLevel(14)
f.debuffs[i].id = i
@@ -2443,6 +2443,7 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks, start, duration)
local position = frame.config.indicator_pos or "TOPLEFT"
local iconsize = tonumber(frame.config.indicator_size)
local spacing = tonumber(frame.config.indicator_spacing)
local config = frame.config
if not frame.hp then return end
local frame = frame.hp.bar
@@ -2461,7 +2462,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 = CreateCooldown(frame.icon[pos], "indicator")
frame.icon[pos].cd = CreateCooldown(frame.icon[pos], "aura", config, "indicator_timers")
frame.icon[pos].cd:SetFrameLevel(48)
end