View Single Post
10-27-10, 03:02 PM   #20
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
I've put together a very basic implemention of the SecureAuraHeaderTemplate using no libs or whatever for those who need it:

MyAddon.lua
lua Code:
  1. local function UpdateStyle(header, button, unit)
  2.     local name = UnitAura(unit, button:GetID(), header:GetAttribute('filter'))
  3.  
  4.     -- insert magic
  5. end
  6.  
  7. local function OnEvent(self, event, unit)
  8.     local secureUnit = SecureButton_GetUnit(self)
  9.     if(not self:IsShown() or (unit and unit ~= secureUnit)) then return end
  10.  
  11.     local col = self:GetAttribute('wrapAfter')
  12.     local row = self:GetAttribute('maxWraps')
  13.     for index = 1, col * row do
  14.         local child = self:GetAttribute('child' .. index)
  15.         if(child) then
  16.             UpdateStyle(self, child, secureUnit)
  17.         end
  18.     end
  19. end
  20.  
  21. local header = CreateFrame('Frame', nil, UIParent, 'SecureAuraHeaderTemplate')
  22. header:SetPoint('CENTER')
  23. header:HookScript('OnEvent', OnEvent)
  24.  
  25. -- Required attributes
  26. header:SetAttribute('unit', 'player')
  27. header:SetAttribute('minWidth', 350)
  28. header:SetAttribute('minHeight', 140)
  29. header:SetAttribute('template', 'MyAddonAuraTemplate') -- your XML template
  30. header:SetAttribute('filter', 'HELPFUL')
  31. header:SetAttribute('xOffset', 35)
  32. header:SetAttribute('wrapYOffset', 35)
  33. header:SetAttribute('wrapAfter', 10)
  34. header:SetAttribute('maxWraps', 4)
  35. header:Show()
  36.  
  37. -- Force update on login
  38. OnEvent(header)
  39.  
  40.  
  41. --[[
  42.     Full list of attributes
  43.  
  44.     filter = [STRING] -- a pipe-separated list of aura filter options ("RAID" will be ignored)
  45.     separateOwn = [NUMBER] -- indicate whether buffs you cast yourself should be separated before (1) or after (-1) others. If 0 or nil, no separation is done.
  46.     sortMethod = ["INDEX", "NAME", "TIME"] -- defines how the group is sorted (Default: "INDEX")
  47.     sortDirection = ["+", "-"] -- defines the sort order (Default: "+")
  48.     groupBy = [nil, auraFilter] -- if present, a series of comma-separated filters, appended to the base filter to separate auras into groups within a single stream
  49.     includeWeapons = [nil, NUMBER] -- The aura sub-stream before which to include temporary weapon enchants. If nil or 0, they are ignored.
  50.     consolidateTo = [nil, NUMBER] -- The aura sub-stream before which to place a proxy for the consolidated header. If nil or 0, consolidation is ignored.
  51.     consolidateDuration = [nil, NUMBER] -- the minimum total duration an aura should have to be considered for consolidation (Default: 30)
  52.     consolidateThreshold = [nil, NUMBER] -- buffs with less remaining duration than this many seconds should not be consolidated (Default: 10)
  53.     consolidateFraction = [nil, NUMBER] -- The fraction of remaining duration a buff should still have to be eligible for consolidation (Default: .10)
  54.  
  55.     template = [STRING] -- the XML template to use for the unit buttons. If the created widgets should be something other than Buttons, append the Widget name after a comma.
  56.     weaponTemplate = [STRING] -- the XML template to use for temporary enchant buttons. Can be nil if you preset the tempEnchant1 and tempEnchant2 attributes, or if you don't include temporary enchants.
  57.     consolidateProxy = [STRING|Frame] -- Either the button which represents consolidated buffs, or the name of the template used to construct one.
  58.     consolidateHeader = [STRING|Frame] -- Either the aura header which contains consolidated buffs, or the name of the template used to construct one.
  59.  
  60.     point = [STRING] -- a valid XML anchoring point (Default: "TOPRIGHT")
  61.     minWidth = [nil, NUMBER] -- the minimum width of the container frame
  62.     minHeight = [nil, NUMBER] -- the minimum height of the container frame
  63.     xOffset = [NUMBER] -- the x-Offset to use when anchoring the unit buttons (Default: width)
  64.     yOffset = [NUMBER] -- the y-Offset to use when anchoring the unit buttons (Default: height)
  65.     wrapAfter = [NUMBER] -- begin a new row or column after this many auras
  66.     wrapXOffset = [NUMBER] -- the x-offset from one row or column to the next
  67.     wrapYOffset = [NUMBER] -- the y-offset from one row or column to the next
  68.     maxWraps = [NUMBER] -- limit the number of rows or columns
  69. --]]

MyAddon.xml:
xml Code:
  1. <Ui xmlns='http://www.blizzard.com/wow/ui'>
  2.     <Button name='MyAddonAuraTemplate' inherits='SecureActionButtonTemplate' virtual='true'>
  3.         <Size x='26' y='26'/>
  4.         <Attributes>
  5.             <Attribute name='type' value='cancelaura'/>
  6.         </Attributes>
  7.         <Scripts>
  8.             <OnLoad>
  9.                 self:RegisterForClicks('RightButtonUp')
  10.             </OnLoad>
  11.             <OnEnter>
  12.                 GameTooltip:SetOwner(self, 'ANCHOR_BOTTOMLEFT')
  13.                 GameTooltip:SetUnitAura(SecureButton_GetUnit(self:GetParent()), self:GetID(), self:GetParent():GetAttribute('filter'))
  14.             </OnEnter>
  15.             <OnLeave function='GameTooltip_Hide'/>
  16.         </Scripts>
  17.     </Button>
  18. </Ui>

Last edited by p3lim : 10-28-10 at 08:15 AM. Reason: typos