diff --git a/api/unitframes.lua b/api/unitframes.lua index cf6e59e8..e04c350f 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -78,10 +78,6 @@ local glow2 = { insets = {left = 0, right = 0, top = 0, bottom = 0}, } -local function DoNothing() - return -end - local function BuffOnEnter() local parent = this:GetParent() if not parent.label then return end @@ -788,25 +784,7 @@ function pfUI.uf:UpdateConfig() f.buffs[i]:SetSize(f.config.buffsize, f.config.buffsize) - -- Create CD frame if it doesn't exist - if not f.buffs[i].cd then - if cooldown_anim == 1 then - -- Animation enabled: Use Model frame with CooldownFrameTemplate - f.buffs[i].cd = CreateFrame("Model", f.buffs[i]:GetName() .. "Cooldown", f.buffs[i], "CooldownFrameTemplate") - else - -- Animation disabled: Use regular Frame with dummy functions - f.buffs[i].cd = CreateFrame("Frame", f.buffs[i]:GetName() .. "Cooldown", f.buffs[i]) - f.buffs[i].cd.AdvanceTime = DoNothing - f.buffs[i].cd.SetSequence = DoNothing - f.buffs[i].cd.SetSequenceTime = DoNothing - end - end - - -- Always update CD properties (in case size changed) - local cdScale = f.config.buffsize / 32 - f.buffs[i].cd:ClearAllPoints() - f.buffs[i].cd:SetScale(cdScale) - f.buffs[i].cd:SetAllPoints(f.buffs[i]) + f.buffs[i].cd = f.buffs[i].cd or CreateFrame("Cooldown", f.buffs[i]:GetName() .. "Cooldown", f.buffs[i], "CooldownFrameTemplate") f.buffs[i].cd:SetFrameLevel(14) f.buffs[i].cd.pfCooldownType = "ALL" f.buffs[i].cd.pfCooldownStyleText = cooldown_text @@ -861,25 +839,7 @@ function pfUI.uf:UpdateConfig() f.debuffs[i]:SetSize(f.config.debuffsize, f.config.debuffsize) f.debuffs[i]:SetNormalTexture(nil) - -- Create CD frame if it doesn't exist - if not f.debuffs[i].cd then - if cooldown_anim == 1 then - -- Animation enabled: Use Model frame with CooldownFrameTemplate - f.debuffs[i].cd = CreateFrame("Model", f.debuffs[i]:GetName() .. "Cooldown", f.debuffs[i], "CooldownFrameTemplate") - else - -- Animation disabled: Use regular Frame with dummy functions - f.debuffs[i].cd = CreateFrame("Frame", f.debuffs[i]:GetName() .. "Cooldown", f.debuffs[i]) - f.debuffs[i].cd.AdvanceTime = DoNothing - f.debuffs[i].cd.SetSequence = DoNothing - f.debuffs[i].cd.SetSequenceTime = DoNothing - end - end - - -- Always update CD properties (in case size changed) - local cdScale = f.config.debuffsize / 32 - f.debuffs[i].cd:ClearAllPoints() - f.debuffs[i].cd:SetScale(cdScale) - f.debuffs[i].cd:SetAllPoints(f.debuffs[i]) + f.debuffs[i].cd = f.debuffs[i].cd or CreateFrame("Cooldown", f.debuffs[i]:GetName() .. "Cooldown", f.debuffs[i], "CooldownFrameTemplate") f.debuffs[i].cd:SetFrameLevel(14) f.debuffs[i].cd.pfCooldownType = "ALL" f.debuffs[i].cd.pfCooldownStyleText = cooldown_text @@ -2318,17 +2278,7 @@ function pfUI.uf:AddIcon(frame, pos, icon, timeleft, stacks, start, duration) frame.icon[pos].stacks:SetJustifyH("RIGHT") frame.icon[pos].stacks:SetJustifyV("BOTTOM") - -- Check if parent frame has cooldown animation enabled - local parent_cooldown_anim = frame.config and tonumber(frame.config.cooldown_anim) or 1 - if parent_cooldown_anim == 1 then - frame.icon[pos].cd = CreateFrame("Model", nil, frame.icon[pos]) - else - frame.icon[pos].cd = CreateFrame("Frame", nil, frame.icon[pos]) - frame.icon[pos].cd.AdvanceTime = DoNothing - frame.icon[pos].cd.SetSequence = DoNothing - frame.icon[pos].cd.SetSequenceTime = DoNothing - end - + frame.icon[pos].cd = CreateFrame("Cooldown", nil, frame.icon[pos], "CooldownFrameTemplate") frame.icon[pos].cd.pfCooldownStyleAnimation = 0 frame.icon[pos].cd.pfCooldownType = "ALL" frame.icon[pos].cd:SetFrameLevel(48) diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 9e752c91..c1aba5a0 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -1008,7 +1008,7 @@ pfUI:RegisterModule("actionbar", function () f.slot = id -- cooldown - f.cd = CreateFrame("Model", f:GetName() .. "Cooldown", f, "CooldownFrameTemplate") + f.cd = CreateFrame("Cooldown", f:GetName() .. "Cooldown", f, "CooldownFrameTemplate") f.cd.pfCooldownStyleAnimation = 1 f.cd.pfCooldownType = "NOGCD" f.cd.pfCooldownSize = cd_size diff --git a/modules/bags.lua b/modules/bags.lua index c468920c..a2942b2c 100644 --- a/modules/bags.lua +++ b/modules/bags.lua @@ -396,14 +396,13 @@ pfUI:RegisterModule("bags", function () if tpl == "BankItemButtonGenericTemplate" then local bankslot = pfUI.bags[bag].slots[slot].frame local name = "pfBag" .. bag .. "item" .. slot .. "Cooldown" - bankslot.cd = CreateFrame("Model", name, bankslot, "CooldownFrameTemplate") - bankslot.cd:SetAllPoints(bankslot) + bankslot.cd = CreateFrame("Cooldown", name, bankslot, "CooldownFrameTemplate") bankslot.cd.pfCooldownStyleAnimation = 1 - bankslot.cd.pfCooldownType = "ALL" + bankslot.cd.pfCooldownType = "NOGCD" else local bagslot = pfUI.bags[bag].slots[slot].frame bagslot.cd = _G[bagslot:GetName().."Cooldown"] - bagslot.cd.pfCooldownType = "ALL" + bagslot.cd.pfCooldownType = "NOGCD" end if not pfUI.bags[bag].slots[slot].frame.backdrop then diff --git a/modules/cooldown.lua b/modules/cooldown.lua index 1f42db37..08177ba0 100644 --- a/modules/cooldown.lua +++ b/modules/cooldown.lua @@ -104,8 +104,10 @@ pfUI:RegisterModule("cooldown", function () return end - -- realign cooldown frames - local parent = this.GetParent and this:GetParent() + -- realign the indicator Models that stock buttons build; the model is + -- drawn at 36px and needs scaling to its button. A Cooldown draws its + -- sweep to its own rect. + local parent = this.GetParent and not this:IsObjectType("Cooldown") and this:GetParent() if parent and parent:GetWidth() / 36 > 0 then this:SetScale(parent:GetWidth() / 36) this:SetPoint("TOPLEFT", parent, "TOPLEFT", -1, 1) @@ -144,7 +146,7 @@ pfUI:RegisterModule("cooldown", function () end end - -- vanilla does not have a cooldown frame type, so we hook the - -- regular SetTimer function that each one is calling. + -- hook the SetTimer function that every cooldown, Cooldown frame or + -- stock indicator Model, is driven through. hooksecurefunc("CooldownFrame_SetTimer", SetCooldown) end) \ No newline at end of file diff --git a/modules/nameplates.lua b/modules/nameplates.lua index f7144f0a..fe9140e1 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -280,10 +280,6 @@ pfUI:RegisterModule("nameplates", function () return color end - local function DoNothing() - return - end - local function DisableObject(object) if not object then return end if not object.GetObjectType then return end @@ -437,22 +433,8 @@ pfUI:RegisterModule("nameplates", function () plate.debuffs[index].stacks:SetJustifyV("BOTTOM") plate.debuffs[index].stacks:SetTextColor(1,1,0) - -- PERF: Use lightweight fake cooldown frame when animation disabled - -- The Model-based CooldownFrameTemplate causes major lag with many nameplates - if cfg.debuffanim ~= 1 then - plate.debuffs[index].cd = CreateFrame("Frame", plate.platename.."Debuff"..index.."Cooldown", plate.debuffs[index]) - plate.debuffs[index].cd:SetAllPoints(plate.debuffs[index]) - plate.debuffs[index].cd:SetFrameLevel(6) - plate.debuffs[index].cd:SetScript("OnUpdate", CooldownFrame_OnUpdateModel) - plate.debuffs[index].cd.AdvanceTime = DoNothing - plate.debuffs[index].cd.SetSequence = DoNothing - plate.debuffs[index].cd.SetSequenceTime = DoNothing - else - -- Use CooldownFrameTemplate for animation - plate.debuffs[index].cd = CreateFrame("Model", plate.platename.."Debuff"..index.."Cooldown", plate.debuffs[index], "CooldownFrameTemplate") - plate.debuffs[index].cd:SetAllPoints(plate.debuffs[index]) - plate.debuffs[index].cd:SetFrameLevel(6) - end + plate.debuffs[index].cd = CreateFrame("Cooldown", plate.platename.."Debuff"..index.."Cooldown", plate.debuffs[index], "CooldownFrameTemplate") + plate.debuffs[index].cd:SetFrameLevel(6) -- Set initial config flags (will be cached per-cooldown later) plate.debuffs[index].cd.pfCooldownStyleAnimation = cfg.debuffanim diff --git a/modules/totems.lua b/modules/totems.lua index 533d2b18..9ad7991c 100644 --- a/modules/totems.lua +++ b/modules/totems.lua @@ -113,7 +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("Model", "pfTotemsBar"..i.."Cooldown", self.bar[i].cdbg, "CooldownFrameTemplate") + 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.pfCooldownType = "ALL"