changeset 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 16465f3fd919
files BuffFrame/BuffAnchors.lua BuffFrame/BuffButton.lua BuffFrame/BuffFrame.lua BuffFrame/BuffFrame.xml BuffFrame/RaidBuffTray.lua Veneer.lua Veneer.xml
diffstat 7 files changed, 122 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/BuffFrame/BuffAnchors.lua	Thu Apr 28 05:54:21 2016 -0400
+++ b/BuffFrame/BuffAnchors.lua	Thu Apr 28 06:58:13 2016 -0400
@@ -16,15 +16,16 @@
 local bprint = B.print('AnchorFrame')
 
 local GetAnchorFrame = function(name)
-  local c = B.displays[name].conf
+  local c = buffFrame.displays[name].conf
+  local anchors = buffFrame.anchors
   local anchorFrom, anchorParent, anchorTo, offsetX, offsetY = unpack(c.Anchor)
   local print = bprint
-  if B.anchor[name] then
-    print('get', B.anchor[name]:GetName())
-    return B.anchor[name], anchorFrom, anchorParent, anchorTo, offsetX, offsetY
+  if anchors[name] and anchors[name].GetName then
+    print('get', buffFrame.anchors[name]:GetName())
+    return buffFrame.anchors[name], anchorFrom, anchorParent, anchorTo, offsetX, offsetY
   end
   print('new frame', name)
-  local frame = CreateFrame('Frame', name..'Anchor', UIParent, B.displays[name].anchorTemplate)
+  local frame = CreateFrame('Frame', name..'Anchor', UIParent, buffFrame.displays[name].anchorTemplate)
   frame.conf = c
 
   local x, dx, y, dy
@@ -51,7 +52,7 @@
     print('|cFFFFFF00**changing', name, 'anchor by', dx, dy)
     offsetX = offsetX + dx
     offsetY = offsetY + dy
-    B.Conf[name .. 'Anchor'] = {anchorFrom, anchorParent, anchorTo, offsetX, offsetY }
+    buffFrame.Conf[name .. 'Anchor'] = {anchorFrom, anchorParent, anchorTo, offsetX, offsetY }
     frame:SetPoint(anchorFrom, _G[anchorParent], anchorTo, offsetX, offsetY)
     frame.isMoving = nil
   end
@@ -59,11 +60,11 @@
   local AnchorButton_OnClick = function(self, anchor)
     local point, parent, relative = anchor:GetPoint(1)
     print('resetting anchors', point, parent:GetName(), relative)
-    B.Conf[name..'Point'] = {point, relative}
-    B.Conf[name..'RelativeX'] = (point:match('RIGHT')) and -1 or 1
-    B.Conf[name..'RelativeY'] = (point:match('TOP')) and -1 or 1
-    wipe(B.drawn[name])
-    B.UpdateBuffs(name)
+    buffFrame.Conf[name..'Point'] = {point, relative}
+    buffFrame.Conf[name..'RelativeX'] = (point:match('RIGHT')) and -1 or 1
+    buffFrame.Conf[name..'RelativeY'] = (point:match('TOP')) and -1 or 1
+    wipe(buffFrame.drawn[name])
+    buffFrame.UpdateBuffs(name)
   end
 
   frame.OnUpdate = function(self, elapsed)
@@ -87,19 +88,19 @@
     anchorButton:SetScript('OnClick', AnchorButton_OnClick)
   end
 
-  B.displays[name].anchor = frame
-  print(B.displays[name].anchor:GetName())
-  print(B.anchor[name]:GetName())
+  buffFrame.displays[name].anchor = frame
+  print('displays[name].anchor', buffFrame.displays[name].anchor:GetName())
+  print('anchors[name]', buffFrame.anchors[name]:GetName())
   return frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY
 end
 
 --- Handles the preliminary positioning calculation for buff guide anchors
 buffFrame.UpdateAnchorFrames = function(name)
   local print = fprint(name)
