Mercurial > wow > reaction
comparison ExtraActionButton.lua @ 305:0211bcdfab70 stable
Merge 1.1 beta 12 to stable
| author | Flick |
|---|---|
| date | Wed, 14 Nov 2012 16:47:27 -0800 |
| parents | e337b39dc491 |
| children |
comparison
equal
deleted
inserted
replaced
| 294:30c9bdaad7a3 | 305:0211bcdfab70 |
|---|---|
| 1 local _, ns = ... | |
| 2 local ReAction = ns.ReAction | |
| 3 local L = ReAction.L | |
| 4 local format = string.format | |
| 5 | |
| 6 -- | |
| 7 -- ExtraAction Button class | |
| 8 -- | |
| 9 local buttonTypeID = "ExtraAction" | |
| 10 local Super = ReAction.Button.Action | |
| 11 local ExtraAction = setmetatable( | |
| 12 { | |
| 13 defaultBarConfig = { | |
| 14 type = buttonTypeID , | |
| 15 btnWidth = 52, | |
| 16 btnHeight = 52, | |
| 17 btnRows = 1, | |
| 18 btnColumns = 1, | |
| 19 spacing = 3, | |
| 20 buttons = { } | |
| 21 }, | |
| 22 | |
| 23 barType = L["Special Action Button"], | |
| 24 buttonTypeID = buttonTypeID | |
| 25 }, | |
| 26 { __index = Super } ) | |
| 27 | |
| 28 ReAction.Button.ExtraAction = ExtraAction | |
| 29 ReAction:RegisterBarType(ExtraAction) | |
| 30 | |
| 31 function ExtraAction:New( config, bar, idx, idHint ) | |
| 32 -- don't invoke the base ActionButton constructor, since it does a bunch of stuff that | |
| 33 -- we don't need. Instead, call the Button base constructor directly instead and | |
| 34 -- re-implement the bits of the ActionButton constructor that we actually need. | |
| 35 self = ReAction.Button.New(self, config, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) | |
| 36 | |
| 37 self.barConfig = bar:GetConfig() | |
| 38 | |
| 39 local f = self:GetFrame() | |
| 40 local barFrame = bar:GetFrame() | |
| 41 | |
| 42 self.rangeTimer = TOOLTIP_UPDATE_TIME | |
| 43 | |
| 44 self:SetActionIDPool("special-action",1) | |
| 45 config.actionID = self:AcquireActionID(config.actionID, idHint, true) | |
| 46 self.nPages = 1 | |
| 47 | |
| 48 -- compute the actual game action-ID from the extra bar offset page | |
| 49 local actionID = config.actionID + (GetExtraBarIndex() - 1)*NUM_ACTIONBAR_BUTTONS | |
| 50 self.actionID = actionID | |
| 51 f.action = actionID | |
| 52 | |
| 53 -- attribute setup | |
| 54 f:SetAttribute("type","action") | |
| 55 f:SetAttribute("checkselfcast", true) | |
| 56 f:SetAttribute("checkfocuscast", true) | |
| 57 f:SetAttribute("action", actionID) | |
| 58 f:SetAttribute("default-action", actionID) | |
| 59 f:SetAttribute("bar-idx",idx) | |
| 60 | |
| 61 -- non secure scripts | |
| 62 f:SetScript("OnEvent", function(frame, ...) self:OnEvent(...) end) | |
| 63 f:SetScript("OnEnter", function(frame) self:OnEnter() end) | |
| 64 f:SetScript("OnLeave", function(frame) self:OnLeave() end) | |
| 65 f:SetScript("OnAttributeChanged", function(frame, attr, value) self:OnAttributeChanged(attr, value) end) | |
| 66 f:SetScript("PostClick", function(frame, ...) self:PostClick(...) end) | |
| 67 f:SetScript("OnUpdate", function(frame, elapsed) self:OnUpdate(elapsed) end) | |
| 68 | |
| 69 -- event registration | |
| 70 for _, evt in pairs(self.eventList) do | |
| 71 f:RegisterEvent(evt) | |
| 72 end | |
| 73 | |
| 74 -- register to use the C cooldown implementation | |
| 75 SetActionUIButton(f, actionID, f.cooldown) | |
| 76 | |
| 77 -- attach to skinner | |
| 78 bar:SkinButton(self) | |
| 79 | |
| 80 self:Refresh() | |
| 81 | |
| 82 return self | |
| 83 end | |
| 84 | |
| 85 function ExtraAction:Destroy() | |
| 86 -- similarly, don't call the ActionButton destructor function, call the Button destructor function | |
| 87 ReAction.Button.Destroy(self) | |
| 88 end | |
| 89 | |
| 90 function ExtraAction:SetupBar(bar) | |
| 91 -- again don't call the ActionButton:SetupBar method, because it does a lot of things we don't need/want. | |
| 92 -- however the Button base class SetupBar method does need to be called. | |
| 93 ReAction.Button.SetupBar(self,bar) | |
| 94 | |
| 95 -- show/hide the bar based on whether we have an extrabar. Hook into the unitexists mechanism that the pet bar uses. | |
| 96 RegisterStateDriver(bar:GetFrame(), "unitexists", "[extrabar] show ; hide") | |
| 97 end | |
| 98 | |
| 99 function ExtraAction:ShowGrid() | |
| 100 -- override: do nothing | |
| 101 end | |
| 102 | |
| 103 function ExtraAction:ShowGridTemp( show ) | |
| 104 -- override: do nothing | |
| 105 end | |
| 106 | |
| 107 function ExtraAction:SetActionID() | |
| 108 -- override: action ID never changes | |
| 109 end | |
| 110 | |
| 111 function ExtraAction:RefreshPages() | |
| 112 -- override: action ID never changes | |
| 113 end | |
| 114 |
