Mercurial > wow > reaction
comparison classes/ActionButton.lua @ 129:28b430de5875
More fixes for new action button
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Fri, 06 Mar 2009 23:44:33 +0000 |
parents | 729232aeeb5e |
children | e39d80bb0b7a |
comparison
equal
deleted
inserted
replaced
128:729232aeeb5e | 129:28b430de5875 |
---|---|
1 local ReAction = ReAction | 1 local ReAction = ReAction |
2 local L = ReAction.L | 2 local L = ReAction.L |
3 local _G = _G | 3 local _G = _G |
4 local CreateFrame = CreateFrame | 4 local CreateFrame = CreateFrame |
5 local GetBindingKey = GetBindingKey | |
6 local format = string.format | 5 local format = string.format |
7 local IsUsableAction = IsUsableAction | 6 local IsUsableAction = IsUsableAction |
8 local IsEquippedAction = IsEquippedAction | 7 local IsEquippedAction = IsEquippedAction |
9 local IsConsumableAction = IsConsumableAction | 8 local IsConsumableAction = IsConsumableAction |
10 local IsStackableAction = IsStackableAction | 9 local IsStackableAction = IsStackableAction |
118 end | 117 end |
119 ]] | 118 ]] |
120 | 119 |
121 local _onReceiveDrag = -- function(self, button, kind, value, ...) | 120 local _onReceiveDrag = -- function(self, button, kind, value, ...) |
122 [[ | 121 [[ |
123 if kind == "spell" or kind == "item" or kind == "macro" then | 122 if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then |
124 -- assume it's a valid action | 123 return kind, value, ... |
125 self:SetAttribute("hasaction-"..self:GetAttribute("action"),true) | 124 end |
126 end | 125 self:SetAttribute("hasaction-"..self:GetAttribute("action"),true) |
127 return "action", self:GetAttribute("action") | 126 return "action", self:GetAttribute("action") |
128 ]] | 127 ]] |
129 | 128 |
130 -- | 129 -- |
131 -- private | 130 -- private |
160 ReAction.Button.Action = Action | 159 ReAction.Button.Action = Action |
161 | 160 |
162 function Action:New( idx, barConfig, bar, idHint ) | 161 function Action:New( idx, barConfig, bar, idHint ) |
163 local name = format("ReAction_%s_Action_%d",bar:GetName(),idx) | 162 local name = format("ReAction_%s_Action_%d",bar:GetName(),idx) |
164 | 163 |
165 self = Super.New(self, name, barConfig, bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) | 164 self = Super.New(self, name, barConfig.buttons[idx], bar, idx, "SecureActionButtonTemplate, ActionButtonTemplate" ) |
165 self.barConfig = barConfig | |
166 | 166 |
167 local f = self:GetFrame() | 167 local f = self:GetFrame() |
168 local barFrame = bar:GetFrame() | 168 local barFrame = bar:GetFrame() |
169 local config = self:GetConfig() | 169 local config = self:GetConfig() |
170 | 170 |
191 | 191 |
192 -- attribute setup | 192 -- attribute setup |
193 f:SetAttribute("type","action") | 193 f:SetAttribute("type","action") |
194 f:SetAttribute("checkselfcast", true) | 194 f:SetAttribute("checkselfcast", true) |
195 f:SetAttribute("checkfocuscast", true) | 195 f:SetAttribute("checkfocuscast", true) |
196 f:SetAttribute("useparent-unit", true) | |
197 f:SetAttribute("action", config.actionID) | 196 f:SetAttribute("action", config.actionID) |
198 f:SetAttribute("default-action", config.actionID) | 197 f:SetAttribute("default-action", config.actionID) |
199 f:SetAttribute("bar-idx",idx) | 198 f:SetAttribute("bar-idx",idx) |
200 f:SetAttribute("showgrid-temp",0) | 199 f:SetAttribute("showgrid-temp",0) |
201 f:SetAttribute("showgrid-event",0) | 200 f:SetAttribute("showgrid-event",0) |
256 end | 255 end |
257 | 256 |
258 Super.Destroy(self) | 257 Super.Destroy(self) |
259 end | 258 end |
260 | 259 |
260 function Action:GetBarConfig() | |
261 -- this is the per-bar Action module config structure, | |
262 -- not the config structure of the bar itself | |
263 return self.barConfig | |
264 end | |
265 | |
261 function Action:Refresh() | 266 function Action:Refresh() |
262 self.bar:PlaceButton(self, 36, 36) | 267 Super.Refresh(self) |
263 self:RefreshPages() | 268 self:RefreshPages() |
264 self:InstallVehicle() | 269 self:InstallVehicle() |
265 self:ShowGrid(not self:GetBarConfig().hideEmpty) | 270 self:ShowGrid(not self:GetBarConfig().hideEmpty) |
266 self:UpdateAction() | 271 self:UpdateAction() |
267 end | 272 end |
534 | 539 |
535 function Action:SetActionID( id, page ) | 540 function Action:SetActionID( id, page ) |
536 id = tonumber(id) | 541 id = tonumber(id) |
537 page = tonumber(page) | 542 page = tonumber(page) |
538 if id == nil or id < 1 or id > 120 then | 543 if id == nil or id < 1 or id > 120 then |
539 error("Action:SetActionID - invalid action ID") | 544 ReAction:UserError(L["Action ID range is 1-120"]) |
545 return | |
540 end | 546 end |
541 if page and page ~= 1 then | 547 if page and page ~= 1 then |
542 if not self.config.pageactions then | 548 if not self.config.pageactions then |
543 self.config.pageactions = { } | 549 self.config.pageactions = { } |
544 end | 550 end |
572 if i > 1 then | 578 if i > 1 then |
573 c[i] = self:AcquireActionID(c[i], self.config.actionID + (i-1)*self.bar:GetNumButtons()) | 579 c[i] = self:AcquireActionID(c[i], self.config.actionID + (i-1)*self.bar:GetNumButtons()) |
574 else | 580 else |
575 c[i] = self.config.actionID -- page 1 is the same as the base actionID | 581 c[i] = self.config.actionID -- page 1 is the same as the base actionID |
576 end | 582 end |
577 f:SetAttribute(("action-page%d"):format(i),c[i]) | 583 f:SetAttribute("action-page"..i,c[i]) |
578 end | 584 end |
579 for i = nPages+1, #c do | 585 for i = nPages+1, #c do |
580 self:ReleaseActionID(c[i]) | 586 self:ReleaseActionID(c[i]) |
581 c[i] = nil | 587 c[i] = nil |
582 f:SetAttribute(("action-page%d"):format(i),nil) | 588 f:SetAttribute("action-page"..i,nil) |
583 end | 589 end |
584 self.nPages = nPages | 590 self.nPages = nPages |
585 end | 591 end |
586 end | 592 end |
587 | 593 |