-  local c = B.displays[name].conf
+  local c = buffFrame.displays[name].conf
   local frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY = GetAnchorFrame(name)
   print('got', frame:GetName())
-  frame.buffs = B.guides[name]
+  frame.buffs = buffFrame.guides[name]
   frame.heading:SetText(name)
   B.SetConfigLayers(frame)
 
@@ -134,21 +135,24 @@
 
 --- Handles placement of anchors embedded within anchors (consolidated buffs, maybe temp enchant)
 buffFrame.UpdateAnchorAnchors = function()
+  local displays = buffFrame.displays
+  local c = buffFrame.Conf
+  local guides = buffFrame.guides
   local print = fprint()
-  for buttonName, d in pairs(B.displays) do
-    local c = B.displays[buttonName].conf
-    local frame =  B.anchor[buttonName]
+  for buttonName, d in pairs(displays) do
+    local c = displays[buttonName].conf
+    local frame =  buffFrame.anchors[buttonName]
     local parent, child = c.Parent, c.Position
 
     frame.parent = nil
-    if B.Conf[buttonName .. 'Parent'] and _G[B.Conf[buttonName .. 'Parent']..'Anchor'] then
+    if c[buttonName .. 'Parent'] and _G[c[buttonName .. 'Parent']..'Anchor'] then
 
-      local anchorAnchor = _G[B.Conf[buttonName .. 'Parent']..'Anchor']
-      local anchorTarget = B.guides[parent][child]
+      local anchorAnchor = _G[c[buttonName .. 'Parent']..'Anchor']
+      local anchorTarget = guides[parent][child]
       if anchorTarget then
         print('link', buttonName, 'to', parent, child)
-        print(parent, child, B.displays[parent].guides[child])
-        local ac = B.displays[parent].conf
+        print(parent, child, displays[parent].guides[child])
+        local ac = displays[parent].conf
         local anchorFrom, anchorTo = unpack(ac.Point)
         frame:ClearAllPoints()
         frame:SetPoint(anchorFrom, anchorTarget, anchorTo)
--- 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BuffFrame/BuffFrame.lua	Thu Apr 28 06:58:13 2016 -0400
@@ -0,0 +1,64 @@
+--------------------------------------------
+-- 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
\ No newline at end of file
--- a/BuffFrame/BuffFrame.xml	Thu Apr 28 05:54:21 2016 -0400
+++ b/BuffFrame/BuffFrame.xml	Thu Apr 28 06:58:13 2016 -0400
@@ -263,9 +263,9 @@
     </Layers>
   </Button>
 
-  <Script file="BuffFrame.lua" />
   <Script file="Constants.lua" />
   <Script file="BuffAnchors.lua" />
   <Script file="RaidBuffTray.lua" />
   <Script file="BuffButton.lua" />
+  <Script file="BuffFrame.lua" />
 </Ui>
\ No newline at end of file
--- a/BuffFrame/RaidBuffTray.lua	Thu Apr 28 05:54:21 2016 -0400
+++ b/BuffFrame/RaidBuffTray.lua	Thu Apr 28 06:58:13 2016 -0400
@@ -60,6 +60,9 @@
 
 --- Populates a list of targets needing a buff, fired by a handler
 local PlayerBuffTodo ={}
+local PlayerBuffStatus = {}
+local UnitClass, IsInGroup, GetNumGroupMembers, UnitAura = UnitClass, IsInGroup, GetNumGroupMembers, UnitAura
+local GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization = GetTalentInfoByID, GetActiveSpecGroup, GetStablePetInfo, GetSpecialization
 M.UpdateBuffStatus = function(aura, filters)
   if not PlayerBuffStatus[aura] then
     PlayerBuffStatus[aura] = {}
@@ -175,10 +178,11 @@
 -- Called once to setup the ConsolidatedBuffs stencil
 local consolidatedBuffsLoaded
 M.SetConsolidatedBuffs = function()
+  local displays = M.displays
   local print = fprint()
   c = displays.ConsolidatedBuff.conf
