@@ -1553,9 +1553,123 @@ end
15531553
15541554local SecureButton_GetModifiedUnit = SecureButton_GetModifiedUnit -- it's so slow
15551555
1556+ function PlexusFrame :MakePAAnchor (parent , unitToken , index , settings )
1557+ local w = settings .PrivateAuraWidth
1558+ local pad = settings .PrivateAuraPadding or 2
1559+ local slot = w + pad
1560+
1561+ -- Center the row: index 3 is the middle
1562+ local offset = (index - 3 ) * slot
1563+
1564+ if settings .enablePrivateAuraCountdownNumbers then
1565+ return {
1566+ durationAnchor = {
1567+ point = " CENTER" ,
1568+ relativeTo = parent ,
1569+ relativePoint = " CENTER" ,
1570+ offsetX = 2 ,
1571+ offsetY = - 2 ,
1572+ },
1573+ unitToken = unitToken ,
1574+ auraIndex = index ,
1575+ parent = parent ,
1576+ showCountdownFrame = settings .enablePrivateAuraCountdownFrame ,
1577+ showCountdownNumbers = true ,
1578+ iconInfo = {
1579+ iconAnchor = {
1580+ point = " CENTER" ,
1581+ relativeTo = parent ,
1582+ relativePoint = " CENTER" ,
1583+ offsetX = settings .PrivateAuraOffsetX + offset ,
1584+ offsetY = settings .PrivateAuraOffsetY ,
1585+ },
1586+ iconWidth = w ,
1587+ iconHeight = settings .PrivateAuraHeight ,
1588+ borderScale = 1.1 ,
1589+ },
1590+ }
1591+ else
1592+ return {
1593+ -- durationAnchor = {
1594+ -- point = "CENTER",
1595+ -- relativeTo = parent,
1596+ -- relativePoint = "CENTER",
1597+ -- offsetX = 2,
1598+ -- offsetY = -2,
1599+ -- },
1600+ unitToken = unitToken ,
1601+ auraIndex = index ,
1602+ parent = parent ,
1603+ showCountdownFrame = settings .enablePrivateAuraCountdownFrame ,
1604+ showCountdownNumbers = false ,
1605+ iconInfo = {
1606+ iconAnchor = {
1607+ point = " CENTER" ,
1608+ relativeTo = parent ,
1609+ relativePoint = " CENTER" ,
1610+ offsetX = settings .PrivateAuraOffsetX + offset ,
1611+ offsetY = settings .PrivateAuraOffsetY ,
1612+ },
1613+ iconWidth = w ,
1614+ iconHeight = settings .PrivateAuraHeight ,
1615+ borderScale = 1.1 ,
1616+ },
1617+ }
1618+ end
1619+ end
1620+
1621+ local function ResizePrivateAuraDuration (parent , size )
1622+ -- Blizzard creates a Cooldown frame inside your parent
1623+ local cd = parent :GetChildren ()
1624+ if cd and cd .SetHideCountdownNumbers then
1625+ -- Duration text is the cooldown's text region
1626+ local regions = { cd :GetRegions () }
1627+ for _ , r in ipairs (regions ) do
1628+ if r :GetObjectType () == " FontString" then
1629+ r :SetFont (r :GetFont (), size , " OUTLINE" )
1630+ end
1631+ end
1632+ end
1633+ end
1634+
1635+ local function ResizePrivateAuraStacks (parent , size )
1636+ for _ , child in ipairs ({ parent :GetChildren () }) do
1637+ if child .count and child .count .SetFont then
1638+ child .count :SetFont (child .count :GetFont (), size , " OUTLINE" )
1639+ end
1640+ end
1641+ end
1642+
1643+ local QueueUpdate -- delay updates if we are in combat
1644+ do
1645+ local queue , frame = {}, CreateFrame (" Frame" )
1646+ frame :Hide ()
1647+ frame :SetScript (" OnEvent" , function ()
1648+ frame :UnregisterEvent (' PLAYER_REGEN_ENABLED' )
1649+ -- for unit in pairs(queue) do
1650+ -- for _, indicator in Grid2:IterateIndicators('privateauras') do
1651+ -- if not indicator.suspended then
1652+ -- for frame in next, Grid2:GetUnitFrames(unit) do
1653+ -- indicator:Update(frame, unit)
1654+ -- end
1655+ -- end
1656+ -- end
1657+ -- end
1658+ PlexusFrame :UpdateFrameUnits ()
1659+ wipe (queue )
1660+ end )
1661+ function QueueUpdate (unit )
1662+ if not next (queue ) then
1663+ frame :RegisterEvent (' PLAYER_REGEN_ENABLED' )
1664+ end
1665+ queue [unit ] = true
1666+ end
1667+ end
1668+
15561669function PlexusFrame :UpdateFrameUnits ()
15571670 local settings = self .db .profile
15581671 for frame_name , frame in pairs (self .registeredFrames ) do
1672+ frame .privateAuraAnchors = frame .privateAuraAnchors or {}
15591673 if frame :IsVisible () then
15601674 local old_unit = frame .unit
15611675 local old_guid = frame .unitGUID
@@ -1564,82 +1678,86 @@ function PlexusFrame:UpdateFrameUnits()
15641678 local guid = unitid and ( (not Plexus .IsSpecialUnit [unitid ]) and UnitGUID (unitid ) or unitid ) or nil
15651679 if Plexus :issecretvalue (guid ) then guid = nil end
15661680
1567- -- Start Priavte Aura
1568- if Plexus :IsRetailWow () and settings .enablePrivateAura and guid and (old_unit ~= unitid or old_guid ~= guid ) and not frame .anchorID then
1569- frame .pa = CreateFrame (" Button" , nil , frame .indicators .bar , BackdropTemplateMixin and " BackdropTemplate" )
1570- frame .pa :SetPoint (" CENTER" )
1571- frame .pa :SetSize (1 , 1 )
1572- frame .pa :EnableMouse (false )
1573- frame .pa :Show ()
1574- local auraAnchor = {
1575- durationAnchor =
1576- {
1577- point = " CENTER" ,
1578- relativeTo = frame .pa , -- frame.Duration
1579- relativePoint = " CENTER" ,
1580- offsetX = settings .PrivateAuraOffsetX ,
1581- offsetY = settings .PrivateAuraOffsetY ,
1582- };
1583- unitToken = unitid ,
1584- auraIndex = 1 , -- frame.auraIndex
1585- parent = frame .pa ,
1586- showCountdownFrame = settings .enablePrivateAuraCountdownFrame ,
1587- showCountdownNumbers = settings .enablePrivateAuraCountdownNumbers ,
1588- iconInfo =
1589- {
1590- iconAnchor = {
1591- point = " CENTER" ,
1592- relativeTo = frame .pa ,
1593- relativePoint = " CENTER" ,
1594- offsetX = settings .PrivateAuraOffsetX ,
1595- offsetY = settings .PrivateAuraOffsetY ,
1596- },
1597- iconWidth = settings .PrivateAuraWidth , -- frame.indicators.icon:GetWidth()
1598- iconHeight = settings .PrivateAuraHeight , -- frame.indicators.icon:GetHeight()
1599- borderScale = 1.1 ,
1600- };
1601- }
1602- frame .anchorID = C_UnitAuras .AddPrivateAuraAnchor (auraAnchor )
1603- end
1604- if Plexus :IsRetailWow () and settings .enablePrivateAura and guid and (old_unit ~= unitid or old_guid ~= guid ) and frame .anchorID then
1605- C_UnitAuras .RemovePrivateAuraAnchor (frame .anchorID )
1606- frame .anchorID = nil
1607- local icon = frame .pa
1608- icon :SetParent (frame .indicators .bar )
1609- icon :SetPoint (" CENTER" )
1610- icon :SetSize (1 , 1 )
1611- icon :EnableMouse (false )
1612- icon :Show ()
1613- local auraAnchor = {
1614- durationAnchor =
1615- {
1616- point = " CENTER" ,
1617- relativeTo = icon , -- frame.Duration
1618- relativePoint = " CENTER" ,
1619- offsetX = settings .PrivateAuraOffsetX ,
1620- offsetY = settings .PrivateAuraOffsetY ,
1621- };
1622- unitToken = unitid ,
1623- auraIndex = 1 , -- frame.auraIndex
1624- parent = icon ,
1625- showCountdownFrame = settings .enablePrivateAuraCountdownFrame ,
1626- showCountdownNumbers = settings .enablePrivateAuraCountdownNumbers ,
1627- iconInfo =
1628- {
1629- iconAnchor = {
1630- point = " CENTER" ,
1631- relativeTo = icon ,
1632- relativePoint = " CENTER" ,
1633- offsetX = settings .PrivateAuraOffsetX ,
1634- offsetY = settings .PrivateAuraOffsetY ,
1635- },
1636- iconWidth = settings .PrivateAuraWidth , -- frame.indicators.icon:GetWidth()
1637- iconHeight = settings .PrivateAuraHeight , -- frame.indicators.icon:GetHeight()
1638- borderScale = 1.1 ,
1639- };
1640- }
1641- frame .anchorID = C_UnitAuras .AddPrivateAuraAnchor (auraAnchor )
1681+ if not InCombatLockdown () then
1682+ -- Start Priavte Aura
1683+ if Plexus :IsRetailWow () and settings .enablePrivateAura and guid and (old_unit ~= unitid or old_guid ~= guid ) then
1684+ -- Create parent frame once
1685+ if not frame .pa then
1686+ frame .pa = CreateFrame (" Button" , nil , frame .indicators .bar , BackdropTemplateMixin and " BackdropTemplate" )
1687+ frame .pa :SetPoint (" CENTER" )
1688+ frame .pa :SetSize (1 , 1 )
1689+ frame .pa :EnableMouse (false )
1690+ frame .pa :Show ()
1691+ end
1692+
1693+ -- Remove old anchors
1694+ for i = 1 , 5 do
1695+ local id = frame .privateAuraAnchors [i ]
1696+ if id then
1697+ C_UnitAuras .RemovePrivateAuraAnchor (id )
1698+ frame .privateAuraAnchors [i ] = nil
1699+ end
1700+ end
1701+
1702+ -- Add new anchors
1703+ for i = 1 , 5 do
1704+ local anchor = PlexusFrame :MakePAAnchor (frame .pa , unitid , i , settings )
1705+ frame .privateAuraAnchors [i ] = C_UnitAuras .AddPrivateAuraAnchor (anchor )
1706+ -- ResizePrivateAuraDuration(frame.pa, settings.PrivateAuraDurationFontSize or 5)
1707+ -- ResizePrivateAuraStacks(frame.pa, settings.PrivateAuraStackFontSize or 5)
1708+ end
1709+ elseif Plexus :IsRetailWow () and not settings .enablePrivateAura and guid and (old_unit ~= unitid or old_guid ~= guid ) then
1710+ -- Remove old anchors
1711+ for i = 1 , 5 do
1712+ local id = frame .privateAuraAnchors [i ]
1713+ if id then
1714+ C_UnitAuras .RemovePrivateAuraAnchor (id )
1715+ frame .privateAuraAnchors [i ] = nil
1716+ end
1717+ end
1718+ end
1719+ else
1720+ QueueUpdate (unitid )
16421721 end
1722+ -- if Plexus:IsRetailWow() and settings.enablePrivateAura and guid and (old_unit ~= unitid or old_guid ~= guid) and frame.anchorID then
1723+ -- C_UnitAuras.RemovePrivateAuraAnchor(frame.anchorID)
1724+ -- frame.anchorID = nil
1725+ -- local icon = frame.pa
1726+ -- icon:SetParent(frame.indicators.bar)
1727+ -- icon:SetPoint("CENTER")
1728+ -- icon:SetSize(1, 1)
1729+ -- icon:EnableMouse(false)
1730+ -- icon:Show()
1731+ -- local auraAnchor = {
1732+ -- durationAnchor =
1733+ -- {
1734+ -- point = "CENTER",
1735+ -- relativeTo = icon, --frame.Duration
1736+ -- relativePoint = "CENTER",
1737+ -- offsetX = settings.PrivateAuraOffsetX,
1738+ -- offsetY = settings.PrivateAuraOffsetY,
1739+ -- };
1740+ -- unitToken = unitid,
1741+ -- auraIndex = 1, --frame.auraIndex
1742+ -- parent = icon,
1743+ -- showCountdownFrame = settings.enablePrivateAuraCountdownFrame,
1744+ -- showCountdownNumbers = settings.enablePrivateAuraCountdownNumbers,
1745+ -- iconInfo =
1746+ -- {
1747+ -- iconAnchor = {
1748+ -- point = "CENTER",
1749+ -- relativeTo = icon,
1750+ -- relativePoint = "CENTER",
1751+ -- offsetX = settings.PrivateAuraOffsetX,
1752+ -- offsetY = settings.PrivateAuraOffsetY,
1753+ -- },
1754+ -- iconWidth = settings.PrivateAuraWidth, --frame.indicators.icon:GetWidth()
1755+ -- iconHeight = settings.PrivateAuraHeight, --frame.indicators.icon:GetHeight()
1756+ -- borderScale = 1.1,
1757+ -- };
1758+ -- }
1759+ -- frame.anchorID = C_UnitAuras.AddPrivateAuraAnchor(auraAnchor)
1760+ -- end
16431761 if Plexus :IsRetailWow () and not settings .enablePrivateAura then
16441762 if frame and frame .anchorID then
16451763 C_UnitAuras .RemovePrivateAuraAnchor (frame .anchorID )
0 commit comments