Originally Posted by p3lim
That is a very bad implementation wurmfood, the icons can jump and hide alot.
|
Originally Posted by p3lim
Replacing the whole SetAuraPositions would be way better.
|
:PreAuraSetPosition() exists for one thing and one thing only -- to allow manipulation of the indexes before the positioning is done, without having to replace the entire :SetAuraPosition() function.
Calling his sort method a bad implementation is also plain wrong. Are you really expecting someone to implement id consistent time sort?
But now that you've said what you have. Then please explain to the crowd here exactly why re-implementing the entire :SetAuraPosition() is a better solution that just sorting the table before it's positioned.
It would also be beneficial that you post your far superior sort algorithm that respects icon position and sort order.
Enough bashing of you for now at least:
The way oUF updates auras is quite straight forward, but it has a lot of different ways to manipulate it. A really short example of why it's beneficial to use :PreAuraSetPosition() would be:
lua Code:
local PreAuraSetPosition = function(self, a, n)
for i = 1, n/2 do
local j = n-i+1
a[i], a[j] = a[j], a[i]
end
end
What the function above those is basically invert the aura sort direction. Now compare it with what you would have to do with :SetAuraPosition():
lua Code:
local SetAuraPosition = function(self, icons, x)
if(icons and x > 0) then
local col = 0
local row = 0
local spacing = icons.spacing or 0
local gap = icons.gap
local size = (icons.size or 16) + spacing
local anchor = icons.initialAnchor or "BOTTOMLEFT"
local growthx = (icons["growth-x"] == "LEFT" and -1) or 1
local growthy = (icons["growth-y"] == "DOWN" and -1) or 1
local cols = math.floor(icons:GetWidth() / size + .5)
local rows = math.floor(icons:GetHeight() / size + .5)
for i = x, 1 do
local button = icons[i]
if(button and button:IsShown()) then
if(gap and button.debuff) then
if(col > 0) then
col = col + 1
end
gap = false
end
if(col >= cols) then
col = 0
row = row + 1
end
button:ClearAllPoints()
button:SetPoint(anchor, icons, anchor, col * size * growthx, row * size * growthy)
col = col + 1
end
end
end
end
This is ofc the default :SetAuraPosition() function copy/pasted and one line changed. What we could do now is have a long argument about how the :PreAuraSetPosition() is an extra for loop + function call, but that isn't really a problem at all. And if you think it is, then it's time to write your own unit frame add-on from scratch, because you won't like how auras in oUF are coded in general.
Enough about that: To get your timer based sort you'll have to:
1. Add a start or end time variable to the icon, so that you can compare it. There's several ways to do this: CreateAuraIcon, PostCreateAuraIcon, CustomAuraFilter, PostUpdateAuraIcon, PreAuraSetPosition. CustomAuraFilter is most likely the best way to do this, as you have direct access to the variables you need.
2. Use :PreAuraSetPosition() to re-arrange the icon list. It's table.sort() compatible for a reason.
3. ???
4. Profit!
What you don't need for just aura sorting like this however is: an OnUpdate, duration, endTime and startTime is way more that you need for this. If you want to update some text, then you obviously will need this ofc tho'...