Mercurial > wow > reaction
comparison Overlay.lua @ 90:7cabc8ac6c16
Updates for wow 3.0
- TOC update
- updated changed APIs/frame names
- rewrote state code per new SecureHandlers API
- cleaned up Bar, ActionButton code
- removed AceLibrary/Dewdrop, menu from bar right-click
- fixed various small bugs
Updated WowAce external locations
Updated README.html
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Wed, 15 Oct 2008 16:29:41 +0000 |
| parents | 42ec2938d65a |
| children | 5f1d7a81317c |
comparison
equal
deleted
inserted
replaced
| 89:491a6ffe7260 | 90:7cabc8ac6c16 |
|---|---|
| 1 local ReAction = ReAction | 1 local ReAction = ReAction |
| 2 local L = ReAction.L | 2 local L = ReAction.L |
| 3 local CreateFrame = CreateFrame | 3 local CreateFrame = CreateFrame |
| 4 local InCombatLockdown = InCombatLockdown | 4 local InCombatLockdown = InCombatLockdown |
| 5 local floor = math.floor | 5 local floor = math.floor |
| 6 local min = math.min | 6 local min = math.min |
| 7 local format = string.format | 7 local format = string.format |
| 8 local GameTooltip = GameTooltip | 8 local GameTooltip = GameTooltip |
| 9 local Bar = ReAction.Bar | |
| 10 local GetSize = Bar.GetSize | |
| 11 local GetButtonSize = Bar.GetButtonSize | |
| 12 local GetButtonGrid = Bar.GetButtonGrid | |
| 13 local SetSize = Bar.SetSize | |
| 14 local SetAnchor = Bar.SetAnchor | |
| 15 local SetButtonSize = Bar.SetButtonSize | |
| 16 local SetButtonGrid = Bar.SetButtonGrid | |
| 17 local ApplyAnchor = Bar.ApplyAnchor | |
| 9 | 18 |
| 10 ReAction:UpdateRevision("$Revision$") | 19 ReAction:UpdateRevision("$Revision$") |
| 11 | |
| 12 -- Looking for a lightweight AceConfig3-struct-compatible | |
| 13 -- replacement for Dewdrop (e.g. forthcoming AceConfigDropdown-3.0?). | |
| 14 -- Considering Blizzard's EasyMenu/UIDropDownMenu, but that's | |
| 15 -- a bit tricky to convert from AceConfig3-struct | |
| 16 local Dewdrop = AceLibrary("Dewdrop-2.0") | |
| 17 | |
| 18 local function OpenMenu (frame, opts) | |
| 19 Dewdrop:Open(frame, "children", opts, "cursorX", true, "cursorY", true) | |
| 20 end | |
| 21 | |
| 22 local function CloseMenu(frame) | |
| 23 if Dewdrop:GetOpenedParent() == frame then | |
| 24 Dewdrop:Close() | |
| 25 end | |
| 26 end | |
| 27 | |
| 28 local function ShowMenu(bar) | |
| 29 if not bar.menuOpts then | |
| 30 bar.menuOpts = { | |
| 31 type = "group", | |
| 32 args = { | |
| 33 openConfig = { | |
| 34 type = "execute", | |
| 35 name = L["Settings..."], | |
| 36 desc = L["Open the editor for this bar"], | |
| 37 func = function() CloseMenu(bar.controlFrame); ReAction:ShowEditor(bar) end, | |
| 38 disabled = InCombatLockdown, | |
| 39 order = 1 | |
| 40 }, | |
| 41 delete = { | |
| 42 type = "execute", | |
| 43 name = L["Delete Bar"], | |
| 44 desc = L["Remove the bar from the current profile"], | |
| 45 confirm = L["Are you sure you want to remove this bar?"], | |
| 46 func = function() ReAction:EraseBar(bar) end, | |
| 47 order = 2 | |
| 48 }, | |
| 49 } | |
| 50 } | |
| 51 end | |
| 52 OpenMenu(bar.controlFrame, bar.menuOpts) | |
| 53 end | |
| 54 | |
| 55 | 20 |
| 56 -- | 21 -- |
| 57 -- Bar config overlay | 22 -- Bar config overlay |
| 58 -- | 23 -- |
| 59 -- localize some of these for small OnUpdate performance boost | 24 |
| 60 local Bar = ReAction.Bar | 25 local function StoreSize(bar) |
| 61 local GetSize = Bar.GetSize | 26 local f = bar:GetFrame() |
| 62 local GetButtonSize = Bar.GetButtonSize | 27 SetSize( bar, f:GetWidth(), f:GetHeight() ) |
| 63 local GetButtonGrid = Bar.GetButtonGrid | 28 end |
| 64 local SetSize = Bar.SetSize | |
| 65 local SetButtonSize = Bar.SetButtonSize | |
| 66 local SetButtonGrid = Bar.SetButtonGrid | |
| 67 local ApplyAnchor = Bar.ApplyAnchor | |
| 68 | 29 |
| 69 local function StoreExtents(bar) | 30 local function StoreExtents(bar) |
| 70 local f = bar:GetFrame() | 31 local f = bar:GetFrame() |
| 71 local point, relativeTo, relativePoint, x, y = f:GetPoint(1) | 32 SetAnchor( bar, f:GetPoint(1) ) |
| 72 relativeTo = relativeTo or f:GetParent() | 33 SetSize( bar, f:GetWidth(), f:GetHeight() ) |
| 73 local anchorTo | |
| 74 for name, b in ReAction:IterateBars() do | |
| 75 if b and b:GetFrame() == relativeTo then | |
| 76 anchorTo = name | |
| 77 break | |
| 78 end | |
| 79 end | |
| 80 anchorTo = anchorTo or relativeTo:GetName() | |
| 81 local c = bar.config | |
| 82 c.anchor = point | |
| 83 c.anchorTo = anchorTo | |
| 84 c.relativePoint = relativePoint | |
| 85 c.x = x | |
| 86 c.y = y | |
| 87 c.width, c.height = f:GetWidth(), f:GetHeight() | |
| 88 end | |
| 89 | |
| 90 local function StoreSize(bar) | |
| 91 local f = bar:GetFrame() | |
| 92 local c = bar.config | |
| 93 c.width, c.height = f:GetWidth(), f:GetHeight() | |
| 94 end | 34 end |
| 95 | 35 |
| 96 local function RecomputeButtonSize(bar) | 36 local function RecomputeButtonSize(bar) |
| 97 local w, h = GetSize(bar) | 37 local w, h = GetSize(bar) |
| 98 local bw, bh = GetButtonSize(bar) | 38 local bw, bh = GetButtonSize(bar) |
| 447 label:SetShadowColor(0,0,0,1) | 387 label:SetShadowColor(0,0,0,1) |
| 448 label:SetShadowOffset(2,-2) | 388 label:SetShadowOffset(2,-2) |
| 449 label:SetTextColor(1,1,1,1) | 389 label:SetTextColor(1,1,1,1) |
| 450 label:SetText(bar:GetName()) | 390 label:SetText(bar:GetName()) |
| 451 label:Show() | 391 label:Show() |
| 452 bar.controlLabelString = label -- so that bar:SetName() can update it | 392 bar.controlLabelString = label -- so that bar:SetLabel() can update it |
| 453 | 393 |
| 454 local function StopResize() | 394 local function StopResize() |
| 455 f:StopMovingOrSizing() | 395 f:StopMovingOrSizing() |
| 456 f.isMoving = false | 396 f.isMoving = false |
| 457 f:SetScript("OnUpdate",nil) | 397 f:SetScript("OnUpdate",nil) |
| 458 StoreSize(bar) | 398 StoreSize(bar) |
| 459 ClampToButtons(bar) | 399 ClampToButtons(bar) |
| 460 ApplyAnchor(bar) | 400 --ApplyAnchor(bar) |
| 461 ReAction:RefreshOptions() | 401 ReAction:RefreshOptions() |
| 462 end | 402 end |
| 463 | 403 |
| 464 -- edge drag handles | 404 -- edge drag handles |
| 465 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do | 405 for _, point in pairs({"LEFT","TOP","RIGHT","BOTTOM"}) do |
| 646 | 586 |
| 647 control:SetScript("OnLeave", HideGameTooltip) | 587 control:SetScript("OnLeave", HideGameTooltip) |
| 648 | 588 |
| 649 control:SetScript("OnClick", | 589 control:SetScript("OnClick", |
| 650 function() | 590 function() |
| 651 ShowMenu(bar) | 591 ReAction:ShowEditor(bar) |
| 652 end | 592 end |
| 653 ) | 593 ) |
| 654 | 594 |
| 595 control:Raise() | |
| 596 | |
| 655 return control | 597 return control |
| 656 end | 598 end |
| 657 | 599 |
| 658 | 600 |
| 659 -- export the ShowControls method to the Bar prototype | 601 -- export methods to the Bar prototype |
| 660 | 602 |
| 661 function Bar:ShowControls(show) | 603 function Bar:ShowControls(show) |
| 662 if show then | 604 if show then |
| 663 if not self.controlFrame then | 605 if not self.controlFrame then |
| 664 self.controlFrame = CreateControls(self) | 606 self.controlFrame = CreateControls(self) |
| 665 end | 607 end |
| 666 self.controlFrame:Show() | 608 self.controlFrame:Show() |
| 667 self.controlFrame:Raise() | 609 self.controlFrame:Raise() |
| 668 elseif self.controlFrame then | 610 elseif self.controlFrame then |
| 669 CloseMenu(self.controlFrame) | |
| 670 self.controlFrame:Hide() | 611 self.controlFrame:Hide() |
| 671 end | 612 end |
| 672 end | 613 end |
| 673 | 614 |
| 674 | 615 function Bar:SetLabel(name) |
| 616 if self.controlLabelString then | |
| 617 self.controlLabelString:SetText(self.name) | |
| 618 end | |
| 619 end |
