Mercurial > wow > reaction
comparison Button.lua @ 299:e337b39dc491
Add ExtraActionButton support
author | Flick |
---|---|
date | Wed, 14 Nov 2012 16:38:53 -0800 |
parents | 7a9e82c0df15 |
children |
comparison
equal
deleted
inserted
replaced
298:d1a56601267b | 299:e337b39dc491 |
---|---|
202 local poolID = self.actionPoolID | 202 local poolID = self.actionPoolID |
203 local maxID = self.actionMaxID | 203 local maxID = self.actionMaxID |
204 if not poolID or not maxID then | 204 if not poolID or not maxID then |
205 error("AcquireActionID: must setup pool first with SetActionIDPool") | 205 error("AcquireActionID: must setup pool first with SetActionIDPool") |
206 end | 206 end |
207 hint = tonumber(hint) | |
208 if hint and (hint < 1 or hint > maxID) then | |
209 hint = nil | |
210 end | |
207 local pool = idPools[poolID] | 211 local pool = idPools[poolID] |
208 if not pool then | 212 if not pool then |
209 pool = { nWraps = 0, useCount = { } } | 213 pool = { nWraps = 0, useCount = { } } |
210 for i = 1, maxID do | 214 for i = 1, maxID do |
211 pool.useCount[i] = 0 | 215 pool.useCount[i] = 0 |
214 end | 218 end |
215 local useCount = pool.useCount | 219 local useCount = pool.useCount |
216 if id == nil then | 220 if id == nil then |
217 repeat | 221 repeat |
218 local nWraps = pool.nWraps or 0 | 222 local nWraps = pool.nWraps or 0 |
219 if hint and (useCount[hint] == nil or useCount[hint] == nWraps) then | 223 if hint and (useCount[hint] == 0 or useCount[hint] == nWraps) then |
220 id = hint | 224 id = hint |
221 else | 225 else |
222 local start = hint or 1 | 226 local start = hint or 1 |
223 for i = start, maxID do | 227 for i = start, maxID do |
224 if useCount[i] == nil or useCount[i] == nWraps then | 228 if useCount[i] == 0 or useCount[i] == nWraps then |
225 id = i | 229 id = i |
226 break | 230 break |
227 end | 231 end |
228 end | 232 end |
229 if not id then | 233 if not id then |
230 for i = 1, start do | 234 for i = 1, start do |
231 if useCount[i] == nil or useCount[i] == nWraps then | 235 if useCount[i] == 0 or useCount[i] == nWraps then |
232 id = i | 236 id = i |
233 break | 237 break |
234 end | 238 end |
235 end | 239 end |
236 end | 240 end |