Mercurial > wow > reaction
comparison Button.lua @ 286:77609bfa804e stable
Merge 1.1 beta 8 to stable
author | Flick |
---|---|
date | Sat, 11 Jun 2011 10:57:00 -0700 |
parents | 7a9e82c0df15 |
children | e337b39dc491 |
comparison
equal
deleted
inserted
replaced
272:71d1a5e47e72 | 286:77609bfa804e |
---|---|
1 --[[ | 1 local _, ns = ... |
2 ReAction Button base class | 2 local ReAction = ns.ReAction |
3 --]] | |
4 | |
5 -- local imports | |
6 local addonName, addonTable = ... | |
7 local ReAction = addonTable.ReAction | |
8 local L = ReAction.L | 3 local L = ReAction.L |
9 local LKB = ReAction.LKB | 4 local LKB = ReAction.LKB |
10 local _G = _G | 5 local _G = _G |
11 local CreateFrame = CreateFrame | 6 local CreateFrame = CreateFrame |
12 local GetBindingKey = GetBindingKey | 7 local GetBindingKey = GetBindingKey |
30 btnHeight = 36, | 25 btnHeight = 36, |
31 btnRows = 1, | 26 btnRows = 1, |
32 btnColumns = 12, | 27 btnColumns = 12, |
33 spacing = 3 | 28 spacing = 3 |
34 }, | 29 }, |
35 barType = L["Button Bar"] | 30 -- barType = L["Button Bar"], -- derived classes must declare |
31 -- buttonTypeID = "Button" -- derived classes must declare | |
36 } | 32 } |
37 | 33 |
38 ReAction.Button = Button -- export to ReAction | 34 ReAction.Button = Button -- export to ReAction |
39 | 35 |
40 function Button:New( name, config, bar, idx, inherits, buttonType ) | 36 function Button:New( config, bar, idx, inherits, buttonType ) |
41 buttonType = buttonType or "CheckButton" | 37 buttonType = buttonType or "CheckButton" |
38 | |
39 local name = format("ReAction_%s_%s_%d",bar:GetName(), self.buttonTypeID, idx) | |
42 | 40 |
43 -- create new self | 41 -- create new self |
44 self = setmetatable( | 42 self = setmetatable( |
45 { | 43 { |
46 bar = bar, | 44 bar = bar, |
188 else | 186 else |
189 n = i - 1 | 187 n = i - 1 |
190 if not success then | 188 if not success then |
191 bar:ClipNButtons(n) | 189 bar:ClipNButtons(n) |
192 cfgN = n | 190 cfgN = n |
193 geterrorhandler()(r) | 191 if r then |
192 geterrorhandler()(r) | |
193 end | |
194 end | 194 end |
195 end | 195 end |
196 end | 196 end |
197 i = i + 1 | 197 i = i + 1 |
198 until b == nil | 198 until b == nil |
235 end | 235 end |
236 end | 236 end |
237 end | 237 end |
238 if id == nil then | 238 if id == nil then |
239 if unique then | 239 if unique then |
240 error(("All action IDs for bars of type '%s' are in use, cannot create any more buttons"):format(self.config.barType)) | 240 ReAction:UserError(L["All action IDs for bars of type '%s' are in use, cannot create any more buttons"]:format(self.barType)) |
241 error(nil) -- no error message, user has already been notified, so don't put in Lua error handler | |
241 end | 242 end |
242 pool.nWraps = nWraps + 1 | 243 pool.nWraps = nWraps + 1 |
243 end | 244 end |
244 until id ~= nil | 245 until id ~= nil |
245 end | 246 end |