Advertisement
Guest User

Untitled

a guest
Nov 4th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.25 KB | None | 0 0
  1. --[[
  2. # Element: Auras
  3.  
  4. Handles creation and updating of aura icons.
  5.  
  6. ## Widget
  7.  
  8. Auras   - A Frame to hold `Button`s representing both buffs and debuffs.
  9. Buffs   - A Frame to hold `Button`s representing buffs.
  10. Debuffs - A Frame to hold `Button`s representing debuffs.
  11.  
  12. ## Notes
  13.  
  14. At least one of the above widgets must be present for the element to work.
  15.  
  16. ## Options
  17.  
  18. .disableMouse       - Disables mouse events (boolean)
  19. .disableCooldown    - Disables the cooldown spiral (boolean)
  20. .size               - Aura icon size. Defaults to 16 (number)
  21. .onlyShowPlayer     - Shows only auras created by player/vehicle (boolean)
  22. .reverse            - Reverse fills the cooldown; only works if .disableCooldown is nil or false (boolean)
  23. .showStealableBuffs - Displays the stealable texture on buffs that can be stolen (boolean)
  24. .spacing            - Spacing between each icon. Defaults to 0 (number)
  25. .['spacing-x']      - Horizontal spacing between each icon. Takes priority over `spacing` (number)
  26. .['spacing-y']      - Vertical spacing between each icon. Takes priority over `spacing` (number)
  27. .['growth-x']       - Horizontal growth direction. Defaults to 'RIGHT' (string)
  28. .['growth-y']       - Vertical growth direction. Defaults to 'UP' (string)
  29. .initialAnchor      - Anchor point for the icons. Defaults to 'BOTTOMLEFT' (string)
  30. .filter             - Custom filter list for auras to display. Defaults to 'HELPFUL' for buffs and 'HARMFUL' for
  31.                       debuffs (string)
  32. .tooltipAnchor      - Anchor point for the tooltip. Defaults to 'ANCHOR_BOTTOMRIGHT', however, if a frame has anchoring
  33.                       restrictions it will be set to 'ANCHOR_CURSOR' (string)
  34.  
  35. ## Options Auras
  36.  
  37. .numBuffs     - The maximum number of buffs to display. Defaults to 32 (number)
  38. .numDebuffs   - The maximum number of debuffs to display. Defaults to 40 (number)
  39. .numTotal     - The maximum number of auras to display. Prioritizes buffs over debuffs. Defaults to the sum of
  40.                 .numBuffs and .numDebuffs (number)
  41. .gap          - Controls the creation of an invisible icon between buffs and debuffs. Defaults to false (boolean)
  42. .buffFilter   - Custom filter list for buffs to display. Takes priority over `filter` (string)
  43. .debuffFilter - Custom filter list for debuffs to display. Takes priority over `filter` (string)
  44.  
  45. ## Options Buffs
  46.  
  47. .num - Number of buffs to display. Defaults to 32 (number)
  48.  
  49. ## Options Debuffs
  50.  
  51. .num - Number of debuffs to display. Defaults to 40 (number)
  52.  
  53. ## Attributes
  54.  
  55. button.caster   - the unit who cast the aura (string)
  56. button.filter   - the filter list used to determine the visibility of the aura (string)
  57. button.isDebuff - indicates if the button holds a debuff (boolean)
  58. button.isPlayer - indicates if the aura caster is the player or their vehicle (boolean)
  59.  
  60. ## Examples
  61.  
  62.     -- Position and size
  63.     local Buffs = CreateFrame('Frame', nil, self)
  64.     Buffs:SetPoint('RIGHT', self, 'LEFT')
  65.     Buffs:SetSize(16 * 2, 16 * 16)
  66.  
  67.     -- Register with oUF
  68.     self.Buffs = Buffs
  69. --]]
  70.  
  71. local _, ns = ...
  72. local oUF = ns.oUF
  73.  
  74. local VISIBLE = 1
  75. local HIDDEN = 0
  76.  
  77. local function UpdateTooltip(self)
  78.     GameTooltip:SetUnitAura(self:GetParent().__owner.unit, self:GetID(), self.filter)
  79. end
  80.  
  81. local function onEnter(self)
  82.     if(not self:IsVisible()) then return end
  83.  
  84.     GameTooltip:SetOwner(self, self:GetParent().tooltipAnchor)
  85.     self:UpdateTooltip()
  86. end
  87.  
  88. local function onLeave()
  89.     GameTooltip:Hide()
  90. end
  91.  
  92. local function createAuraIcon(element, index)
  93.     local button = CreateFrame('Button', element:GetDebugName() .. 'Button' .. index, element)
  94.     button:RegisterForClicks('RightButtonUp')
  95.  
  96.     local cd = CreateFrame('Cooldown', '$parentCooldown', button, 'CooldownFrameTemplate')
  97.     cd:SetAllPoints()
  98.     if element.reverse then
  99.         cd:SetReverse(true)
  100.     end
  101.  
  102.     local icon = button:CreateTexture(nil, 'BORDER')
  103.     icon:SetAllPoints()
  104.  
  105.     local countFrame = CreateFrame('Frame', nil, button)
  106.     countFrame:SetAllPoints(button)
  107.     countFrame:SetFrameLevel(cd:GetFrameLevel() + 1)
  108.  
  109.     local count = countFrame:CreateFontString(nil, 'OVERLAY', 'NumberFontNormal')
  110.     count:SetPoint('BOTTOMRIGHT', countFrame, 'BOTTOMRIGHT', -1, 0)
  111.  
  112.     local overlay = button:CreateTexture(nil, 'OVERLAY')
  113.     overlay:SetTexture([[Interface\Buttons\UI-Debuff-Overlays]])
  114.     overlay:SetAllPoints()
  115.     overlay:SetTexCoord(.296875, .5703125, 0, .515625)
  116.     button.overlay = overlay
  117.  
  118.     local stealable = button:CreateTexture(nil, 'OVERLAY')
  119.     stealable:SetTexture([[Interface\TargetingFrame\UI-TargetingFrame-Stealable]])
  120.     stealable:SetPoint('TOPLEFT', -3, 3)
  121.     stealable:SetPoint('BOTTOMRIGHT', 3, -3)
  122.     stealable:SetBlendMode('ADD')
  123.     button.stealable = stealable
  124.  
  125.     button.UpdateTooltip = UpdateTooltip
  126.     button:SetScript('OnEnter', onEnter)
  127.     button:SetScript('OnLeave', onLeave)
  128.  
  129.     button.icon = icon
  130.     button.count = count
  131.     button.cd = cd
  132.  
  133.     --[[ Callback: Auras:PostCreateIcon(button)
  134.     Called after a new aura button has been created.
  135.  
  136.     * self   - the widget holding the aura buttons
  137.     * button - the newly created aura button (Button)
  138.     --]]
  139.     if(element.PostCreateIcon) then element:PostCreateIcon(button) end
  140.     return button
  141. end
  142.  
  143. local function customFilter(element, unit, button, name)
  144.     if((element.onlyShowPlayer and button.isPlayer) or (not element.onlyShowPlayer and name)) then
  145.         return true
  146.     end
  147. end
  148.  
  149. local function updateIcon(element, unit, index, offset, filter, isDebuff, visible)
  150.     local name, texture, count, debuffType, duration, expiration, caster, isStealable,
  151.         nameplateShowSelf, spellID, canApply, isBossDebuff, casterIsPlayer, nameplateShowAll,
  152.         timeMod, effect1, effect2, effect3 = UnitAura(unit, index, filter)
  153.  
  154.     if(name) then
  155.         local position = visible + offset + 1
  156.         local button = element[position]
  157.         if(not button) then
  158.             --[[ Override: Auras:CreateIcon(position)
  159.             Used to create the aura button at a given position.
  160.  
  161.             * self     - the widget holding the aura buttons
  162.             * position - the position at which the aura button is to be created (number)
  163.  
  164.             ## Returns
  165.  
  166.             * button - the button used to represent the aura (Button)
  167.             --]]
  168.             button = (element.CreateIcon or createAuraIcon) (element, position)
  169.            
  170.             table.insert(element, button)
  171.             element.createdIcons = element.createdIcons + 1
  172.         end
  173.  
  174.         button.caster = caster
  175.         button.filter = filter
  176.         button.isDebuff = isDebuff
  177.         button.isPlayer = caster == 'player' or caster == 'vehicle'
  178.  
  179.         --[[ Override: Auras:CustomFilter(unit, button, ...)
  180.         Defines a custom filter that controls if the aura button should be shown.
  181.  
  182.         * self   - the widget holding the aura buttons
  183.         * unit   - the unit on which the aura is cast (string)
  184.         * button - the button displaying the aura (Button)
  185.         * ...    - the return values from [UnitAura](http://wowprogramming.com/docs/api/UnitAura.html)
  186.  
  187.         ## Returns
  188.  
  189.         * show - indicates whether the aura button should be shown (boolean)
  190.         --]]
  191.         local show = (element.CustomFilter or customFilter) (element, unit, button, name, texture,
  192.             count, debuffType, duration, expiration, caster, isStealable, nameplateShowSelf, spellID,
  193.             canApply, isBossDebuff, casterIsPlayer, nameplateShowAll,timeMod, effect1, effect2, effect3)
  194.         if(show) then
  195.             -- We might want to consider delaying the creation of an actual cooldown
  196.             -- object to this point, but I think that will just make things needlessly
  197.             -- complicated.
  198.             if(button.cd and not element.disableCooldown) then
  199.                 if(duration and duration > 0) then
  200.                     button.cd:SetCooldown(expiration - duration, duration)
  201.                     button.cd:Show()
  202.                 else
  203.                     button.cd:Hide()
  204.                 end
  205.             end
  206.  
  207.             if(button.overlay) then
  208.                 if((isDebuff and element.showDebuffType) or (not isDebuff and element.showBuffType) or element.showType) then
  209.                     local color = element.__owner.colors.debuff[debuffType] or element.__owner.colors.debuff.none
  210.  
  211.                     button.overlay:SetVertexColor(color[1], color[2], color[3])
  212.                     button.overlay:Show()
  213.                 else
  214.                     button.overlay:Hide()
  215.                 end
  216.             end
  217.  
  218.             if(button.stealable) then
  219.                 if(not isDebuff and isStealable and element.showStealableBuffs and not UnitIsUnit('player', unit)) then
  220.                     button.stealable:Show()
  221.                 else
  222.                     button.stealable:Hide()
  223.                 end
  224.             end
  225.  
  226.             if(button.icon) then button.icon:SetTexture(texture) end
  227.             if(button.count) then button.count:SetText(count > 1 and count) end
  228.  
  229.             local size = element.size or 16
  230.             button:SetSize(size, size)
  231.  
  232.             button:EnableMouse(not element.disableMouse)
  233.             button:SetID(index)
  234.             button:Show()
  235.  
  236.             --[[ Callback: Auras:PostUpdateIcon(unit, button, index, position)
  237.             Called after the aura button has been updated.
  238.  
  239.             * self        - the widget holding the aura buttons
  240.             * unit        - the unit on which the aura is cast (string)
  241.             * button      - the updated aura button (Button)
  242.             * index       - the index of the aura (number)
  243.             * position    - the actual position of the aura button (number)
  244.             * duration    - the aura duration in seconds (number?)
  245.             * expiration  - the point in time when the aura will expire. Comparable to GetTime() (number)
  246.             * debuffType  - the debuff type of the aura (string?)['Curse', 'Disease', 'Magic', 'Poison']
  247.             * isStealable - whether the aura can be stolen or purged (boolean)
  248.             --]]
  249.             if(element.PostUpdateIcon) then
  250.                 element:PostUpdateIcon(unit, button, index, position, duration, expiration, debuffType, isStealable)
  251.             end
  252.             return VISIBLE
  253.         else
  254.             return HIDDEN
  255.         end
  256.     end
  257. end
  258.  
  259. local function SetPosition(element, from, to)
  260.     local sizex = (element.size or 16) + (element['spacing-x'] or element.spacing or 0)
  261.     local sizey = (element.size or 16) + (element['spacing-y'] or element.spacing or 0)
  262.     local anchor = element.initialAnchor or 'BOTTOMLEFT'
  263.     local growthx = (element['growth-x'] == 'LEFT' and -1) or 1
  264.     local growthy = (element['growth-y'] == 'DOWN' and -1) or 1
  265.     local cols = math.floor(element:GetWidth() / sizex + 0.5)
  266.    
  267.     for i = from, to do
  268.         local button = element[i]
  269.  
  270.         -- Bail out if the to range is out of scope.
  271.         if(not button) then break end
  272.         local col = (i - 1) % cols
  273.         local row = math.floor((i - 1) / cols)
  274.  
  275.         button:ClearAllPoints()
  276.         button:SetPoint(anchor, element, anchor, col * sizex * growthx, row * sizey * growthy)
  277.     end
  278. end
  279.  
  280. local function filterIcons(element, unit, filter, limit, isDebuff, offset, dontHide)
  281.     if(not offset) then offset = 0 end
  282.     local index = 1
  283.     local visible = 0
  284.     local hidden = 0
  285.     while(visible < limit) do
  286.         local result = updateIcon(element, unit, index, offset, filter, isDebuff, visible)
  287.         if(not result) then
  288.             break
  289.         elseif(result == VISIBLE) then
  290.             visible = visible + 1
  291.         elseif(result == HIDDEN) then
  292.             hidden = hidden + 1
  293.         end
  294.  
  295.         index = index + 1
  296.     end
  297.  
  298.     if(not dontHide) then
  299.         for i = visible + offset + 1, #element do
  300.             element[i]:Hide()
  301.         end
  302.     end
  303.  
  304.     return visible, hidden
  305. end
  306.  
  307. local function UpdateAuras(self, event, unit)
  308.     if(self.unit ~= unit) then return end
  309.    
  310.     if (self.Auras or self.multiAuras) then
  311.         for i = 1, (self.Auras and 1) or (self.multiAuras and #self.multiAuras) do
  312.             local auras = (self.multiAuras and self.multiAuras[i]) or self.Auras
  313.             if(auras) then
  314.                 --[[ Callback: Auras:PreUpdate(unit)
  315.                 Called before the element has been updated.
  316.  
  317.                 * self - the widget holding the aura buttons
  318.                 * unit - the unit for which the update has been triggered (string)
  319.                 --]]
  320.                 if(auras.PreUpdate) then auras:PreUpdate(unit) end
  321.  
  322.                 local numBuffs = auras.numBuffs or 32
  323.                 local numDebuffs = auras.numDebuffs or 40
  324.                 local max = auras.numTotal or numBuffs + numDebuffs
  325.  
  326.                 local visibleBuffs, hiddenBuffs = filterIcons(auras, unit, auras.buffFilter or auras.filter or 'HELPFUL', math.min(numBuffs, max), nil, 0, true)
  327.  
  328.                 local hasGap
  329.                 if(visibleBuffs ~= 0 and auras.gap) then
  330.                     hasGap = true
  331.                     visibleBuffs = visibleBuffs + 1
  332.  
  333.                     local button = auras[visibleBuffs]
  334.                     if(not button) then
  335.                         button = (auras.CreateIcon or createAuraIcon) (auras, visibleBuffs)
  336.                         table.insert(auras, button)
  337.                         auras.createdIcons = auras.createdIcons + 1
  338.                     end
  339.  
  340.                     -- Prevent the button from displaying anything.
  341.                     if(button.cd) then button.cd:Hide() end
  342.                     if(button.icon) then button.icon:SetTexture() end
  343.                     if(button.overlay) then button.overlay:Hide() end
  344.                     if(button.stealable) then button.stealable:Hide() end
  345.                     if(button.count) then button.count:SetText() end
  346.  
  347.                     button:EnableMouse(false)
  348.                     button:Show()
  349.  
  350.                     --[[ Callback: Auras:PostUpdateGapIcon(unit, gapButton, visibleBuffs)
  351.                     Called after an invisible aura button has been created. Only used by Auras when the `gap` option is enabled.
  352.  
  353.                     * self         - the widget holding the aura buttons
  354.                     * unit         - the unit that has the invisible aura button (string)
  355.                     * gapButton    - the invisible aura button (Button)
  356.                     * visibleBuffs - the number of currently visible aura buttons (number)
  357.                     --]]
  358.                     if(auras.PostUpdateGapIcon) then
  359.                         auras:PostUpdateGapIcon(unit, button, visibleBuffs)
  360.                     end
  361.                 end
  362.  
  363.                 local visibleDebuffs, hiddenDebuffs = filterIcons(auras, unit, auras.debuffFilter or auras.filter or 'HARMFUL', math.min(numDebuffs, max - visibleBuffs), true, visibleBuffs)
  364.                 auras.visibleDebuffs = visibleDebuffs
  365.  
  366.                 if(hasGap and visibleDebuffs == 0) then
  367.                     auras[visibleBuffs]:Hide()
  368.                     visibleBuffs = visibleBuffs - 1
  369.                 end
  370.  
  371.                 auras.visibleBuffs = visibleBuffs
  372.                 auras.visibleAuras = auras.visibleBuffs + auras.visibleDebuffs
  373.  
  374.                 local fromRange, toRange
  375.                 --[[ Callback: Auras:PreSetPosition(max)
  376.                 Called before the aura buttons have been (re-)anchored.
  377.  
  378.                 * self - the widget holding the aura buttons
  379.                 * max  - the maximum possible number of aura buttons (number)
  380.  
  381.                 ## Returns
  382.  
  383.                 * from - the offset of the first aura button to be (re-)anchored (number)
  384.                 * to   - the offset of the last aura button to be (re-)anchored (number)
  385.                 --]]
  386.                 if(auras.PreSetPosition) then
  387.                     fromRange, toRange = auras:PreSetPosition(max)
  388.                 end
  389.  
  390.                 if(fromRange or auras.createdIcons > auras.anchoredIcons) then
  391.                     --[[ Override: Auras:SetPosition(from, to)
  392.                     Used to (re-)anchor the aura buttons.
  393.                     Called when new aura buttons have been created or if :PreSetPosition is defined.
  394.  
  395.                     * self - the widget that holds the aura buttons
  396.                     * from - the offset of the first aura button to be (re-)anchored (number)
  397.                     * to   - the offset of the last aura button to be (re-)anchored (number)
  398.                     --]]
  399.                     (auras.SetPosition or SetPosition) (auras, fromRange or auras.anchoredIcons + 1, toRange or auras.createdIcons)
  400.                     auras.anchoredIcons = auras.createdIcons
  401.                 end
  402.  
  403.                 --[[ Callback: Auras:PostUpdate(unit)
  404.                 Called after the element has been updated.
  405.  
  406.                 * self - the widget holding the aura buttons
  407.                 * unit - the unit for which the update has been triggered (string)
  408.                 --]]
  409.                 if(auras.PostUpdate) then auras:PostUpdate(unit) end
  410.             end
  411.         end
  412.     end
  413.  
  414.     if (self.Buffs or self.multiBuffs) then
  415.         for i = 1, (self.Buffs and 1) or (self.multiBuffs and #self.multiBuffs) do
  416.             local buffs = (self.multiBuffs and self.multiBuffs[i]) or self.Buffs
  417.             if(buffs) then
  418.                 if(buffs.PreUpdate) then buffs:PreUpdate(unit) end
  419.  
  420.                 local numBuffs = buffs.num or 32
  421.                 local visibleBuffs, hiddenBuffs = filterIcons(buffs, unit, buffs.filter or 'HELPFUL', numBuffs)
  422.                 buffs.visibleBuffs = visibleBuffs
  423.  
  424.                 local fromRange, toRange
  425.                 if(buffs.PreSetPosition) then
  426.                     fromRange, toRange = buffs:PreSetPosition(numBuffs)
  427.                 end
  428.  
  429.                 if(fromRange or buffs.createdIcons > buffs.anchoredIcons) then
  430.                     (buffs.SetPosition or SetPosition) (buffs, fromRange or buffs.anchoredIcons + 1, toRange or buffs.createdIcons)
  431.                     buffs.anchoredIcons = buffs.createdIcons
  432.                 end
  433.  
  434.                 if(buffs.PostUpdate) then buffs:PostUpdate(unit) end
  435.             end
  436.         end
  437.     end
  438.  
  439.     if (self.Debuffs or self.multiDebuffs) then
  440.         for i = 1, (self.Debuffs and 1) or (self.multiDebuffs and #self.multiDebuffs) do
  441.             local debuffs = (self.multiDebuffs and self.multiDebuffs[i]) or self.Debuffs
  442.             if(debuffs) then
  443.                 if(debuffs.PreUpdate) then debuffs:PreUpdate(unit) end
  444.  
  445.                 local numDebuffs = debuffs.num or 40
  446.                 local visibleDebuffs, hiddenDebuffs = filterIcons(debuffs, unit, debuffs.filter or 'HARMFUL', numDebuffs, true)
  447.                 debuffs.visibleDebuffs = visibleDebuffs
  448.  
  449.                 local fromRange, toRange
  450.                 if(debuffs.PreSetPosition) then
  451.                     fromRange, toRange = debuffs:PreSetPosition(numDebuffs)
  452.                 end
  453.                
  454.                 if(fromRange or debuffs.createdIcons > debuffs.anchoredIcons) then
  455.                     (debuffs.SetPosition or SetPosition) (debuffs, fromRange or debuffs.anchoredIcons + 1, toRange or debuffs.createdIcons)
  456.                     debuffs.anchoredIcons = debuffs.createdIcons
  457.                 end
  458.  
  459.                 if(debuffs.PostUpdate) then debuffs:PostUpdate(unit) end
  460.             end
  461.         end
  462.     end
  463. end
  464.  
  465. local function Update(self, event, unit)
  466.     if(self.unit ~= unit) then return end
  467.  
  468.     UpdateAuras(self, event, unit)
  469.  
  470.     -- Assume no event means someone wants to re-anchor things. This is usually
  471.     -- done by UpdateAllElements and :ForceUpdate.
  472.     if(event == 'ForceUpdate' or not event) then
  473.         if (self.Buffs or self.multiBuffs) then
  474.             local x = (self.Buffs and 1) or (self.multiBuffs and #self.multiBuffs)
  475.             for i = 1, x do
  476.                 local buffs = (self.multiBuffs and self.multiBuffs[i]) or self.Buffs
  477.                 if(buffs) then
  478.                     (buffs.SetPosition or SetPosition) (buffs, 1, buffs.createdIcons)
  479.                 end
  480.             end
  481.         end
  482.  
  483.         if (self.Debuffs or self.multiDebuffs) then
  484.             local x = (self.Debuffs and 1) or (self.multiDebuffs and #self.multiDebuffs)
  485.             for i = 1, x do
  486.                 local debuffs = (self.multiDebuffs and self.multiDebuffs[i]) or self.Debuffs
  487.                 if(debuffs) then
  488.                     (debuffs.SetPosition or SetPosition) (debuffs, 1, debuffs.createdIcons)
  489.                 end
  490.             end
  491.         end
  492.  
  493.         if (self.Auras or self.multiAuras) then
  494.             local x = (self.Auras and 1) or (self.multiAuras and #self.multiAuras)
  495.             for i = 1, x do
  496.                 local auras = (self.multiAuras and self.multiAuras[i]) or self.Auras
  497.                 if(auras) then
  498.                     (auras.SetPosition or SetPosition) (auras, 1, auras.createdIcons)
  499.                 end
  500.             end
  501.         end
  502.     end
  503. end
  504.  
  505. local function ForceUpdate(element)
  506.     return Update(element.__owner, 'ForceUpdate', element.__owner.unit)
  507. end
  508.  
  509. local function Enable(self)
  510.     if(self.Buffs or self.Debuffs or self.Auras) then
  511.         self:RegisterEvent('UNIT_AURA', UpdateAuras)
  512.        
  513.         if (self.Buffs or self.multiBuffs) then
  514.             for i = 1, (self.Buffs and 1) or (self.multiBuffs and #self.multiBuffs) do
  515.                 local buffs = (self.multiBuffs and self.multiBuffs[i]) or self.Buffs
  516.                 if(buffs) then
  517.                     buffs.__owner = self
  518.                     buffs.ForceUpdate = ForceUpdate
  519.  
  520.                     buffs.createdIcons = buffs.createdIcons or 0
  521.                     buffs.anchoredIcons = 0
  522.  
  523.                     -- Avoid parenting GameTooltip to frames with anchoring restrictions,
  524.                     -- otherwise it'll inherit said restrictions which will cause issues
  525.                     -- with its further positioning, clamping, etc
  526.                     if(not pcall(self.GetCenter, self)) then
  527.                         buffs.tooltipAnchor = 'ANCHOR_CURSOR'
  528.                     else
  529.                         buffs.tooltipAnchor = buffs.tooltipAnchor or 'ANCHOR_BOTTOMRIGHT'
  530.                     end
  531.  
  532.                     buffs:Show()
  533.                 end
  534.             end
  535.         end
  536.        
  537.         if (self.Debuffs or self.multiDebuffs) then
  538.             for i = 1, (self.Debuffs and 1) or (self.multiDebuffs and #self.multiDebuffs) do
  539.                 local debuffs = (self.multiDebuffs and self.multiDebuffs[i]) or self.Debuffs
  540.                 if(debuffs) then
  541.                     debuffs.__owner = self
  542.                     debuffs.ForceUpdate = ForceUpdate
  543.  
  544.                     debuffs.createdIcons = debuffs.createdIcons or 0
  545.                     debuffs.anchoredIcons = 0
  546.  
  547.                     -- Avoid parenting GameTooltip to frames with anchoring restrictions,
  548.                     -- otherwise it'll inherit said restrictions which will cause issues
  549.                     -- with its further positioning, clamping, etc
  550.                     if(not pcall(self.GetCenter, self)) then
  551.                         debuffs.tooltipAnchor = 'ANCHOR_CURSOR'
  552.                     else
  553.                         debuffs.tooltipAnchor = debuffs.tooltipAnchor or 'ANCHOR_BOTTOMRIGHT'
  554.                     end
  555.  
  556.                     debuffs:Show()
  557.                 end
  558.             end
  559.         end
  560.  
  561.        if (self.Auras or self.multiAuras) then
  562.             for i = 1, (self.Auras and 1) or (self.multiAuras and #self.multiAuras) do
  563.                 local auras = (self.multiAuras and self.multiAuras[i]) or self.Auras
  564.                 if(auras) then
  565.                     auras.__owner = self
  566.                     auras.ForceUpdate = ForceUpdate
  567.  
  568.                     auras.createdIcons = auras.createdIcons or 0
  569.                     auras.anchoredIcons = 0
  570.  
  571.                     -- Avoid parenting GameTooltip to frames with anchoring restrictions,
  572.                     -- otherwise it'll inherit said restrictions which will cause issues
  573.                     -- with its further positioning, clamping, etc
  574.                     if(not pcall(self.GetCenter, self)) then
  575.                         auras.tooltipAnchor = 'ANCHOR_CURSOR'
  576.                     else
  577.                         auras.tooltipAnchor = auras.tooltipAnchor or 'ANCHOR_BOTTOMRIGHT'
  578.                     end
  579.  
  580.                     auras:Show()
  581.                 end
  582.             end
  583.         end
  584.  
  585.         return true
  586.     end
  587. end
  588.  
  589. local function Disable(self)
  590.     if(self.Buffs or self.Debuffs or self.Auras) then
  591.         self:UnregisterEvent('UNIT_AURA', UpdateAuras)
  592.  
  593.         if(self.Buffs) then self.Buffs:Hide() end
  594.         if(self.Debuffs) then self.Debuffs:Hide() end
  595.         if(self.Auras) then self.Auras:Hide() end
  596.     end
  597. end
  598.  
  599. oUF:AddElement('Auras', Update, Enable, Disable)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement