Skip to content

Commit

Permalink
auras: Take numTotal into account when adding gap (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- authored Feb 25, 2023
1 parent 308705a commit dff23c0
Showing 1 changed file with 33 additions and 25 deletions.
58 changes: 33 additions & 25 deletions elements/auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -488,35 +488,43 @@ local function UpdateAuras(self, event, unit, updateInfo)
numDebuffs = math.min(numDebuffs, numTotal - numVisible, #auras.sortedDebuffs)

if(auras.gap and numVisible > 0 and numDebuffs > 0) then
numVisible = numVisible + 1

local button = auras[numVisible]
if(not button) then
button = (auras.CreateButton or CreateButton) (auras, numVisible)
table.insert(auras, button)
auras.createdButtons = auras.createdButtons + 1
-- adjust the number of visible debuffs if there's an overflow
if(numVisible + numDebuffs == numTotal) then
numDebuffs = numDebuffs - 1
end

-- prevent the button from displaying anything
if(button.Cooldown) then button.Cooldown:Hide() end
if(button.Icon) then button.Icon:SetTexture() end
if(button.Overlay) then button.Overlay:Hide() end
if(button.Stealable) then button.Stealable:Hide() end
if(button.Count) then button.Count:SetText() end

button:EnableMouse(false)
button:Show()
-- double check and skip it if we end up with 0 after the adjustment
if(numDebuffs > 0) then
numVisible = numVisible + 1

--[[ Callback: Auras:PostUpdateGapButton(unit, gapButton, position)
Called after an invisible aura button has been created. Only used by Auras when the `gap` option is enabled.
local button = auras[numVisible]
if(not button) then
button = (auras.CreateButton or CreateButton) (auras, numVisible)
table.insert(auras, button)
auras.createdButtons = auras.createdButtons + 1
end

* self - the widget holding the aura buttons
* unit - the unit that has the invisible aura button (string)
* gapButton - the invisible aura button (Button)
* position - the position of the invisible aura button (number)
--]]
if(auras.PostUpdateGapButton) then
auras:PostUpdateGapButton(unit, button, numVisible)
-- prevent the button from displaying anything
if(button.Cooldown) then button.Cooldown:Hide() end
if(button.Icon) then button.Icon:SetTexture() end
if(button.Overlay) then button.Overlay:Hide() end
if(button.Stealable) then button.Stealable:Hide() end
if(button.Count) then button.Count:SetText() end

button:EnableMouse(false)
button:Show()

--[[ Callback: Auras:PostUpdateGapButton(unit, gapButton, position)
Called after an invisible aura button has been created. Only used by Auras when the `gap` option is enabled.
* self - the widget holding the aura buttons
* unit - the unit that has the invisible aura button (string)
* gapButton - the invisible aura button (Button)
* position - the position of the invisible aura button (number)
--]]
if(auras.PostUpdateGapButton) then
auras:PostUpdateGapButton(unit, button, numVisible)
end
end
end

Expand Down

0 comments on commit dff23c0

Please sign in to comment.