diff BuffFrame/BuffButton.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 1a322b92dbfa
children d7655c4e6e06
line wrap: on
line diff
--- a/BuffFrame/BuffButton.lua	Thu Apr 28 05:54:21 2016 -0400
+++ b/BuffFrame/BuffButton.lua	Thu Apr 28 06:58:13 2016 -0400
@@ -4,21 +4,22 @@
 -- @file-revision@ @file-hash@
 -- Created: 3/12/2016 12:47 AM
 local MODULE = 'BuffFrame'
-local _, A = ...
-local B, _G = A.frame, _G
+
+local _
+local B, _G = select(2,...).frame, _G
 local type, unpack, select, pairs, ipairs = _G.type, _G.unpack, _G.select, _G.pairs, _G.ipairs
 local min, ceil, mod, tonumber, tostring = _G.min, _G.ceil, _G.mod, _G.tonumber, _G.tostring
 local floor, wipe, max = _G.math.floor, _G.table.wipe, _G.math.max
 local CreateFrame, IsInGroup, GetCVarBool = _G.CreateFrame, _G.IsInGroup, _G.GetCVarBool
 local BuffFrame, ConsolidatedBuffs = _G.BuffFrame, _G.ConsolidatedBuffs
-local print, gprint, aprint, fprint = B.print('Buff'), B.print('SetGuides'), B.print('SetAnchors'), B.fprint
-local displays, anchors, guides, decors, positioned, drawn, zoom = B.displays, {}, {}, {}, {}, {}, {}
 local UnitAura, UnitName, RegisterStateDriver = _G.UnitAura, _G.UnitName, _G.RegisterStateDriver
 
 local M = B:RegisterModule(MODULE)
+local displays = M.displays
+local print, gprint, aprint, fprint = B.print('Buff'), B.print('SetGuides'), B.print('SetAnchors'), B.fprint
 
 M.GetBuffZoom = function(buffName)
-  local zoom = tonumber(B.displays[buffName].conf['Zoom']) / 100 / 2
+  local zoom = tonumber(M.displays[buffName].conf['Zoom']) / 100 / 2
   local zoomL, zoomU, zoomR, zoomD = zoom, zoom, 1-zoom, 1-zoom
   print(buffName, zoom)
   return function(self, ...)
@@ -50,7 +51,9 @@
 M.UpdateGuideFrames = function(buffName)
   refreshCount = refreshCount + 1
   local print = fprint()
-
+  print(buffName)
+  local displays, anchors = M.displays, M.anchors
+  local guides, decors = M.guides, M.decors
 
   local anchor = anchors[buffName]
   local c, g, d = displays[buffName].conf, guides[buffName], decors[buffName]
@@ -198,6 +201,8 @@
   local numBuffs = 0
   local actualIcons = auraType.actualIcons()
   local maxIcons = auraType.maxIcons
+  local guides, decors, anchors, drawn = M.guides, M.decors, M.anchors, M.drawn
+
   local anchor = anchors[buffName]
   local buffMax = c['Max']
   local consolidated = (anchor.contains and IsInGroup())
@@ -371,6 +376,7 @@
 
 M.PostBuffAnchors  = function()
   local print = fprint()
+  local anchors = M.anchors
   if M.ShowConsolidatedBuffs then
     M.UpdateRaidBuffs()
   end
@@ -391,6 +397,7 @@
 end
 
 M.UpdateBuffs = function(buttonName, forced)
+  local displays, drawn = M.displays, M.drawn
   local print = B.fprint(buttonName)
   local c = displays[buttonName].conf
   if drawn[buttonName] then
@@ -405,37 +412,4 @@
 end
 
 --- should only be called from user input
-print('init def')
-function M:OnInitialize ()
-  drawn = B.Abstract(B.displays, 'drawn')
-  -- Lesser extent of guide frames that have been positioned
-  positioned = B.Abstract(B.displays, 'positioned', positioned)
-  -- Backdrop style frame
-  decors = B.Abstract(B.displays, 'decorator', decors)
-  -- Static positioning frames
-  guides = B.Abstract(B.displays, 'guides', guides)
-  -- Anchor points for guides
-  anchors = B.Abstract(B.displays, 'anchor')
-  -- Stored functions for doing icon texture adjustments
-  zoom = B.Abstract(B.displays, 'zoom', zoom)
-
-  B:RegisterUnitEvent("UNIT_AURA", "player", "vehicle")
-  B:RegisterEvent("GROUP_ROSTER_UPDATE")
-  B:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
-  hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", M.PostBuffAnchors)
-  hooksecurefunc("RaidBuffTray_Update", M.UpdateRaidBuffs)
-end
-print('update def')
-function M:OnUpdate ()
-  M.ShowConsolidated = (IsInGroup() and GetCVarBool("consolidateBuffs"))
-  M.ShowMissingBuffs = (IsInGroup() and B.Conf.RaidShowMissing)
-
-  for name, auraType in pairs(displays) do
-    print(name, auraType)
-    M.UpdateBuffs(auraType.buffName, true)
-  end
-
-  M.UpdateAnchorAnchors()
-  M.UpdateRaidBuffs()
-  M.UpdateBuffsTodo()
-end
\ No newline at end of file
+print('init def')
\ No newline at end of file