Mercurial > wow > buffalo2
diff Init.lua @ 3:3397aae1f44d
- use the correct key value when searching for action buttons
- handle pre-built frames from XML
author | Nenue |
---|---|
date | Thu, 31 Mar 2016 07:32:05 -0400 |
parents | 3dbcad2b387d |
children | 9455693fc290 |
line wrap: on
line diff
--- a/Init.lua Thu Mar 31 01:38:47 2016 -0400 +++ b/Init.lua Thu Mar 31 07:32:05 2016 -0400 @@ -6,7 +6,7 @@ local ADDON, A = ... Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent) local B = Veneer -local wipe, min, max, random, tinsert = table.wipe, math.min, math.max, math.random, table.insert +local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G local type, tostring, format = type, tostring, string.format A.frame = B @@ -15,6 +15,7 @@ local initOnced local modules = {} local queuedModules = {} +local checkForConfig = {} local moduleStack = { } @@ -247,6 +248,16 @@ --@end-non-debug@]===] end end + + + if #checkForConfig >= 1 then + local queuedFrame = tremove(checkForConfig) + while queuedFrame do + B.SetConfigLayers(queuedFrame) + B.InitXMLFrame(queuedFrame) + queuedFrame = tremove(checkForConfig) + end + end -- remove from existing end @@ -296,6 +307,7 @@ module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate') end modules[name] = module + B[name] = module if select('#', ...) >= 1 then local numDeps = select('#', ...) print(' '..numDeps..' deps detected') @@ -331,6 +343,7 @@ end B.RemoveConfigLayers = function(frame) + local print = B.fprint() print('|cFFFF0000RemoveConfigLayers', frame:GetName()) for i, subframe in pairs(layers) do @@ -368,4 +381,45 @@ end print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') +end + +--- Generic handlers for keeping track of XML-defined frames +B.OnLoad = function(self) + tinsert(checkForConfig, self) +end + +B.InitXMLFrame = function(self) + print('|cFF00FF00hello from '..self:GetName()) + + self:RegisterForDrag('LeftButton') + if not B.Conf.FramePosition then + B.Conf.FramePosition = {} + end + if B.Conf.FramePosition[self:GetName()] then + print('restoring frame position', unpack(B.Conf.FramePosition[self:GetName()])) + self:ClearAllPoints() + local anchorTo, relativePoint, x, y = unpack(B.Conf.FramePosition[self:GetName()]) + self:SetPoint(anchorTo, UIParent, relativePoint, x, y) + end +end + +B.OnDragStart = function(self) + self.xA = self:GetLeft() + self.yA = self:GetBottom() + self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) + print('acquire anchor', self:GetPoint(1)) + print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') + self:StartMoving() +end + +B.OnDragStop = function(self) + print(self:GetName(), 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') + local xB = self:GetLeft() - self.xA + local yB = self:GetBottom() - self.yA + print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) + + self:StopMovingOrSizing() + B.Conf.FramePosition[self:GetName()] = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} + B.InitXMLFrame(self) + end \ No newline at end of file