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:
@@ -967,8 +967,6 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
local bind_size = tonumber(C.bars.bind_size)
|
||||
local bind_color = { GetStringColor(C.bars.bind_color) }
|
||||
|
||||
local cd_size = tonumber(C.bars.cd_size)
|
||||
|
||||
local showempty = C.bars["bar"..bar].showempty
|
||||
local showmacro = C.bars["bar"..bar].showmacro
|
||||
local showkybind = C.bars["bar"..bar].showkeybind
|
||||
@@ -978,7 +976,6 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
if macro_size == 0 then macro_size = 1 end
|
||||
if count_size == 0 then macro_size = 1 end
|
||||
if bind_size == 0 then macro_size = 1 end
|
||||
if cd_size == 0 then cd_size = nil end
|
||||
|
||||
local button_name = "pfActionBar" .. barnames[bar] .. "Button" .. button
|
||||
|
||||
@@ -1010,11 +1007,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
f.slot = id
|
||||
|
||||
-- cooldown
|
||||
f.cd = CreateFrame("Cooldown", f:GetName() .. "Cooldown", f, "CooldownFrameTemplate")
|
||||
f.cd.pfCooldownStyleAnimation = 1
|
||||
f.cd:SetReverse(C.bars.cooldown_reverse == "1")
|
||||
f.cd.pfCooldownType = "NOGCD"
|
||||
f.cd.pfCooldownSize = cd_size
|
||||
f.cd = CreateCooldown(f, "actionbar", f:GetName() .. "Cooldown")
|
||||
|
||||
-- icon
|
||||
f.icon = f:CreateTexture(button_name .. "Icon", "BACKGROUND")
|
||||
|
||||
+1
-4
@@ -415,11 +415,8 @@ pfUI:RegisterModule("bags", function ()
|
||||
-- reaches it after that
|
||||
local slotframe = pfUI.bags[bag].slots[slot].frame
|
||||
local cdname = slotframe:GetName() .. "Cooldown"
|
||||
slotframe.cd = CreateFrame("Cooldown", cdname, slotframe, "CooldownFrameTemplate")
|
||||
slotframe.cd = CreateCooldown(slotframe, "bags", cdname)
|
||||
_G[cdname] = slotframe.cd
|
||||
slotframe.cd.pfCooldownStyleAnimation = 1
|
||||
slotframe.cd:SetReverse(C.appearance.bags.cooldown_reverse == "1")
|
||||
slotframe.cd.pfCooldownType = "NOGCD"
|
||||
|
||||
if not pfUI.bags[bag].slots[slot].frame.backdrop then
|
||||
CreateBackdrop(pfUI.bags[bag].slots[slot].frame, default_border)
|
||||
|
||||
+66
-104
@@ -16,6 +16,25 @@ pfUI:RegisterModule("buff", function ()
|
||||
ScanAuraSlots("player", "HARMFUL", harmfulSlots, 16)
|
||||
end
|
||||
|
||||
-- weapon enchants report only their time left, and no event as their
|
||||
-- charges and time run down, so the OnUpdate below refreshes their buttons
|
||||
-- too: the charges, and the timer when the enchant was renewed
|
||||
local function RefreshWeaponButton(buff, timeleft, charges)
|
||||
timeleft = (timeleft or 0) / 1000
|
||||
charges = charges or 0
|
||||
buff.stacks:SetText(charges > 1 and charges or "")
|
||||
|
||||
local expires = GetTime() + timeleft
|
||||
if timeleft <= 0 then
|
||||
buff.cd:Clear()
|
||||
buff.cdExpires = nil
|
||||
elseif not buff.cdExpires or abs(buff.cdExpires - expires) > 1 then
|
||||
SetCooldownTimeLeft(buff.cd, timeleft)
|
||||
buff.cdExpires = expires
|
||||
end
|
||||
buff.cdStart = nil
|
||||
end
|
||||
|
||||
local function RefreshBuffButton(buff)
|
||||
if buff.btype == "HELPFUL" then
|
||||
if C.buffs.separateweapons == "1" then
|
||||
@@ -57,21 +76,22 @@ pfUI:RegisterModule("buff", function ()
|
||||
end
|
||||
end
|
||||
|
||||
-- Set Weapon Texture and Border
|
||||
-- Set Weapon Texture, Border and Timer
|
||||
if buff.mode == "MAINHAND" then
|
||||
buff.texture:SetTexture(GetInventoryItemTexture("player", 16))
|
||||
buff.backdrop:SetBackdropBorderColor(GetItemQualityColor(GetInventoryItemQuality("player", 16) or 1))
|
||||
RefreshWeaponButton(buff, mhtime, mhcharge)
|
||||
elseif buff.mode == "OFFHAND" then
|
||||
buff.texture:SetTexture(GetInventoryItemTexture("player", 17))
|
||||
buff.backdrop:SetBackdropBorderColor(GetItemQualityColor(GetInventoryItemQuality("player", 17) or 1))
|
||||
RefreshWeaponButton(buff, ohtime, ohcharge)
|
||||
end
|
||||
elseif name and (( buff.btype == "HARMFUL" and C.buffs.debuffs == "1" ) or ( buff.btype == "HELPFUL" and C.buffs.buffs == "1" )) then
|
||||
-- Set Buff Texture and Border
|
||||
buff.mode = buff.btype
|
||||
buff.expirationTime = expirationTime
|
||||
buff.stackCount = count
|
||||
buff.spellId = spellId
|
||||
buff.texture:SetTexture(icon)
|
||||
buff.stacks:SetText((count or 0) > 1 and count or "")
|
||||
|
||||
if buff.btype == "HARMFUL" then
|
||||
local dispelColor = C_UnitAuras.GetAuraDispelTypeColor(dispelType)
|
||||
@@ -79,33 +99,23 @@ pfUI:RegisterModule("buff", function ()
|
||||
else
|
||||
buff.backdrop:SetBackdropBorderColor(br,bg,bb,ba)
|
||||
end
|
||||
|
||||
-- start the timer from the aura's duration; permanent auras have none
|
||||
local start, dur = GetAuraTimer(duration, expirationTime)
|
||||
if dur <= 0 then
|
||||
buff.cd:Clear()
|
||||
buff.cdStart = nil
|
||||
elseif buff.cdStart == nil or abs(buff.cdStart - start) > .5 or buff.cdDuration ~= dur then
|
||||
CooldownFrame_SetTimer(buff.cd, start, dur, 1)
|
||||
buff.cdStart = start
|
||||
buff.cdDuration = dur
|
||||
end
|
||||
buff.cdExpires = nil
|
||||
else
|
||||
buff:Hide()
|
||||
return
|
||||
end
|
||||
|
||||
-- drive the sweep from the aura duration (weapon enchants and permanent
|
||||
-- auras report no usable total, so those buttons stay text-only)
|
||||
if C.buffs.cooldown_anim == "1" and buff.mode == buff.btype and duration and duration > 0 and expirationTime and expirationTime > 0 then
|
||||
local now = GetTime()
|
||||
local timeleft = expirationTime - now
|
||||
if timeleft > 0 then
|
||||
local effDuration = duration > timeleft and duration or timeleft
|
||||
local newStart = now + timeleft - effDuration
|
||||
if buff.cdStart == nil or abs(buff.cdStart - newStart) > .5 or buff.cdDuration ~= effDuration then
|
||||
buff.cd:SetCooldown(newStart, effDuration)
|
||||
buff.cdStart = newStart
|
||||
buff.cdDuration = effDuration
|
||||
end
|
||||
else
|
||||
buff.cd:Clear()
|
||||
buff.cdStart = nil
|
||||
end
|
||||
else
|
||||
buff.cd:Clear()
|
||||
buff.cdStart = nil
|
||||
end
|
||||
|
||||
buff:Show()
|
||||
end
|
||||
|
||||
@@ -128,29 +138,21 @@ pfUI:RegisterModule("buff", function ()
|
||||
buff.texture:SetTexCoord(.07,.93,.07,.93)
|
||||
buff.texture:SetAllPoints(buff)
|
||||
|
||||
-- overlay lifts the texts above the sweep: a child frame renders above
|
||||
-- all of its parent's own regions, so the timer would dim under the
|
||||
-- dark wedge otherwise
|
||||
-- overlay lifts the stacks above the sweep: a child frame renders above
|
||||
-- all of its parent's own regions, so they would dim under the dark
|
||||
-- wedge otherwise
|
||||
buff.overlay = CreateFrame("Frame", nil, buff)
|
||||
buff.overlay:SetAllPoints(buff)
|
||||
|
||||
buff.timer = buff.overlay:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
buff.timer:SetTextColor(1,1,1,1)
|
||||
buff.timer:SetJustifyH("CENTER")
|
||||
buff.timer:SetJustifyV("CENTER")
|
||||
|
||||
buff.stacks = buff.overlay:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
buff.stacks:SetTextColor(1,1,1,1)
|
||||
buff.stacks:SetJustifyH("RIGHT")
|
||||
buff.stacks:SetJustifyV("BOTTOM")
|
||||
buff.stacks:SetAllPoints(buff)
|
||||
|
||||
-- radial sweep (the template covers the button and starts hidden).
|
||||
-- RefreshBuffButton drives it through the frame's own methods, never
|
||||
-- CooldownFrame_SetTimer, so the cooldown module's hook leaves it alone;
|
||||
-- text stays with buff.timer, so the frame's own numbers are hidden
|
||||
buff.cd = CreateFrame("Cooldown", buttonName .. "Cooldown", buff, "CooldownFrameTemplate")
|
||||
buff.cd:SetHideCountdownNumbers(true)
|
||||
-- the sweep and the duration numbers (the template covers the button and
|
||||
-- starts hidden); RefreshBuffButton starts its timer
|
||||
buff.cd = CreateCooldown(buff, "buff", buttonName .. "Cooldown")
|
||||
buff.cd:SetFrameLevel(buff:GetFrameLevel() + 1)
|
||||
buff.overlay:SetFrameLevel(buff:GetFrameLevel() + 2)
|
||||
|
||||
@@ -230,66 +232,24 @@ pfUI:RegisterModule("buff", function ()
|
||||
end
|
||||
end)
|
||||
|
||||
-- PERF: Consolidated OnUpdate handler for all buff timers
|
||||
-- This replaces 50 individual OnUpdate handlers with a single one
|
||||
-- the buttons that can show a weapon enchant: the first two buffs, or the
|
||||
-- separate weapon buttons
|
||||
local weaponButtons
|
||||
|
||||
-- weapon enchants, see RefreshWeaponButton
|
||||
pfUI.buff:SetScript("OnUpdate", function()
|
||||
local now = GetTime()
|
||||
if not this.nextUpdate then this.nextUpdate = now + 0.1 end
|
||||
if this.nextUpdate > now then return end
|
||||
this.nextUpdate = now + 0.1
|
||||
|
||||
-- Cache weapon enchant info once per update cycle
|
||||
local mh, mhtime, mhcharge, oh, ohtime, ohcharge = GetWeaponEnchantInfo()
|
||||
|
||||
-- Update all visible buff buttons
|
||||
local buttons = pfUI.buff.buffs.buttons
|
||||
for i = 1, 32 do
|
||||
local buff = buttons[i]
|
||||
local _, mhtime, mhcharge, _, ohtime, ohcharge = GetWeaponEnchantInfo()
|
||||
for _, buff in ipairs(weaponButtons) do
|
||||
if buff:IsShown() then
|
||||
local timeleft, stacks = 0, 0
|
||||
if buff.mode == buff.btype then
|
||||
timeleft = buff.expirationTime > 0 and (buff.expirationTime - now) or 0
|
||||
stacks = buff.stackCount or 0
|
||||
elseif buff.mode == "MAINHAND" then
|
||||
timeleft = mhtime and mhtime / 1000 or 0
|
||||
stacks = mhcharge or 0
|
||||
if buff.mode == "MAINHAND" then
|
||||
RefreshWeaponButton(buff, mhtime, mhcharge)
|
||||
elseif buff.mode == "OFFHAND" then
|
||||
timeleft = ohtime and ohtime / 1000 or 0
|
||||
stacks = ohcharge or 0
|
||||
end
|
||||
buff.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
||||
buff.stacks:SetText(stacks > 1 and stacks or "")
|
||||
end
|
||||
end
|
||||
|
||||
-- Update all visible debuff buttons
|
||||
buttons = pfUI.buff.debuffs.buttons
|
||||
for i = 1, 16 do
|
||||
local buff = buttons[i]
|
||||
if buff:IsShown() then
|
||||
local timeleft = buff.expirationTime > 0 and (buff.expirationTime - now) or 0
|
||||
local stacks = buff.stackCount or 0
|
||||
buff.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
||||
buff.stacks:SetText(stacks > 1 and stacks or "")
|
||||
end
|
||||
end
|
||||
|
||||
-- Update weapon buff buttons if separate
|
||||
if C.buffs.separateweapons == "1" then
|
||||
buttons = pfUI.buff.wepbuffs.buttons
|
||||
for i = 1, 2 do
|
||||
local buff = buttons[i]
|
||||
if buff:IsShown() then
|
||||
local timeleft, stacks = 0, 0
|
||||
if buff.mode == "MAINHAND" then
|
||||
timeleft = mhtime and mhtime / 1000 or 0
|
||||
stacks = mhcharge or 0
|
||||
elseif buff.mode == "OFFHAND" then
|
||||
timeleft = ohtime and ohtime / 1000 or 0
|
||||
stacks = ohcharge or 0
|
||||
end
|
||||
buff.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
||||
buff.stacks:SetText(stacks > 1 and stacks or "")
|
||||
RefreshWeaponButton(buff, ohtime, ohcharge)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -320,53 +280,55 @@ pfUI:RegisterModule("buff", function ()
|
||||
pfUI.buff.debuffs.buttons[i] = CreateBuffButton(i, "HARMFUL")
|
||||
end
|
||||
|
||||
weaponButtons = {
|
||||
pfUI.buff.buffs.buttons[1], pfUI.buff.buffs.buttons[2],
|
||||
pfUI.buff.wepbuffs.buttons[1], pfUI.buff.wepbuffs.buttons[2],
|
||||
}
|
||||
|
||||
-- config loading
|
||||
function pfUI.buff:UpdateConfigBuffButton(buff)
|
||||
local fontsize = C.buffs.fontsize == "-1" and C.global.font_size or C.buffs.fontsize
|
||||
local buffSize, buffSpacing = tonumber(C.buffs.size), tonumber(C.buffs.spacing)
|
||||
local rowextra = C.buffs.textinside == "1" and 0 or GetCooldownFontSize(buffSize) * 1.5
|
||||
local rowcount, relFrame, offsetX, offsetY
|
||||
if buff.btype == "HELPFUL" then
|
||||
if buff.weapon == 1 and C.buffs.separateweapons == "1" then
|
||||
rowcount = floor((buff.gid-1) / tonumber(C.buffs.wepbuffrowsize))
|
||||
relFrame = pfUI.buff.wepbuffs
|
||||
offsetX = -(buff.gid-1-rowcount*tonumber(C.buffs.wepbuffrowsize))*(buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * ((C.buffs.textinside == "1" and 0 or (fontsize*1.5))+buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * (rowextra+buffSize+2*buffSpacing)
|
||||
else
|
||||
rowcount = floor((buff.gid-1) / tonumber(C.buffs.buffrowsize))
|
||||
relFrame = pfUI.buff.buffs
|
||||
offsetX = -(buff.gid-1-rowcount*tonumber(C.buffs.buffrowsize))*(buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * ((C.buffs.textinside == "1" and 0 or (fontsize*1.5))+buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * (rowextra+buffSize+2*buffSpacing)
|
||||
end
|
||||
else
|
||||
rowcount = floor((buff.gid-1) / tonumber(C.buffs.debuffrowsize))
|
||||
relFrame = pfUI.buff.debuffs
|
||||
offsetX = -(buff.gid-1-rowcount*tonumber(C.buffs.debuffrowsize))*(buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * ((C.buffs.textinside == "1" and 0 or (fontsize*1.5))+buffSize+2*buffSpacing)
|
||||
offsetY = -(rowcount) * (rowextra+buffSize+2*buffSpacing)
|
||||
end
|
||||
buff:SetSize(buffSize, buffSize)
|
||||
buff.cd:SetReverse(C.buffs.cooldown_reverse == "1")
|
||||
buff:ClearAllPoints()
|
||||
buff:SetPoint("TOPRIGHT", relFrame, "TOPRIGHT",offsetX, offsetY)
|
||||
|
||||
buff.timer:SetFont(pfUI.font_default, fontsize, "OUTLINE")
|
||||
buff.stacks:SetFont(pfUI.font_default, fontsize+1, "OUTLINE")
|
||||
|
||||
buff.timer:SetHeight(fontsize * 1.3)
|
||||
|
||||
buff.timer:ClearAllPoints()
|
||||
-- the duration numbers sit inside the icon or below it
|
||||
local countdown = buff.cd:GetCountdownFontString()
|
||||
countdown:ClearAllPoints()
|
||||
if C.buffs.textinside == "1" then
|
||||
buff.timer:SetAllPoints(buff)
|
||||
countdown:SetPoint("CENTER", buff, "CENTER", 0, 0)
|
||||
else
|
||||
buff.timer:SetPoint("TOP", buff, "BOTTOM", 0, -3)
|
||||
countdown:SetPoint("TOP", buff, "BOTTOM", 0, -3)
|
||||
end
|
||||
end
|
||||
|
||||
function pfUI.buff:UpdateConfig()
|
||||
local fontsize = C.buffs.fontsize == "-1" and C.global.font_size or C.buffs.fontsize
|
||||
|
||||
local spacing = tonumber(C.buffs.spacing)
|
||||
local cell = tonumber(C.buffs.size) + 2 * spacing
|
||||
local rowextra = C.buffs.textinside == "1" and 0 or (fontsize * 1.5)
|
||||
local rowextra = C.buffs.textinside == "1" and 0 or GetCooldownFontSize(tonumber(C.buffs.size)) * 1.5
|
||||
|
||||
local function SizeBuffFrame(frame, rowsize, count)
|
||||
rowsize = tonumber(rowsize)
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
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)
|
||||
+45
-32
@@ -1597,22 +1597,51 @@ pfUI:RegisterModule("gui", function ()
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Settings"], T["Cooldown"], function()
|
||||
-- every kind of cooldown CreateCooldown makes, as C.cooldown groups.
|
||||
-- Other addons' cooldowns only lose numbers or sweep (see
|
||||
-- api/cooldown.lua), so giving them back takes a reload
|
||||
local kinds = {
|
||||
{ "actionbar", T["Action Bars"] },
|
||||
{ "bags", T["Bags"] },
|
||||
{ "blizzard", T["Spellbook And Character"] },
|
||||
{ "unitframe", T["Unit Frame Auras"] },
|
||||
{ "indicator", T["Buff Indicators"] },
|
||||
{ "nameplate", T["Nameplate Debuffs"] },
|
||||
{ "buff", T["Player Buffs"] },
|
||||
{ "tooltip", T["Tooltip Auras"] },
|
||||
{ "totem", T["Totems"] },
|
||||
{ "lossofcontrol", T["Loss Of Control"] },
|
||||
{ "foreign", T["Other Addons"] },
|
||||
}
|
||||
|
||||
CreateConfig(nil, COUNTDOWN_FOR_COOLDOWNS_TEXT, "CVAR", "countdownForCooldowns", "checkbox")
|
||||
CreateConfig(U["buff"], T["Show Milliseconds When Timer Runs Out"], C.appearance.cd, "milliseconds", "checkbox")
|
||||
CreateConfig(nil, T["Cooldown Color (Less than 3 Sec)"], C.appearance.cd, "lowcolor", "color")
|
||||
CreateConfig(nil, T["Cooldown Color (Seconds)"], C.appearance.cd, "normalcolor", "color")
|
||||
CreateConfig(nil, T["Cooldown Color (Minutes)"], C.appearance.cd, "minutecolor", "color")
|
||||
CreateConfig(nil, T["Cooldown Color (Hours)"], C.appearance.cd, "hourcolor", "color")
|
||||
CreateConfig(nil, T["Cooldown Color (Days)"], C.appearance.cd, "daycolor", "color")
|
||||
CreateConfig(nil, T["Use Dynamic Font Size"], C.appearance.cd, "dynamicsize", "checkbox")
|
||||
CreateConfig(nil, T["Cooldown Text Font"], C.appearance.cd, "font", "dropdown", pfUI.gui.dropdowns.fonts)
|
||||
CreateConfig(nil, T["Cooldown Text Font Size"], C.appearance.cd, "font_size")
|
||||
CreateConfig(nil, T["Cooldown Text Font Size (Blizzard Frames)"], C.appearance.cd, "font_size_blizz")
|
||||
CreateConfig(nil, T["Cooldown Text Font Size (Foreign Frames)"], C.appearance.cd, "font_size_foreign")
|
||||
CreateConfig(nil, T["Cooldown Text Time Threshold"], C.appearance.cd, "threshold")
|
||||
CreateConfig(nil, T["Enable Durations On Blizzard Frames"], C.appearance.cd, "blizzard", "checkbox")
|
||||
CreateConfig(nil, T["Enable Durations On Foreign Frames"], C.appearance.cd, "foreign", "checkbox")
|
||||
CreateConfig(nil, T["Hide Foreign Cooldown Animations"], C.appearance.cd, "hideanim", "checkbox")
|
||||
CreateConfig(UpdateCooldowns, T["Font"], C.cooldown, "font", "dropdown", pfUI.gui.dropdowns.fonts)
|
||||
CreateConfig(nil, T["Font Size"], C.cooldown, "font_size")
|
||||
CreateConfig(nil, T["Scale Font Size With Icon"], C.cooldown, "dynamicsize", "checkbox")
|
||||
CreateConfig(UpdateCooldowns, T["Hide Numbers On Spell Cooldowns Up To (Seconds)"], C.cooldown, "threshold")
|
||||
CreateConfig(UpdateCooldowns, T["Show Tenths Below 5 Seconds"], C.cooldown, "milliseconds", "checkbox")
|
||||
CreateConfig(UpdateCooldowns, T["Cooldown Color (5 Seconds Or Less)"], C.cooldown, "lowcolor", "color")
|
||||
CreateConfig(UpdateCooldowns, T["Cooldown Color (Seconds)"], C.cooldown, "normalcolor", "color")
|
||||
CreateConfig(UpdateCooldowns, T["Cooldown Color (Minutes)"], C.cooldown, "minutecolor", "color")
|
||||
CreateConfig(UpdateCooldowns, T["Cooldown Color (Hours)"], C.cooldown, "hourcolor", "color")
|
||||
CreateConfig(UpdateCooldowns, T["Cooldown Color (Days)"], C.cooldown, "daycolor", "color")
|
||||
|
||||
CreateConfig(nil, T["Show Numbers On"], nil, nil, "header")
|
||||
for _, kind in ipairs(kinds) do
|
||||
CreateConfig(kind[1] ~= "foreign" and UpdateCooldowns or nil, kind[2], C.cooldown[kind[1]], "text", "checkbox")
|
||||
end
|
||||
|
||||
CreateConfig(nil, T["Show Sweep On"], nil, nil, "header")
|
||||
for _, kind in ipairs(kinds) do
|
||||
CreateConfig(kind[1] ~= "foreign" and UpdateCooldowns or nil, kind[2], C.cooldown[kind[1]], "animation", "checkbox")
|
||||
end
|
||||
|
||||
CreateConfig(nil, T["Reverse Sweep On"], nil, nil, "header")
|
||||
for _, kind in ipairs(kinds) do
|
||||
if kind[1] ~= "foreign" then
|
||||
CreateConfig(UpdateCooldowns, kind[2], C.cooldown[kind[1]], "reverse", "checkbox")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Settings"], T["Screenshot"], function()
|
||||
@@ -2325,11 +2354,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(U[c], T["Automatic Level Text Color"], C.unitframes[c], "levelcolor", "checkbox")
|
||||
CreateConfig(U[c], T["Automatic Class Text Color"], C.unitframes[c], "classcolor", "checkbox")
|
||||
|
||||
CreateConfig(U[c], T["Timer"], nil, nil, "header")
|
||||
CreateConfig(U[c], T["Show Timer Text"], C.unitframes[c], "cooldown_text", "checkbox")
|
||||
CreateConfig(U[c], T["Show Timer Animation"], C.unitframes[c], "cooldown_anim", "checkbox")
|
||||
CreateConfig(U[c], T["Reverse Timer Animation"], C.unitframes[c], "cooldown_reverse", "checkbox")
|
||||
|
||||
CreateConfig(U[c], T["Buffs"], nil, nil, "header")
|
||||
CreateConfig(U[c], T["Buff Position"], C.unitframes[c], "buffs", "dropdown", pfUI.gui.dropdowns.uf_buff_position)
|
||||
CreateConfig(U[c], T["Buff Size"], C.unitframes[c], "buffsize")
|
||||
@@ -2359,7 +2383,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
|
||||
CreateConfig(U[c], T["Buff/Debuff Indicators"], nil, nil, "header")
|
||||
CreateConfig(U[c], T["Enable Indicators"], C.unitframes[c], "buff_indicator", "checkbox")
|
||||
CreateConfig(U[c], T["Show Time Left"], C.unitframes[c], "indicator_time", "checkbox")
|
||||
CreateConfig(U[c], T["Show Stacks"], C.unitframes[c], "indicator_stacks", "checkbox")
|
||||
CreateConfig(U[c], T["Indicator Size"], C.unitframes[c], "indicator_size")
|
||||
CreateConfig(U[c], T["Indicator Spacing"], C.unitframes[c], "indicator_spacing", "dropdown", pfUI.gui.dropdowns.spacing)
|
||||
@@ -2447,7 +2470,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(nil, T["Bagslots Per Row"], C.appearance.bags, "bagrowlength")
|
||||
CreateConfig(nil, T["Bankslots Per Row"], C.appearance.bags, "bankrowlength")
|
||||
CreateConfig(nil, T["Item Slot Size"], C.appearance.bags, "icon_size")
|
||||
CreateConfig(Reload, T["Reverse Cooldown Animation"], C.appearance.bags, "cooldown_reverse", "checkbox")
|
||||
CreateConfig(nil, T["Auto Sell Grey Items"], C.global, "autosell", "checkbox")
|
||||
CreateConfig(nil, T["Auto Repair Items"], C.global, "autorepair", "checkbox")
|
||||
CreateConfig(nil, T["Auto Sort When Opening Bags"], C.appearance.bags, "autoSortOnOpen", "checkbox")
|
||||
@@ -2497,9 +2519,7 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(U["buff"], T["Number Of Buffs Per Row"], C.buffs, "buffrowsize")
|
||||
CreateConfig(U["buff"], T["Number Of Debuffs Per Row"], C.buffs, "debuffrowsize")
|
||||
CreateConfig(U["buff"], T["Show Duration Inside Buff"], C.buffs, "textinside", "checkbox")
|
||||
CreateConfig(U["buff"], T["Buff Font Size"], C.buffs, "fontsize")
|
||||
CreateConfig(U["buff"], T["Show Timer Animation"], C.buffs, "cooldown_anim", "checkbox")
|
||||
CreateConfig(U["buff"], T["Reverse Timer Animation"], C.buffs, "cooldown_reverse", "checkbox")
|
||||
CreateConfig(U["buff"], T["Stack Count Font Size"], C.buffs, "fontsize")
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Buffs"], T["Totem Icons"], function()
|
||||
@@ -2507,7 +2527,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(U["totems"], T["Icon Size"], C.totems, "iconsize")
|
||||
CreateConfig(U["totems"], T["Spacing"], C.totems, "spacing", "dropdown", pfUI.gui.dropdowns.spacing)
|
||||
CreateConfig(U["totems"], T["Show Background"], C.totems, "showbg", "checkbox")
|
||||
CreateConfig(U["totems"], T["Reverse Cooldown Animation"], C.totems, "cooldown_reverse", "checkbox")
|
||||
end)
|
||||
|
||||
CreateGUIEntry(T["Buffs"], T["Player Buff Bar"], function()
|
||||
@@ -2596,8 +2615,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(U["bars"], T["Item Count Text Color"], C.bars, "count_color", "color")
|
||||
CreateConfig(U["bars"], T["Keybind Text Size"], C.bars, "bind_size")
|
||||
CreateConfig(U["bars"], T["Keybind Text Color"], C.bars, "bind_color", "color")
|
||||
CreateConfig(nil, T["Cooldown Text Size"], C.bars, "cd_size")
|
||||
CreateConfig(Reload, T["Reverse Cooldown Animation"], C.bars, "cooldown_reverse", "checkbox")
|
||||
|
||||
CreateConfig(nil, T["Auto Paging"], nil, nil, "header")
|
||||
CreateConfig(U["bars"], T["Switch Pages On Alt Key Press"], C.bars, "pagemasteralt", "checkbox")
|
||||
@@ -2968,10 +2985,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
CreateConfig(U["nameplates"], T["Debuff Icon Offset"], C.nameplates, "debuffoffset")
|
||||
CreateConfig(U["nameplates"], T["Debuff Icon Size"], C.nameplates, "debuffsize")
|
||||
CreateConfig(U["nameplates"], T["Show Debuff Stacks"], C.nameplates.debuffs, "showstacks", "checkbox")
|
||||
CreateConfig(U["nameplates"], T["Enable Debuff Timers"], C.nameplates, "debufftimers", "checkbox")
|
||||
CreateConfig(U["nameplates"], T["Show Timer Text"], C.nameplates, "debufftext", "checkbox")
|
||||
CreateConfig(U["nameplates"], T["Show Timer Animation"], C.nameplates, "debuffanim", "checkbox")
|
||||
CreateConfig(U["nameplates"], T["Reverse Timer Animation"], C.nameplates, "debreverse", "checkbox")
|
||||
|
||||
CreateConfig(U["nameplates"], T["Filter Mode"], C.nameplates.debuffs, "filter", "dropdown", pfUI.gui.dropdowns.buffbarfilter)
|
||||
CreateConfig(U["nameplates"], T["Blacklist"], C.nameplates.debuffs, "blacklist", "list")
|
||||
|
||||
@@ -34,10 +34,8 @@ pfUI:RegisterModule("lossofcontrol", function ()
|
||||
frame.icon.tex = frame.icon:CreateTexture(nil, "ARTWORK")
|
||||
HandleIcon(frame.icon, frame.icon.tex)
|
||||
|
||||
frame.cd = CreateFrame("Cooldown", nil, frame.icon, "CooldownFrameTemplate")
|
||||
frame.cd = CreateCooldown(frame.icon, "lossofcontrol")
|
||||
frame.cd:SetAllPoints(frame.icon.tex)
|
||||
frame.cd.pfCooldownStyleAnimation = 1
|
||||
frame.cd.pfCooldownType = "ALL"
|
||||
|
||||
frame.label = frame:CreateFontString(nil, "OVERLAY")
|
||||
frame.label:SetFont(pfUI.font_default, 20, "OUTLINE")
|
||||
|
||||
+2
-17
@@ -155,8 +155,6 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
cfg.use_unitfonts = C.nameplates.use_unitfonts == "1"
|
||||
cfg.font_size = cfg.use_unitfonts and C.global.font_unit_size or C.global.font_size
|
||||
cfg.hptextformat = C.nameplates.hptextformat
|
||||
-- NEW: Cache debuff config
|
||||
cfg.debufftimers = C.nameplates.debufftimers == "1"
|
||||
|
||||
-- Throttle delays, resolved once instead of per plate per tick.
|
||||
-- libthrottle:Get walks the saved-variable table, a defaults fallback and a
|
||||
@@ -438,11 +436,8 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
plate.debuffs[index].stacks:SetJustifyV("BOTTOM")
|
||||
plate.debuffs[index].stacks:SetTextColor(1,1,0)
|
||||
|
||||
plate.debuffs[index].cd = CreateFrame("Cooldown", plate.platename.."Debuff"..index.."Cooldown", plate.debuffs[index], "CooldownFrameTemplate")
|
||||
plate.debuffs[index].cd = CreateCooldown(plate.debuffs[index], "nameplate", plate.platename.."Debuff"..index.."Cooldown")
|
||||
plate.debuffs[index].cd:SetFrameLevel(6)
|
||||
-- the display settings come from UpdateDebuffConfig, which runs for
|
||||
-- every new icon before its first timer
|
||||
plate.debuffs[index].cd.pfCooldownType = "ALL"
|
||||
end
|
||||
|
||||
local function UpdateDebuffConfig(nameplate, i)
|
||||
@@ -475,16 +470,6 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
end
|
||||
|
||||
nameplate.debuffs[i]:SetSize(debuffsize, debuffsize)
|
||||
|
||||
-- Update cooldown display settings
|
||||
local cd = nameplate.debuffs[i].cd
|
||||
cd.pfCooldownStyleText = tonumber(C.nameplates.debufftext) or 1
|
||||
cd.pfCooldownStyleAnimation = tonumber(C.nameplates.debuffanim) or 0
|
||||
-- the draw flags, not alpha: the plate's SetAlpha copies its alpha down
|
||||
-- to every child (ClassicAPI keeps 1.12's alpha under default plates)
|
||||
cd:SetDrawSwipe(C.nameplates.debuffanim == "1")
|
||||
cd:SetDrawBling(C.nameplates.debuffanim == "1")
|
||||
cd:SetReverse(C.nameplates.debreverse == "1")
|
||||
end
|
||||
|
||||
-- create nameplate core
|
||||
@@ -1376,7 +1361,7 @@ nameplates:RegisterUnitEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE", "target", "focu
|
||||
plate.debuffs[index].stacks:Hide()
|
||||
end
|
||||
|
||||
if duration and timeleft and cfg.debufftimers then
|
||||
if duration and timeleft then
|
||||
-- C_UnitAuras returns the Spell.dbc base duration, which talents
|
||||
-- can extend past — Shadow Affinity bumps SW:P from 18s to 24s,
|
||||
-- so a fresh cast has timeleft > duration and `now + timeleft -
|
||||
|
||||
+4
-20
@@ -216,10 +216,7 @@ pfUI:RegisterModule("tooltip", function ()
|
||||
icon.stacks:SetFont(C.tooltip.font_tooltip, C.tooltip.font_tooltip_size, "OUTLINE")
|
||||
icon.stacks:SetTextColor(1, 1, 1, 1)
|
||||
|
||||
icon.timer = icon:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
||||
icon.timer:SetPoint("CENTER", icon, "CENTER", 0, 0)
|
||||
icon.timer:SetFont(C.tooltip.font_tooltip, C.tooltip.font_tooltip_size, "OUTLINE")
|
||||
icon.timer:SetTextColor(1, 1, 1, 1)
|
||||
icon.cd = CreateCooldown(icon, "tooltip")
|
||||
return icon
|
||||
end
|
||||
|
||||
@@ -228,18 +225,6 @@ pfUI:RegisterModule("tooltip", function ()
|
||||
icon:ClearAllPoints()
|
||||
end)
|
||||
|
||||
-- Tick the remaining-time text on the visible icons. OnUpdate only fires
|
||||
-- while the row is shown, so it stops as soon as the tooltip hides.
|
||||
pfUI.tooltip.buffs:SetScript("OnUpdate", function()
|
||||
local now = GetTime()
|
||||
if (this.tick or 0) > now then return end
|
||||
this.tick = now + 0.1
|
||||
for icon in pfUI.tooltip.buffpool:EnumerateActive() do
|
||||
local timeleft = icon.expirationTime and icon.expirationTime > 0 and (icon.expirationTime - now) or 0
|
||||
icon.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
||||
end
|
||||
end)
|
||||
|
||||
function pfUI.tooltip:UpdateBuffs(unit)
|
||||
pfUI.tooltip.buffpool:ReleaseAll()
|
||||
|
||||
@@ -253,7 +238,7 @@ pfUI:RegisterModule("tooltip", function ()
|
||||
-- table and no per-index re-walk of the aura array
|
||||
local n = ScanAuraSlots(unit, "HELPFUL", auraSlots, BUFF_MAX)
|
||||
for i = 1, n do
|
||||
local name, texture, applications, _, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unit, auraSlots[i])
|
||||
local name, texture, applications, _, duration, expirationTime = C_UnitAuras.UnitAuraBySlot(unit, auraSlots[i])
|
||||
if not name then break end
|
||||
|
||||
count = count + 1
|
||||
@@ -261,9 +246,8 @@ pfUI:RegisterModule("tooltip", function ()
|
||||
icon.texture:SetTexture(texture)
|
||||
icon.stacks:SetText(applications and applications > 1 and applications or "")
|
||||
|
||||
icon.expirationTime = expirationTime
|
||||
local timeleft = expirationTime and expirationTime > 0 and (expirationTime - GetTime()) or 0
|
||||
icon.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
||||
local start, dur = GetAuraTimer(duration, expirationTime)
|
||||
CooldownFrame_SetTimer(icon.cd, start, dur, dur > 0 and 1 or 0)
|
||||
|
||||
if prev then
|
||||
icon:SetPoint("LEFT", prev, "RIGHT", BUFF_SPACING, 0)
|
||||
|
||||
+1
-4
@@ -113,10 +113,7 @@ pfUI:RegisterModule("totems", function ()
|
||||
self.bar[i].cdbg = self.bar[i].cdbg or CreateFrame("Frame", nil, self.bar[i])
|
||||
self.bar[i].cdbg:SetSize(self.iconsize - 3, self.iconsize - 3)
|
||||
self.bar[i].cdbg:SetPoint("CENTER", self.bar[i], "CENTER", 0, 0)
|
||||
self.bar[i].cd = self.bar[i].cd or CreateFrame("Cooldown", "pfTotemsBar"..i.."Cooldown", self.bar[i].cdbg, "CooldownFrameTemplate")
|
||||
self.bar[i].cd.pfCooldownStyleAnimation = 1
|
||||
self.bar[i].cd:SetReverse(pfUI_config.totems.cooldown_reverse == "1")
|
||||
self.bar[i].cd.pfCooldownType = "ALL"
|
||||
self.bar[i].cd = self.bar[i].cd or CreateCooldown(self.bar[i].cdbg, "totem", "pfTotemsBar"..i.."Cooldown")
|
||||
|
||||
self.bar[i]:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||
self.bar[i]:SetScript("OnClick", self.OnClick)
|
||||
|
||||
Reference in New Issue
Block a user