Mercurial > wow > buffalo2
comparison BuffFrame/BuffAnchors.lua @ 50:d7655c4e6e06 v1.0-release
disambiguate local module names
author | Nenue |
---|---|
date | Fri, 29 Apr 2016 10:52:43 -0400 |
parents | 16465f3fd919 |
children |
comparison
equal
deleted
inserted
replaced
49:16465f3fd919 | 50:d7655c4e6e06 |
---|---|
5 -- Created: 3/22/2016 3:10 AM | 5 -- Created: 3/22/2016 3:10 AM |
6 | 6 |
7 local MODULE = 'BuffFrame' | 7 local MODULE = 'BuffFrame' |
8 local _, A = ... | 8 local _, A = ... |
9 local B, _G = A.frame, _G | 9 local B, _G = A.frame, _G |
10 local buffFrame = B:RegisterModule(MODULE) | 10 local Aura = B:RegisterModule(MODULE) |
11 local type, unpack, select, pairs, ipairs, wipe = type, unpack, select, pairs, ipairs, table.wipe | 11 local type, unpack, select, pairs, ipairs, wipe = type, unpack, select, pairs, ipairs, table.wipe |
12 local min, ceil, mod, tonumber, tostring = min, ceil, mod, tonumber, tostring | 12 local min, ceil, mod, tonumber, tostring = min, ceil, mod, tonumber, tostring |
13 local CreateFrame = CreateFrame | 13 local CreateFrame = CreateFrame |
14 local print = B.print('Anchor') | 14 local print = B.print('Anchor') |
15 local fprint = B.fprint | 15 local fprint = B.fprint |
16 local bprint = B.print('AnchorFrame') | 16 local bprint = B.print('AnchorFrame') |
17 | 17 |
18 local GetAnchorFrame = function(name) | 18 local GetAnchorFrame = function(name) |
19 local c = buffFrame.displays[name].conf | 19 local c = Aura.displays[name].conf |
20 local anchors = buffFrame.anchors | 20 local anchors = Aura.anchors |
21 local anchorFrom, anchorParent, anchorTo, offsetX, offsetY = unpack(c.Anchor) | 21 local anchorFrom, anchorParent, anchorTo, offsetX, offsetY = unpack(c.Anchor) |
22 local print = bprint | 22 local print = bprint |
23 if anchors[name] and anchors[name].GetName then | 23 if anchors[name] and anchors[name].GetName then |
24 print('get', buffFrame.anchors[name]:GetName()) | 24 print('get', Aura.anchors[name]:GetName()) |
25 return buffFrame.anchors[name], anchorFrom, anchorParent, anchorTo, offsetX, offsetY | 25 return Aura.anchors[name], anchorFrom, anchorParent, anchorTo, offsetX, offsetY |
26 end | 26 end |
27 print('new frame', name) | 27 print('new frame', name) |
28 local frame = CreateFrame('Frame', name..'Anchor', UIParent, buffFrame.displays[name].anchorTemplate) | 28 local frame = CreateFrame('Frame', name..'Anchor', UIParent, Aura.displays[name].anchorTemplate) |
29 frame.conf = c | 29 frame.conf = c |
30 | 30 |
31 local x, dx, y, dy | 31 local x, dx, y, dy |
32 local Anchor_OnMouseDown = function() | 32 local Anchor_OnMouseDown = function() |
33 if c['Parent'] then | 33 if c['Parent'] then |
50 dy = frame:GetTop() - y | 50 dy = frame:GetTop() - y |
51 -- update config | 51 -- update config |
52 print('|cFFFFFF00**changing', name, 'anchor by', dx, dy) | 52 print('|cFFFFFF00**changing', name, 'anchor by', dx, dy) |
53 offsetX = offsetX + dx | 53 offsetX = offsetX + dx |
54 offsetY = offsetY + dy | 54 offsetY = offsetY + dy |
55 buffFrame.Conf[name .. 'Anchor'] = {anchorFrom, anchorParent, anchorTo, offsetX, offsetY } | 55 Aura.Conf[name .. 'Anchor'] = {anchorFrom, anchorParent, anchorTo, offsetX, offsetY } |
56 frame:SetPoint(anchorFrom, _G[anchorParent], anchorTo, offsetX, offsetY) | 56 frame:SetPoint(anchorFrom, _G[anchorParent], anchorTo, offsetX, offsetY) |
57 frame.isMoving = nil | 57 frame.isMoving = nil |
58 end | 58 end |
59 | 59 |
60 local AnchorButton_OnClick = function(self, anchor) | 60 local AnchorButton_OnClick = function(self, anchor) |
61 local point, parent, relative = anchor:GetPoint(1) | 61 local point, parent, relative = anchor:GetPoint(1) |
62 print('resetting anchors', point, parent:GetName(), relative) | 62 print('resetting anchors', point, parent:GetName(), relative) |
63 buffFrame.Conf[name..'Point'] = {point, relative} | 63 Aura.Conf[name..'Point'] = {point, relative} |
64 buffFrame.Conf[name..'RelativeX'] = (point:match('RIGHT')) and -1 or 1 | 64 Aura.Conf[name..'RelativeX'] = (point:match('RIGHT')) and -1 or 1 |
65 buffFrame.Conf[name..'RelativeY'] = (point:match('TOP')) and -1 or 1 | 65 Aura.Conf[name..'RelativeY'] = (point:match('TOP')) and -1 or 1 |
66 wipe(buffFrame.drawn[name]) | 66 wipe(Aura.drawn[name]) |
67 buffFrame.UpdateBuffs(name) | 67 Aura.UpdateBuffs(name) |
68 end | 68 end |
69 | 69 |
70 frame.OnUpdate = function(self, elapsed) | 70 frame.OnUpdate = function(self, elapsed) |
71 print(self:GetName(), elapsed) | 71 print(self:GetName(), elapsed) |
72 if self:IsMouseOver() then | 72 if self:IsMouseOver() then |
86 -- table addition | 86 -- table addition |
87 for i, anchorButton in ipairs(frame.anchorButton) do | 87 for i, anchorButton in ipairs(frame.anchorButton) do |
88 anchorButton:SetScript('OnClick', AnchorButton_OnClick) | 88 anchorButton:SetScript('OnClick', AnchorButton_OnClick) |
89 end | 89 end |
90 | 90 |
91 buffFrame.displays[name].anchor = frame | 91 Aura.displays[name].anchor = frame |
92 print('displays[name].anchor', buffFrame.displays[name].anchor:GetName()) | 92 print('displays[name].anchor', Aura.displays[name].anchor:GetName()) |
93 print('anchors[name]', buffFrame.anchors[name]:GetName()) | 93 print('anchors[name]', Aura.anchors[name]:GetName()) |
94 return frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY | 94 return frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY |
95 end | 95 end |
96 | 96 |
97 --- Handles the preliminary positioning calculation for buff guide anchors | 97 --- Handles the preliminary positioning calculation for buff guide anchors |
98 buffFrame.UpdateAnchorFrames = function(name) | 98 Aura.UpdateAnchorFrames = function(name) |
99 local print = fprint(name) | 99 local print = fprint(name) |
100 local c = buffFrame.displays[name].conf | 100 local c = Aura.displays[name].conf |
101 local frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY = GetAnchorFrame(name) | 101 local frame, anchorFrom, anchorParent, anchorTo, offsetX, offsetY = GetAnchorFrame(name) |
102 print('got', frame:GetName()) | 102 print('got', frame:GetName()) |
103 frame.buffs = buffFrame.guides[name] | 103 frame.buffs = Aura.guides[name] |
104 frame.heading:SetText(name) | 104 frame.heading:SetText(name) |
105 B.SetConfigLayers(frame) | 105 B.SetConfigLayers(frame) |
106 | 106 |
107 local buffMax = c['Max'] or 3 | 107 local buffMax = c['Max'] or 3 |
108 local perRow = c['PerRow'] or 2 | 108 local perRow = c['PerRow'] or 2 |