mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-02 08:56:57 +00:00
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:
-48
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user