Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  1. function (self, unitId, unitFrame, envTable)
  2.  
  3. local auraContainers = {unitFrame.BuffFrame.PlaterBuffList}
  4.  
  5. if (Plater.db.profile.buffs_on_aura2) then
  6. auraContainers [2] = unitFrame.BuffFrame2.PlaterBuffList
  7. end
  8.  
  9. for containerID = 1, #auraContainers do
  10.  
  11. local auraContainer = auraContainers [containerID]
  12. local aurasShown = {}
  13. local aurasDuplicated = {}
  14.  
  15. --build the list of auras shown in the buff frame and check for each aura priority
  16. --also check if the consolidate (stack) auras with the same name is enabled
  17. for index, auraIcon in ipairs (auraContainer) do
  18. if (auraIcon:IsShown()) then
  19. if (envTable.consolidadeRepeatedAuras) then
  20. --is this aura already shown?
  21. local iconShownIndex = aurasDuplicated [auraIcon.SpellName]
  22. if (iconShownIndex) then
  23. --get the table with information about the shown icon
  24. local auraShownTable = aurasShown [iconShownIndex]
  25. --get the icon already in the table
  26. local icon = auraShownTable[1]
  27. --increase the amount of stacks
  28. auraShownTable[3] = auraShownTable[3] + 1
  29.  
  30. --check if the remaining time of the icon already added in the table is lower than the current
  31. if (auraIcon.RemainingTime > icon.RemainingTime) then
  32. --replace the icon for the icon with bigger duration
  33. auraShownTable[1] = auraIcon
  34. icon:Hide()
  35. else
  36. auraIcon:Hide()
  37. end
  38. else
  39. local priority = envTable.priority[auraIcon.SpellName] or envTable.priority[auraIcon.spellId] or 1
  40. tinsert (aurasShown, {auraIcon, priority, 1}) --icon frame, priority, stack amount
  41. aurasDuplicated [auraIcon.SpellName] = #aurasShown
  42. end
  43. else
  44. --not stacking similar auras
  45. local priority = envTable.priority[auraIcon.SpellName] or envTable.priority[auraIcon.spellId] or 1
  46. tinsert (aurasShown, {auraIcon, priority})
  47.  
  48. end
  49. end
  50. end
  51.  
  52. --sort auras by priority
  53. table.sort (aurasShown, DetailsFramework.SortOrder2)
  54.  
  55. local growDirection
  56. if (containerID == 1) then --debuff container
  57. growDirection = Plater.db.profile.aura_grow_direction
  58. --force to grow to right if it is anchored to center
  59. if (growDirection == 2) then
  60. growDirection = 3
  61. end
  62. -- "Left", "Center", "Right" - 1 2 3
  63.  
  64. elseif (containerID == 2) then --buff container
  65. growDirection = Plater.db.profile.aura2_grow_direction
  66. --force to grow to left if it is anchored to center
  67. if (growDirection == 2) then
  68. growDirection = 1
  69. end
  70.  
  71. end
  72.  
  73. local padding = envTable.padding
  74. local framersPerRow = envTable.maxAurasPerRow + 1
  75.  
  76. --first icon is where the row starts
  77. local firstIcon = aurasShown[1] and aurasShown[1][1]
  78.  
  79. if (firstIcon) then
  80. local anchorPoint = firstIcon:GetParent() --anchor point is the BuffFrame
  81. anchorPoint:SetSize (1, 1)
  82.  
  83. firstIcon:ClearAllPoints()
  84. firstIcon:SetPoint ("center", anchorPoint, "center", 0, 5)
  85.  
  86. --check the consolidaded stacks, this is not the regular buff stacks
  87. local firstIconStacks = aurasShown[1][3]
  88. if (firstIconStacks and firstIconStacks > 1) then
  89. firstIcon.StackText:SetText (firstIconStacks)
  90. firstIcon.StackText:Show()
  91. end
  92.  
  93. --> left to right
  94. if (growDirection == 3) then
  95. --> iterate among all aura icons
  96. for i = 2, #aurasShown do
  97. local auraIcon = aurasShown [i][1]
  98. auraIcon:ClearAllPoints()
  99.  
  100. if (i == framersPerRow) then
  101. auraIcon:SetPoint ("bottomleft", firstIcon, "topleft", 0, envTable.rowPadding)
  102. framersPerRow = framersPerRow + framersPerRow
  103.  
  104. else
  105. auraIcon:SetPoint ("topleft", aurasShown [i-1][1], "topright", padding, 0)
  106. end
  107.  
  108. local stacks = aurasShown[i][3]
  109. if (stacks and stacks > 1) then
  110. auraIcon.StackText:SetText (stacks)
  111. auraIcon.StackText:Show()
  112. end
  113. end
  114.  
  115. --right to left
  116. elseif (growDirection == 1) then
  117. --> iterate among all aura icons
  118. for i = 2, #aurasShown do
  119. local auraIcon = aurasShown [i][1]
  120. auraIcon:ClearAllPoints()
  121.  
  122. if (i == framersPerRow) then
  123. auraIcon:SetPoint ("bottomright", firstIcon, "topright", 0, envTable.rowPadding)
  124. framersPerRow = framersPerRow + framersPerRow
  125.  
  126. else
  127. auraIcon:SetPoint ("topright", aurasShown [i-1][1], "topleft", -padding, 0)
  128. end
  129.  
  130. local stacks = aurasShown[i][3]
  131. if (stacks and stacks > 1) then
  132. auraIcon.StackText:SetText (stacks)
  133. auraIcon.StackText:Show()
  134. end
  135.  
  136. end
  137. end
  138.  
  139. end
  140. end
  141. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement