mirror of
https://github.com/brues-code/pfUI.git
synced 2026-11-02 17:06:57 +00:00
The cooldown module no longer builds its own text frame with a 10 Hz OnUpdate per cooldown. The CooldownFrame_SetTimer hook now configures each Cooldown frame's own countdown instead: SetHideCountdownNumbers for the per-frame text toggles and omnicc's noCooldownCount, SetMinimumCountdownDuration for the GCD threshold, and GetCountdownFontString for the pfUI font and size. The engine ticks the numbers, gated by the countdownForCooldowns cvar. The cvar gets a checkbox in the Cooldown settings, and pfUI.SetupCVars turns it on. The text comes from one shared C_StringUtil numeric rule formatter, given to each frame with SetCountdownFormatter. Its breakpoints keep pfUI's format: the number in its unit's cooldown color, a unit (m/h/d) once the unit below passes 99, and tenths in the low color when milliseconds are on. Values now round up. GetColoredTimeString formats through the same formatter, so the buff, buffwatch and tooltip timers match. A config:changed callback rebuilds the breakpoints, and every frame picks them up on its next update. The paper-doll slots swap their indicator Models for Cooldown frames, as the spellbook and bags already do. They and the spellbook take the BLIZZARD tag when they are created, replacing the per-update hooks in the skin module. Models get no numbers. Hide Foreign Cooldown Animations clears the draw flags instead of setting alpha to 0, so the numbers stay visible. The buff module's sweep hides its numbers because buff.timer carries the text.
76 lines
2.7 KiB
Lua
76 lines
2.7 KiB
Lua
pfUI:RegisterModule("cooldown", function ()
|
|
-- The numbers are the Cooldown frame's own countdown (ClassicAPI): the
|
|
-- engine ticks them, gated by the countdownForCooldowns cvar, and writes
|
|
-- them through pfUI's shared formatter. pfUI only configures each frame as
|
|
-- its timer is set.
|
|
|
|
local function GetCooldownHeight(cooldown)
|
|
return cooldown:GetParent() and cooldown:GetParent():GetHeight() or cooldown:GetHeight() or 0
|
|
end
|
|
|
|
-- sizes the numbers to the cooldown's current height; the dynamic size
|
|
-- follows the frame, so SetCooldown calls this again whenever that height
|
|
-- changes
|
|
local function UpdateCountdownFont(cooldown)
|
|
local size
|
|
if not cooldown.pfCooldownType then
|
|
size = tonumber(C.appearance.cd.font_size_foreign)
|
|
elseif cooldown.pfCooldownType == "BLIZZARD" then
|
|
size = tonumber(C.appearance.cd.font_size_blizz)
|
|
elseif cooldown.pfCooldownSize then
|
|
size = tonumber(cooldown.pfCooldownSize)
|
|
else
|
|
size = tonumber(C.appearance.cd.font_size)
|
|
end
|
|
|
|
local height = GetCooldownHeight(cooldown)
|
|
cooldown.pfCountdownHeight = height
|
|
|
|
-- enforce dynamic font size
|
|
if C.appearance.cd.dynamicsize == "1" then
|
|
size = math.max((height > 0 and height * .64 or 16), size)
|
|
end
|
|
|
|
cooldown:GetCountdownFontString():SetFont(pfUI.media[C.appearance.cd.font], size, "OUTLINE")
|
|
end
|
|
|
|
-- hook
|
|
local function SetCooldown(this)
|
|
-- 1.12's indicator Models have no countdown and keep the stock timer
|
|
if not this:IsObjectType("Cooldown") then return end
|
|
|
|
-- no numbers on unknown frames, nor on frames with omnicc's disable flag
|
|
if (C.appearance.cd.foreign == "0" and not this.pfCooldownType) or this.noCooldownCount then
|
|
this:SetHideCountdownNumbers(true)
|
|
return
|
|
end
|
|
|
|
this:SetHideCountdownNumbers(this.pfCooldownStyleText == 0)
|
|
|
|
-- no numbers for global cooldowns, except on frames that time auras
|
|
if not this.pfCooldownType or this.pfCooldownType == "NOGCD" then
|
|
this:SetMinimumCountdownDuration(tonumber(C.appearance.cd.threshold) * 1000)
|
|
else
|
|
this:SetMinimumCountdownDuration(0)
|
|
end
|
|
|
|
this:SetCountdownFormatter(GetCountdownFormatter())
|
|
|
|
-- hide foreign animations; frames that set pfCooldownStyleAnimation
|
|
-- configure their own sweep. The draw flags, not alpha, so the numbers
|
|
-- stay visible
|
|
if not this.pfCooldownStyleAnimation and C.appearance.cd.hideanim == "1" then
|
|
this:SetDrawSwipe(false)
|
|
this:SetDrawBling(false)
|
|
end
|
|
|
|
if GetCooldownHeight(this) ~= this.pfCountdownHeight then
|
|
UpdateCountdownFont(this)
|
|
end
|
|
end
|
|
|
|
-- hook the SetTimer function that every cooldown, Cooldown frame or
|
|
-- stock indicator Model, is driven through.
|
|
hooksecurefunc("CooldownFrame_SetTimer", SetCooldown)
|
|
end)
|