Mercurial > wow > buffalo2
diff BuffFrame/BuffAnchors.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 | 16465f3fd919 |
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)