WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Relationship between FilterAura and button? (https://www.wowinterface.com/forums/showthread.php?t=59347)

siweia 11-15-22 02:59 AM

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

siweia 11-15-22 05:11 AM

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

lightspark 11-15-22 08:51 AM

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

lightspark 11-15-22 10:02 AM

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.

siweia 11-27-22 05:34 AM

Quote:

Originally Posted by lightspark (Post 341599)
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?


All times are GMT -6. The time now is 07:34 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI