WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Any idea to consolidate the bolster buffs? (https://www.wowinterface.com/forums/showthread.php?t=56173)

siweia 04-22-18 08:33 PM

Any idea to consolidate the bolster buffs?
 
Is it possible to consolidate all the bolster buffs into one?

siweia 04-23-18 02:03 AM

Code:

local function postUpdateAura (element, unit)
  element.bolster, element.bolsterIndex = 0, 0

  local visibleBuffs = element.visibleBuffs
  for i = 1 , visibleBuffs do
    local name, _, _, _, _, _, _, _, _, _, spellID = UnitAura(unit, i, "HELPFUL")
    if name and spellID == 209859 then
      element.bolster = element.bolster + 1
      if element.bolster > 1 then
        element[i]:Hide()
        visibleBuffs = visibleBuffs - 1
      else
        element[i]:Show()
        element.bolsterIndex = i
      end

      element[element.bolsterIndex].count:SetText(element.bolster)
    end

    element.visibleBuffs = visibleBuffs
end


siweia 04-23-18 02:06 AM

Kind of stuck, it seems like not affect anything.

haste 04-23-18 02:27 AM

:PostUpdate runs after anchoring is done. The sanest solution would probably be to implement a :CustomFilter . Alternatively you could probably abuse :PreSetPosition to do what you want.

siweia 04-23-18 02:28 AM

Code:

local function customFilter(element, _, _, name, _, _, _, _, _, _, _, _, _, spellID)
  element.bolster = element.bolster or 0

  if name and spellID == 209859 then
    element.bolster = element.bolster + 1

    if element.bolster > 1 then
      return true
    else
      return false
    end
  end

end

local function postUpdateAura(element, unit)
  local visibleBuffs = element.visibleBuffs
  local found
  for i = 1, visibleBuffs do
    local name, _, _, _, _, _, _, _, _, _, spellID = UnitAura(unit, i, "HELPFUL")
    if name and spellID == 209859 then
      element[i].count:SetText(element.bolster)
      found = true
    end
  end

  if not found then element.bolster = 0 end
end


siweia 04-23-18 06:09 AM

Not working either :(
The way I did in customFilter, not just show one icon as I thought.

Rainrider 04-24-18 11:37 AM

Use buffs.PreUpdate to reset buffs.bolster.
Increment buffs.bolster and return false in your custom filter for every spellID == 209859.
Use buffs.PostUpdate to set the stacks and display your icon.

The problem here is if you try to display an aura oUF has not yet created a button for, so you will have to override buff.CreateIcon and call it.

Another solution would be to return true for the first bolster buff you encounter in your custom filter and save the index for it. Return false for all bolster buffs afterwards to hide them. Then in buffs.PostUpdate just update the buff button at the index you saved previously. This won't work if you use sort your buffs.

siweia 04-26-18 09:07 AM

Thank you Rainrider, you wake me up.

Code:

local function preUpdateForBolster(element)
        element.bolster = 0
        element.bolsterIndex = nil
end

local function customFilterForBolster(element, _, button, name, _, _, _, _, _, _, _, _, _, spellID)
        if name and spellID == 209859 then
                element.bolster = element.bolster + 1
                if not element.bolsterIndex then
                        element.bolsterIndex = button
                        return true
                end
        end
end

local function postUpdateForBolster(element)
        if not element.bolsterIndex then return end
        for _, button in pairs(element) do
                if button == element.bolsterIndex then
                        button.count:SetText(element.bolster)
                        return
                end
        end
end


siweia 04-26-18 11:00 AM

Hmmm, it works perfectly now. Although it is not Bolstering this week in mythic +.

If someone interested about this and want to have a go, you can just change the customfilter as below to test it.
Code:

local function customFilterForBolster(element, _, button, name, _, _, _, _, _, _, _, _, _, spellID)
        if name then
                element.bolster = element.bolster + 1
                if not element.bolsterIndex then
                        element.bolsterIndex = button
                        return true
                end
        end
end

And there would be just one icon shows up and it counts how many auras the unit owns.


All times are GMT -6. The time now is 10:28 PM.

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