Mercurial > wow > buffalo2
comparison Init.lua @ 38:1f8f9cc3d956
- module integration brought up to speed with current frame management structure
| author | Nenue |
|---|---|
| date | Thu, 21 Apr 2016 11:36:41 -0400 |
| parents | e84d645c8ab8 |
| children | 756e8aeb040b |
comparison
equal
deleted
inserted
replaced
| 37:e84d645c8ab8 | 38:1f8f9cc3d956 |
|---|---|
| 285 | 285 |
| 286 if #checkForConfig >= 1 then | 286 if #checkForConfig >= 1 then |
| 287 local queuedFrame = tremove(checkForConfig) | 287 local queuedFrame = tremove(checkForConfig) |
| 288 while queuedFrame do | 288 while queuedFrame do |
| 289 B.SetConfigLayers(queuedFrame) | 289 B.SetConfigLayers(queuedFrame) |
| 290 B.InitXMLFrame(queuedFrame) | 290 B.UpdateXMLFrame(queuedFrame) |
| 291 queuedFrame = tremove(checkForConfig) | 291 queuedFrame = tremove(checkForConfig) |
| 292 end | 292 end |
| 293 end | 293 end |
| 294 -- remove from existing | 294 -- remove from existing |
| 295 end | 295 end |
| 419 end | 419 end |
| 420 | 420 |
| 421 print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') | 421 print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') |
| 422 end | 422 end |
| 423 | 423 |
| 424 local XMLFrame_SetEnabled = function(self, value) | 424 local XMLFrame_Enable = function(self, value) |
| 425 local name = self:GetName() | 425 local name = self:GetName() |
| 426 | 426 |
| 427 | 427 |
| 428 if not B.Conf[name] then | 428 if not B.Conf[name] then |
| 429 B.Conf[name] = { | 429 B.Conf[name] = { |
| 467 else | 467 else |
| 468 if self.OnDisable then | 468 if self.OnDisable then |
| 469 self:OnDisable() | 469 self:OnDisable() |
| 470 end | 470 end |
| 471 end | 471 end |
| 472 | |
| 473 | |
| 474 end | 472 end |
| 475 --- Generic handlers for keeping track of XML-defined frames | 473 --- Generic handlers for keeping track of XML-defined frames |
| 476 B.OnLoad = function(self) | 474 |
| 477 tinsert(checkForConfig, self) | 475 local XMLFrame_OnDragStart = function(self) |
| 478 self.SetEnabled = XMLFrame_SetEnabled | |
| 479 end | |
| 480 | |
| 481 B.InitXMLFrame = function(self) | |
| 482 local name = self:GetName() | |
| 483 print('|cFF00FF00hello from '.. name) | |
| 484 | |
| 485 if self.drag then | |
| 486 self:RegisterForDrag('LeftButton') | |
| 487 else | |
| 488 self:EnableMouse(false) | |
| 489 end | |
| 490 | |
| 491 if not B.Conf[name] then | |
| 492 B.Conf[name] = { | |
| 493 enabled = true, | |
| 494 } | |
| 495 end | |
| 496 local c = B.Conf[name] | |
| 497 | |
| 498 if c.position then | |
| 499 print('restoring frame position', unpack(c.position)) | |
| 500 self:ClearAllPoints() | |
| 501 local anchorTo, relativePoint, x, y = unpack(c.position) | |
| 502 self:SetPoint(anchorTo, UIParent, relativePoint, x, y) | |
| 503 else | |
| 504 local a, _, b, c, d = self:GetPoint(1) | |
| 505 print('seeding default position', a, b, c, d) | |
| 506 c.position = {a, b, c, d} | |
| 507 end | |
| 508 local state = c.enabled | |
| 509 self:SetEnabled(state) | |
| 510 end | |
| 511 | |
| 512 B.OnDragStart = function(self) | |
| 513 self.xA = self:GetLeft() | 476 self.xA = self:GetLeft() |
| 514 self.yA = self:GetBottom() | 477 self.yA = self:GetBottom() |
| 515 self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) | 478 self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) |
| 516 print('acquire anchor', self:GetPoint(1)) | 479 print('acquire anchor', self:GetPoint(1)) |
| 517 print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') | 480 print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') |
| 518 self:StartMoving() | 481 self:StartMoving() |
| 519 end | 482 end |
| 520 | 483 |
| 521 B.OnDragStop = function(self) | 484 local XMLFrame_OnDragStop = function(self) |
| 522 local name = self:GetName() | 485 local name = self:GetName() |
| 523 print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') | 486 print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') |
| 524 local xB = self:GetLeft() - self.xA | 487 local xB = self:GetLeft() - self.xA |
| 525 local yB = self:GetBottom() - self.yA | 488 local yB = self:GetBottom() - self.yA |
| 526 print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) | 489 print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) |
| 527 | 490 |
| 528 self:StopMovingOrSizing() | 491 self:StopMovingOrSizing() |
| 529 B.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} | 492 B.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} |
| 530 B.InitXMLFrame(self) | 493 B.UpdateXMLFrame(self) |
| 531 end | 494 end |
| 495 | |
| 496 B.RegisterModuleFrame = function(self, moduleName) | |
| 497 tinsert(checkForConfig, self) | |
| 498 self.Enable = XMLFrame_Enable | |
| 499 self.moduleName = moduleName | |
| 500 print('|cFF00FF00XML stuff related to '.. tostring(moduleName) .. ':', name) | |
| 501 end | |
| 502 | |
| 503 B.UpdateXMLFrame = function(self) | |
| 504 | |
| 505 local name = self:GetName() | |
| 506 | |
| 507 | |
| 508 if self.drag then | |
| 509 self:RegisterForDrag('LeftButton') | |
| 510 self:SetScript('OnDragStart', XMLFrame_OnDragStart) | |
| 511 if self.OnDragStop then | |
| 512 self:SetScript('OnDragStop', function(self, ...) | |
| 513 self:OnDragStop(self, ...) | |
| 514 XMLFrame_OnDragStop(self, ...) | |
| 515 end) | |
| 516 else | |
| 517 self:SetScript('OnDragStop', XMLFrame_OnDragStop) | |
| 518 end | |
| 519 else | |
| 520 self:EnableMouse(false) | |
| 521 end | |
| 522 | |
| 523 if not B.Conf[name] then | |
| 524 B.Conf[name] = { | |
| 525 enabled = self.enabled, | |
| 526 } | |
| 527 end | |
| 528 local c = B.Conf[name] | |
| 529 | |
| 530 if not c.position then | |
| 531 local a, _, b, c, d = self:GetPoint(1) | |
| 532 print('seeding default position', a, b, c, d) | |
| 533 c.position = {a, b, c, d } | |
| 534 else | |
| 535 | |
| 536 print('restoring frame position', unpack(c.position)) | |
| 537 self:ClearAllPoints() | |
| 538 local anchorTo, relativePoint, x, y = unpack(c.position) | |
| 539 self:SetPoint(anchorTo, UIParent, relativePoint, x, y) | |
| 540 end | |
| 541 self:Enable(c.enabled) | |
| 542 | |
| 543 | |
| 544 end |