-  parentFrame = B.guides[c.Parent][c.Position]
-  raidbuffsFrame = B.anchor.ConsolidatedBuff
+  parentFrame = M.guides[c.Parent][c.Position]
+  raidbuffsFrame = M.anchors.ConsolidatedBuff
 
   B.SetConfigLayers(raidbuffsFrame)
   consolidatedBuffsLoaded = true
--- a/Veneer.lua	Thu Apr 28 05:54:21 2016 -0400
+++ b/Veneer.lua	Thu Apr 28 06:58:13 2016 -0400
@@ -131,7 +131,6 @@
 
 
 --- localize for speed
-local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays
 
 local ModulesCall = function(func, flag)
 
@@ -169,38 +168,21 @@
 end
 
 
+local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays
 --- Things that happen immediately upon entering world
 local InitOnce = function()
   print('entering world first time')
-  local defaults = B.ConfDefaults
+  local defaults = {}
   print('|cFFFFFF00Veneer|r')
   if not VeneerData then
     VeneerData = {}
     for k,v in pairs(defaults) do
-
-
       VeneerData[k] = v
     end
     print('Veneer defaults being used.')
   end
-
   B.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end})
 
-
-
-  -- suffix tables
-  for name, display in pairs(displays) do
-    display.conf = setmetatable({}, {
-      __index = function(_, k)
-        --print('config check '.. name .. k)
-        return B.Conf[name .. k] or B.Conf['BuffButton' .. k]
-      end,
-      __newindex = function(_, k , v)
-        B.Conf[name..k] = v
-      end,
-    })
-  end
-
   -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up
   -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next
   -- layer.
@@ -252,7 +234,6 @@
     i = i + 1
   until i > stackLevels
 
-
   for level, batch in ipairs(moduleStack) do
     print('config level', level)
     for name, module in pairs(batch) do
@@ -282,7 +263,7 @@
     end
   end
 
-
+  --- Pull in any XML templates
   if #checkForConfig >= 1 then
     local queuedFrame = tremove(checkForConfig)
     while queuedFrame do
@@ -291,7 +272,6 @@
       queuedFrame = tremove(checkForConfig)
     end
   end
-  -- remove from existing
 end
 
 --- Fires an update to all modules
@@ -393,26 +373,11 @@
   end
 end
 
-B.UpdateConfigLayers = function()
+B.ToggleGuideLayers = function()
   local print = B.fprint()
   local func = B.Conf.GuidesMode and 'Show' or 'Hide'
   local numAnchors = 0
-  for name, display in pairs(displays) do
-    numAnchors = numAnchors + 1
-    display.anchor:EnableMouse(B.Conf.GuidesMode)
-    if B.Conf.GuidesMode then
-      display.anchor:SetScript('OnUpdate', display.anchor.OnUpdate)
-    else
-      display.anchor:SetScript('OnUpdate', nil)
 
-      for i, anchorButton in ipairs(display.anchor.anchorButton) do
-        anchorButton:Hide()
-      end
-
-    end
-    --print(B.Conf.ConfigMode)
-    display.anchor:EnableMouse(B.Conf.ConfigMode)
-  end
   for id, region in pairs(layers) do
     --print(id, region:GetName(), func)
     region[func](region)
@@ -420,6 +385,10 @@
 
   --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames')
 end
+B.UpdateConfigLayers = function()
+  print('|cFFFF0000', debugstack())
+  B.ToggleGuideLayers()
+end
 
 local XMLFrame_Enable = function(self, value)
   local name = self:GetName()
--- a/Veneer.xml	Thu Apr 28 05:54:21 2016 -0400
+++ b/Veneer.xml	Thu Apr 28 06:58:13 2016 -0400
@@ -53,6 +53,7 @@
     <Color r="1" g="1" b="0" a="1" />
   </Font>
 
+  <Frame name="VeneerHandlerTemplate" parent="UIParent" virtual="true" />
 
   <Frame name="Veneer" hidden="true" enableMouse="true" movable="true" parent="UIParent" frameStrata="DIALOG">
     <Size x="400" y="400" />