view BuffFrame/BuffFrame.lua @ 48:9837069e366a

move BuffFrame-specific things out of Veneer.lua straighten out table hierarchy for BuffFrame module
author Nenue
date Thu, 28 Apr 2016 06:58:13 -0400
parents
children 16465f3fd919
line wrap: on
line source
--------------------------------------------
-- Veneer
-- Nick
-- @project-revision@ @project-hash@
-- @file-revision@ @file-hash@
-- Created: 4/28/2016 5:58 AM
--------------------------------------------

local B = select(2,...).frame
local M = B:RegisterModule('BuffFrame')

function M:OnInitialize()
  local displays = M.displays
  local c= M.Conf
  -- suffix tables

  M.drawn = B.Abstract(displays, 'drawn', M.drawn )
  -- Lesser extent of guide frames that have been positioned
  M.positioned = B.Abstract(displays, 'positioned', M.positioned)
  -- Backdrop style frame
  M.decors = B.Abstract(displays, 'decorator', M.decors)
  -- Static positioning frames
  M.guides = B.Abstract(displays, 'guides', M.guides)
  -- Anchor points for guides
  M.anchors = B.Abstract(displays, 'anchor', M.anchors)
  -- Stored functions for doing icon texture adjustments
  M.zoom = B.Abstract(displays, 'zoom', M.zoom )


  for name, display in pairs(displays) do
    display.conf = setmetatable({}, {
      __index = function(_, k)
        --print('config check '.. name .. k)
        return c[name .. k] or c['BuffButton' .. k]
      end,
      __newindex = function(_, k , v)
        c[name..k] = v
      end,
    })
  end

  M:RegisterUnitEvent("UNIT_AURA", "player", "vehicle")
  M:RegisterEvent("GROUP_ROSTER_UPDATE")
  M:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
  hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", M.PostBuffAnchors)
  hooksecurefunc("RaidBuffTray_Update", M.UpdateRaidBuffs)
end

function M:OnUpdate ()
  local displays = M.displays
  M.ShowConsolidated = (IsInGroup() and GetCVarBool("consolidateBuffs"))
  M.ShowMissingBuffs = (IsInGroup() and M.Conf.RaidShowMissing)

  for name, auraType in pairs(displays) do

    M.UpdateBuffs(auraType.buffName, true)
    print(name, auraType)
    _G[name..'Anchor']:EnableMouse(B.Conf.ConfigMode)
  end

  M.UpdateAnchorAnchors()
  M.UpdateRaidBuffs()
  M.UpdateBuffsTodo()
end