I simply cannot understand why my sorting function would not work. It mixes buffs and debuffs together. I'll just post my assumptions. Please tell me where I'm wrong:
The sorting function.
The aura button properties (duration and expTime are the 6th and 7th return of UnitAura):
IsShown() return value:
-
true for buffs, debuffs and the gap aura
-
nil for other created but unused aura buttons
isDebuff value:
-
nil for buffs
-
true for debuffs
-
true or
nil for the gap aura and other created but unused aura buttons
timeLeft value (set by my layout):
-
expTime - GetTime() for buffs and debuffs if duration and duration > 0
-
math.huge for buffs and debuffs if not duration or duration <= 0
-
-5 for gap aura if not isDebuff (so it's the buff with the lowest timeLeft)
-
math.huge for gap aura if isDebuff == true (so it's the debuff with the highest timeLeft)
- whatever from the above from when the button was last used for unused created aura buttons
The aura array before PreSetPosition (PreSetPosition is where we are supposed to sort):
[buffs (index sorted)][gap aura][debuffs (index sorted)][unused created icons]
The aura array is without holes.
The sorting function gets two parameters a and b, where a always has a higher array index than b. The sorting function returning true means a should come before b.
PreSetPosition should return a range (2 array indices) in which SetPosition operates to (re)anchor the corresponding auras. I return 1 and auras.createdIcons so it reanchors all of them (wouldn't it be even better to use auras.visibleAuras?).
Also why do I need
elseif (a:IsShown()) then in my sorting function? It should not be possible to have a hidden aura button in between. I added that as per haste's advice
here.
A short video of the results so far:
short video
A topic branch of my layout could be reviewed on github.