Quantcast Any idea to consolidate the bolster buffs? - WoWInterface
Thread Tools Display Modes
04-22-18, 08:33 PM   #1
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
Any idea to consolidate the bolster buffs?

Is it possible to consolidate all the bolster buffs into one?
  Reply With Quote
04-23-18, 02:03 AM   #2
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
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

Last edited by siweia : 04-23-18 at 02:17 AM.
  Reply With Quote
04-23-18, 02:06 AM   #3
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
Kind of stuck, it seems like not affect anything.
  Reply With Quote
04-23-18, 02:27 AM   #4
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,025
: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.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
04-23-18, 02:28 AM   #5
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
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
  Reply With Quote
04-23-18, 06:09 AM   #6
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
Not working either
The way I did in customFilter, not just show one icon as I thought.
  Reply With Quote
04-24-18, 11:37 AM   #7
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 450
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.
  Reply With Quote
04-26-18, 09:07 AM   #8
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
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

Last edited by siweia : 04-26-18 at 12:24 PM.
  Reply With Quote
04-26-18, 11:00 AM   #9
siweia
A Warpwood Thunder Caller
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 97
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.

Last edited by siweia : 04-27-18 at 02:00 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Any idea to consolidate the bolster buffs?

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