Mercurial > wow > buffalo2
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:a2396b03ce63 | 3:3397aae1f44d |
---|---|
4 -- OnEnable -- run when GetSpecialization() returns true | 4 -- OnEnable -- run when GetSpecialization() returns true |
5 | 5 |
6 local ADDON, A = ... | 6 local ADDON, A = ... |
7 Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent) | 7 Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent) |
8 local B = Veneer | 8 local B = Veneer |
9 local wipe, min, max, random, tinsert = table.wipe, math.min, math.max, math.random, table.insert | 9 local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove |
10 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G | 10 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G |
11 local type, tostring, format = type, tostring, string.format | 11 local type, tostring, format = type, tostring, string.format |
12 A.frame = B | 12 A.frame = B |
13 | 13 |
14 --- Cache tables | 14 --- Cache tables |
15 local initOnced | 15 local initOnced |
16 local modules = {} | 16 local modules = {} |
17 local queuedModules = {} | 17 local queuedModules = {} |
18 local checkForConfig = {} | |
18 local moduleStack = { | 19 local moduleStack = { |
19 } | 20 } |
20 | 21 |
21 --- Various region categories | 22 --- Various region categories |
22 B.displays = {} | 23 B.displays = {} |
243 print('Adding defaults from module ', name) | 244 print('Adding defaults from module ', name) |
244 VeneerData[name] = module.default | 245 VeneerData[name] = module.default |
245 --[===[@non-debug@ | 246 --[===[@non-debug@ |
246 end | 247 end |
247 --@end-non-debug@]===] | 248 --@end-non-debug@]===] |
249 end | |
250 end | |
251 | |
252 | |
253 if #checkForConfig >= 1 then | |
254 local queuedFrame = tremove(checkForConfig) | |
255 while queuedFrame do | |
256 B.SetConfigLayers(queuedFrame) | |
257 B.InitXMLFrame(queuedFrame) | |
258 queuedFrame = tremove(checkForConfig) | |
248 end | 259 end |
249 end | 260 end |
250 -- remove from existing | 261 -- remove from existing |
251 end | 262 end |
252 | 263 |
294 end | 305 end |
295 else | 306 else |
296 module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate') | 307 module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate') |
297 end | 308 end |
298 modules[name] = module | 309 modules[name] = module |
310 B[name] = module | |
299 if select('#', ...) >= 1 then | 311 if select('#', ...) >= 1 then |
300 local numDeps = select('#', ...) | 312 local numDeps = select('#', ...) |
301 print(' '..numDeps..' deps detected') | 313 print(' '..numDeps..' deps detected') |
302 for i = 1, numDeps do | 314 for i = 1, numDeps do |
303 local dep = select(i, ...) | 315 local dep = select(i, ...) |
329 print(' ', i, subframe:GetName()) | 341 print(' ', i, subframe:GetName()) |
330 end | 342 end |
331 end | 343 end |
332 | 344 |
333 B.RemoveConfigLayers = function(frame) | 345 B.RemoveConfigLayers = function(frame) |
346 | |
334 local print = B.fprint() | 347 local print = B.fprint() |
335 print('|cFFFF0000RemoveConfigLayers', frame:GetName()) | 348 print('|cFFFF0000RemoveConfigLayers', frame:GetName()) |
336 for i, subframe in pairs(layers) do | 349 for i, subframe in pairs(layers) do |
337 if subframe:GetParent() == frame then | 350 if subframe:GetParent() == frame then |
338 print('|cFFFF8800 ', subframe:GetParent():GetName(), '|cFFFFFF00', subframe:GetName()) | 351 print('|cFFFF8800 ', subframe:GetParent():GetName(), '|cFFFFFF00', subframe:GetName()) |
367 region[func](region) | 380 region[func](region) |
368 end | 381 end |
369 | 382 |
370 print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') | 383 print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') |
371 end | 384 end |
385 | |
386 --- Generic handlers for keeping track of XML-defined frames | |
387 B.OnLoad = function(self) | |
388 tinsert(checkForConfig, self) | |
389 end | |
390 | |
391 B.InitXMLFrame = function(self) | |
392 print('|cFF00FF00hello from '..self:GetName()) | |
393 | |
394 self:RegisterForDrag('LeftButton') | |
395 if not B.Conf.FramePosition then | |
396 B.Conf.FramePosition = {} | |
397 end | |
398 if B.Conf.FramePosition[self:GetName()] then | |
399 print('restoring frame position', unpack(B.Conf.FramePosition[self:GetName()])) | |
400 self:ClearAllPoints() | |
401 local anchorTo, relativePoint, x, y = unpack(B.Conf.FramePosition[self:GetName()]) | |
402 self:SetPoint(anchorTo, UIParent, relativePoint, x, y) | |
403 end | |
404 end | |
405 | |
406 B.OnDragStart = function(self) | |
407 self.xA = self:GetLeft() | |
408 self.yA = self:GetBottom() | |
409 self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) | |
410 print('acquire anchor', self:GetPoint(1)) | |
411 print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') | |
412 self:StartMoving() | |
413 end | |
414 | |
415 B.OnDragStop = function(self) | |
416 print(self:GetName(), 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') | |
417 local xB = self:GetLeft() - self.xA | |
418 local yB = self:GetBottom() - self.yA | |
419 print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) | |
420 | |
421 self:StopMovingOrSizing() | |
422 B.Conf.FramePosition[self:GetName()] = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} | |
423 B.InitXMLFrame(self) | |
424 | |
425 end |