Thread Tools Display Modes
11-15-22, 02:59 AM   #1
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
Relationship between FilterAura and button?

Before oUF 11, I use customFilter to consolidate all bolster in mythic plus.

The code is what I did before, but in oUF 11, button no longer accessable in FilterAura.

Lua Code:
  1. local function PreUpdate(element)
  2.     element.bolster = 0
  3.     element.bolsterIndex = nil
  4. end
  5.  
  6. local function CustomFilter(element, unit, button, name, _, _, _, _, _, _, _, _, spellID)
  7.     if name and spellID == 209859 then
  8.         element.bolster = element.bolster + 1
  9.         if not element.bolsterIndex then
  10.             element.bolsterIndex = button
  11.             return true
  12.         end
  13.     end
  14. end
  15.  
  16. local function PostUpdate(element)
  17.     local button = element.bolsterIndex
  18.     if button then
  19.         button.Count:SetText(element.bolster)
  20.     end
  21. end

Last edited by siweia : 11-16-22 at 12:05 AM.
  Reply With Quote
11-15-22, 05:11 AM   #2
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
What I currently do is add a new attribute in 'updateAura'.

Code:
button.spellID = aura.spellId
Lua Code:
  1. local BOLSTER_ID = 209859
  2.  
  3. local function PreUpdate(element)
  4.     element.numBolster = 0
  5. end
  6.  
  7. local function FilterAura(element, _, data)
  8.     if data.name and data.spellId == BOLSTER_ID then
  9.         element.numBolster = element.numBolster + 1
  10.         return element.numBolster == 1
  11.     end
  12. end
  13.  
  14. local function PostUpdate(element)
  15.     if element.numBolster == 0 then return end
  16.  
  17.     for i = 1, #element.sortedBuffs do
  18.         local button = element[i]
  19.         if button.spellID == BOLSTER_ID then
  20.             button.Count:SetText(element.numBolster)
  21.             break
  22.         end
  23.     end
  24. end
  Reply With Quote
11-15-22, 08:51 AM   #3
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Well, it had to happen because the update process happens in stages now, filtering > sorting > redrawing. Buttons get updated only at the redrawing stage, but before that we work with raw aura data. If I were you, I'd use PostUpdateButton instead of PostUpdate since it gives you both the button and the aura data, but you won't need the latter in this case. I drycoded it, but this should do the trick.

Lua Code:
  1. local BOLSTER_ID = 209859
  2.  
  3. local function PreUpdate(element)
  4.     element.bolsterStacks = 0
  5.     element.bolsterInstanceID = nil
  6. end
  7.  
  8. local function FilterAura(element, _, data)
  9.     if data.name and data.spellId == BOLSTER_ID then
  10.         if not element.bolsterInstanceID then
  11.             element.bolsterInstanceID = data.auraInstanceID
  12.         end
  13.  
  14.         element.bolsterStacks = element.bolsterStacks + 1
  15.         return element.bolsterStacks == 1
  16.     end
  17. end
  18.  
  19. local function PostUpdateButton(element, button)
  20.     if not element.bolsterInstanceID then return end
  21.     if element.bolsterInstanceID ~= button.auraInstanceID then return end
  22.  
  23.     button.Count:SetText(element.bolsterStacks)
  24. end
__________________
  Reply With Quote
11-15-22, 10:02 AM   #4
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Btw, your code will only work properly during full updates. But worry not, there's this new PR in the works atm, it'll allow you to mess with stuff via PostUpdateInfo before it's sent over to sorting.
__________________
  Reply With Quote
11-27-22, 05:34 AM   #5
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
Originally Posted by lightspark View Post
Btw, your code will only work properly during full updates. But worry not, there's this new PR in the works atm, it'll allow you to mess with stuff via PostUpdateInfo before it's sent over to sorting.
Could you provide an example for me, with PostUpdateInfo?
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Relationship between FilterAura and button?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off