mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 22:00:49 +00:00
Size aura cooldown text to its laid-out icon
Unit frame aura icons only get their size from the layout pass, but RefreshUnit started their timers before it ran. A cooldown text created on a never-laid-out icon saw a height of 0 and fell back to a 16pt font, so some buff and debuff timers overflowed their icons. (Closes #64) - RefreshUnit stores each aura's timer and starts them after LayoutAuras, once every icon has its final size. - With dynamic size on, the cooldown text re-sizes its font whenever its frame's height changed since the last SetTimer, so icons that switch between the normal and own aura size keep a matching font.
This commit is contained in:
+26
-13
@@ -59,18 +59,14 @@ pfUI:RegisterModule("cooldown", function ()
|
||||
end
|
||||
end
|
||||
|
||||
local height, size
|
||||
local textcount = 0
|
||||
local function pfCreateCoolDown(cooldown, start, duration)
|
||||
textcount = textcount + 1
|
||||
local name = cooldown.GetName and cooldown:GetName() or "pfCooldown" .. textcount
|
||||
|
||||
cooldown.pfCooldownText = CreateFrame("Frame", name .. "Text", cooldown:GetParent())
|
||||
cooldown.pfCooldownText.cooldown = cooldown
|
||||
cooldown.pfCooldownText:SetAllPoints(cooldown)
|
||||
cooldown.pfCooldownText:SetFrameLevel(cooldown:GetParent():GetFrameLevel() + 2)
|
||||
cooldown.pfCooldownText.text = cooldown.pfCooldownText:CreateFontString(name .. "TextString", "OVERLAY")
|
||||
local function GetCooldownHeight(cooldown)
|
||||
return cooldown:GetParent() and cooldown:GetParent():GetHeight() or cooldown:GetHeight() or 0
|
||||
end
|
||||
|
||||
-- sizes the text to the cooldown's current height; the dynamic size follows
|
||||
-- the frame, so SetCooldown calls this again whenever that height changes
|
||||
local function pfUpdateCooldownFont(cooldown)
|
||||
local size
|
||||
if not cooldown.pfCooldownType then
|
||||
size = tonumber(C.appearance.cd.font_size_foreign)
|
||||
elseif cooldown.pfCooldownType == "BLIZZARD" then
|
||||
@@ -82,12 +78,27 @@ pfUI:RegisterModule("cooldown", function ()
|
||||
end
|
||||
|
||||
-- enforce dynamic font size
|
||||
if C.appearance.cd.dynamicsize == "1" and cooldown.GetParent then
|
||||
height = cooldown:GetParent() and cooldown:GetParent():GetHeight() or cooldown:GetHeight() or 0
|
||||
if C.appearance.cd.dynamicsize == "1" then
|
||||
local height = GetCooldownHeight(cooldown)
|
||||
cooldown.pfCooldownText.height = height
|
||||
size = math.max((height > 0 and height * .64 or 16), size)
|
||||
end
|
||||
|
||||
cooldown.pfCooldownText.text:SetFont(pfUI.media[C.appearance.cd.font], size, "OUTLINE")
|
||||
end
|
||||
|
||||
local textcount = 0
|
||||
local function pfCreateCoolDown(cooldown, start, duration)
|
||||
textcount = textcount + 1
|
||||
local name = cooldown.GetName and cooldown:GetName() or "pfCooldown" .. textcount
|
||||
|
||||
cooldown.pfCooldownText = CreateFrame("Frame", name .. "Text", cooldown:GetParent())
|
||||
cooldown.pfCooldownText.cooldown = cooldown
|
||||
cooldown.pfCooldownText:SetAllPoints(cooldown)
|
||||
cooldown.pfCooldownText:SetFrameLevel(cooldown:GetParent():GetFrameLevel() + 2)
|
||||
cooldown.pfCooldownText.text = cooldown.pfCooldownText:CreateFontString(name .. "TextString", "OVERLAY")
|
||||
|
||||
pfUpdateCooldownFont(cooldown)
|
||||
cooldown.pfCooldownText.text:SetPoint("CENTER", cooldown.pfCooldownText, "CENTER", 0, 0)
|
||||
cooldown.pfCooldownText:SetScript("OnUpdate", pfCooldownOnUpdate)
|
||||
end
|
||||
@@ -136,6 +147,8 @@ pfUI:RegisterModule("cooldown", function ()
|
||||
and start > 0 and duration > 0 and (not enable or enable > 0) then
|
||||
if( not this.pfCooldownText ) then
|
||||
pfCreateCoolDown(this, start, duration)
|
||||
elseif C.appearance.cd.dynamicsize == "1" and GetCooldownHeight(this) ~= this.pfCooldownText.height then
|
||||
pfUpdateCooldownFont(this)
|
||||
end
|
||||
|
||||
this.pfCooldownText.start = start
|
||||
|
||||
Reference in New Issue
Block a user