# HG changeset patch # User Nenue # Date 1461841093 14400 # Node ID 9837069e366aea9fd344b4e19e69a0ab27610a2f # Parent 1a322b92dbfaec2b377364672675716106af872d move BuffFrame-specific things out of Veneer.lua straighten out table hierarchy for BuffFrame module diff -r 1a322b92dbfa -r 9837069e366a BuffFrame/BuffAnchors.lua --- 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) diff -r 1a322b92dbfa -r 9837069e366a BuffFrame/BuffButton.lua --- 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 diff -r 1a322b92dbfa -r 9837069e366a BuffFrame/BuffFrame.lua --- /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 diff -r 1a322b92dbfa -r 9837069e366a BuffFrame/BuffFrame.xml --- 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 @@ -