-- Buffs Header
frame.buffs = CreateFrame("Frame", "ZPerl2"..name.."BuffFrame", frame, "SecureAuraHeaderTemplate")
frame.buffs:SetPoint("TopLeft", frame, "BottomLeft", 4, -1)
frame.buffs:SetAttribute("useparent-unit", true)
frame.buffs:SetAttribute("filter", "HELPFUL")
frame.buffs:SetAttribute("template", "SecureActionButtonTemplate")
frame.buffs:SetAttribute("minWidth", 24)
frame.buffs:SetAttribute("minHeight", 24)
frame.buffs:SetAttribute("separateOwn", 0)
frame.buffs:SetAttribute("point", "TOPLEFT")
frame.buffs:SetAttribute("xOffset", 24)
frame.buffs:SetAttribute("yOffset", 0)
frame.buffs:SetAttribute("wrapAfter", 8)
frame.buffs:SetAttribute("wrapXOffset", 0)
frame.buffs:SetAttribute("wrapYOffset", -24)
frame.buffs:SetAttribute("maxWraps", 5)
frame.buffs:SetAttribute("sortMethod", "INDEX") -- INDEX or NAME or TIME
frame.buffs:SetAttribute("sortDir", "+") -- - to reverse
frame.buffs:SetAttribute("style-width", 24)
frame.buffs:SetAttribute("style-height", 24)
frame.buffs:SetAttribute("style-scale", 1)
local function CreateBuffFrame(header, frameName)
local buff = _G[frameName]
buff:RegisterForClicks("RightButtonUp")
--buff.unit = header:GetParent():GetAttribute("unit") or frame.unit
--buff.filter = "HELPFUL"
buff.texture = buff:CreateTexture(nil, "Background")
buff.texture:SetAllPoints(buff)
buff.cooldown = CreateFrame("Cooldown", nil, buff, "CooldownFrameTemplate")
buff.cooldown:SetReverse(true)
buff.cooldown:SetDrawEdge(false)
buff.cooldown:SetDrawBling(false)
-- Blizzard
buff.cooldown:SetHideCountdownNumbers(true)
-- OmniCC
buff.cooldown.noCooldownCount = true
buff.cooldown:SetAllPoints(buff)
buff.stack = buff:CreateFontString(nil, "Artwork")
buff.stack:SetFont("Fonts\\ARIALN.TTF", 9, "Outline")
buff.stack:SetPoint("BottomRight", buff, "BottomRight", 0, 2)
buff.stack:SetJustifyH("Center")
buff.stack:SetJustifyV("Center")
buff.stack:SetWordWrap(false)
buff:SetScript("OnAttributeChanged", function(self, name, value)
--print(self:GetName(), name, value)
if name == "index" then
--print(self:GetName(), name, value)
if value then
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, shouldConsolidate, spellId, canApplyAura, isBossDebuff, isCastByPlayer = UnitAura(header:GetParent():GetAttribute("unit"), header:GetAttribute("filter"))
if self.index ~= value or self.spellId ~= spellId or self.count ~= count or self.expirationTime ~= expirationTime then
--[[if self.index ~= value then
print("INDEX", name, self.index, value)
elseif self.spellId ~= spellId then
print("ID", value, name, self.spellId, spellId)
elseif self.count ~= count then
print("COUNT", value, name, self.count, count)
elseif self.expirationTime ~= expirationTime then
print("EXP", value, name, self.expirationTime, expirationTime)
end]]
if type(module.UpdateBuff) == "function" then
module:UpdateBuff(self, value)
end
end
else
self.index = nil
self.spellId = nil
self.count = nil
self.expirationTime = nil
end
end
end)
buff:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT")
GameTooltip:SetFrameLevel(self:GetFrameLevel() + 2)
local s = self.slotID or 0
if s == 16 or s == 17 then
GameTooltip:SetInventoryItem(header:GetParent():GetAttribute("unit"), s)
else
GameTooltip:SetUnitAura(header:GetParent():GetAttribute("unit"), self:GetID(), header:GetAttribute("filter"))
end
self:SetScript("OnUpdate", function(self, elapsed)
self.time = (self.time or 0) + elapsed
if self.time < 0.5 then
return
end
self.time = 0
if GameTooltip:IsOwned(self) then
local s = self.slotID or 0
if s == 16 or s == 17 or s == 18 then
GameTooltip:SetInventoryItem(header:GetParent():GetAttribute("unit"), s)
else
GameTooltip:SetUnitAura(header:GetParent():GetAttribute("unit"), self:GetID(), header:GetAttribute("filter"))
end
end
end)
end)
buff:SetScript("OnLeave", function(self)
self:SetScript("OnUpdate", nil)
GameTooltip:Hide()
end)
return buff
end
frame.buffs:SetAttribute("initialConfigFunction", [[
local header = self:GetParent()
self:SetHeight(header:GetAttribute("style-height"))
self:SetWidth(header:GetAttribute("style-width"))
self:SetScale(header:GetAttribute("style-scale"))
self:SetAttribute("type2", "cancelaura")
self:SetAttribute("isHeaderDriven", true)
header:CallMethod("initialConfigFunction", self:GetName())
]])
frame.buffs.initialConfigFunction = CreateBuffFrame
frame.buffs:Show()