View Single Post
Old 10-26-10, 03:45 PM   #14
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
I've had some issues with buffs not correctly updating myself. Basically, doing this ...
lua Code:
  1. header:SetScript('OnEvent', ParseAuras)
...before the headers are completely initialized seems to be a bad idea. I solved most of these problems by maintaining a structure like this:

lua Code:
  1. local nivBuffs = CreateFrame("Frame", "nivBuffs")
  2.  
  3. local buffHeader = CreateFrame("Frame", "nivBuffs_Buffs", nil, "SecureAuraHeaderTemplate")
  4. local debuffHeader = CreateFrame("Frame", "nivBuffs_Debuffs", nil, "SecureAuraHeaderTemplate")
  5.  
  6. do
  7.     local function setHeaderAttributes(header, template, filter, buff)
  8.         header:SetAttribute("unit", "player")
  9.         --set more attributes --
  10.     end
  11.  
  12.     setHeaderAttributes(buffHeader, "nivBuffButtonTemplate", "HELPFUL", true)
  13.     buffHeader:SetPoint(nivBuffDB.buffAnchorFrom, nivBuffDB.buffAnchorFrame, nivBuffDB.buffAnchorTo, nivBuffDB.buffXpos, nivBuffDB.buffYpos)
  14.     buffHeader:Show()
  15.  
  16.     setHeaderAttributes(debuffHeader, "nivDebuffButtonTemplate", "HARMFUL", false)
  17.     debuffHeader:SetPoint(nivBuffDB.debuffAnchorFrom, nivBuffDB.debuffAnchorFrame, nivBuffDB.debuffAnchorTo, nivBuffDB.debuffXpos, nivBuffDB.debuffYpos)
  18.     debuffHeader:Show()    
  19. end
  20.  
  21. --many local functions for updating --
  22.  
  23. local function updateStyle(self, event, unit)
  24.     --update style --
  25. end
  26.  
  27. -- hide blizz auras --
  28.  
  29. nivBuffs:RegisterEvent("PLAYER_ENTERING_WORLD")
  30. nivBuffs:RegisterEvent("UNIT_AURA")
  31. nivBuffs:SetScript("OnEvent", updateStyle)
Of course, you may also get more inspiration from my whole code, if that doesn't spoil too much of the fun for you.

Last edited by Luzzifus : 10-26-10 at 03:48 PM.
Luzzifus is offline