Mercurial > wow > reaction
comparison classes/ReAction.lua @ 21:90bf38d48efd
committing changes to obsolete 0.4 series
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Fri, 07 Mar 2008 21:54:26 +0000 |
| parents | f3a7bfebc283 |
| children |
comparison
equal
deleted
inserted
replaced
| 20:2f3e45fcb9e2 | 21:90bf38d48efd |
|---|---|
| 20 -- The base config structure is as follows: | 20 -- The base config structure is as follows: |
| 21 -- | 21 -- |
| 22 -- config = { | 22 -- config = { |
| 23 -- type = "ReAction", -- static string (used by ReBar) | 23 -- type = "ReAction", -- static string (used by ReBar) |
| 24 -- subtype = "string", -- ReAction implementation identifier (index into ReAction.buttonTypes) | 24 -- subtype = "string", -- ReAction implementation identifier (index into ReAction.buttonTypes) |
| 25 -- ids = { {paged list}, {paged list}, ... } -- indexed by self.barIdx | 25 -- buttons = { |
| 26 -- id = n, -- global button ID number | |
| 27 -- actions = { {paged list}, {paged list}, ... } -- indexed by self.barIdx | |
| 28 -- } | |
| 26 -- } | 29 -- } |
| 27 -- | 30 -- |
| 28 | 31 |
| 29 | 32 |
| 30 local AceOO = AceLibrary("AceOO-2.0") | 33 local AceOO = AceLibrary("AceOO-2.0") |
| 166 | 169 |
| 167 local ids = { } | 170 local ids = { } |
| 168 local primary = nil | 171 local primary = nil |
| 169 | 172 |
| 170 for i = 1, pages do | 173 for i = 1, pages do |
| 171 local hint = config.ids[barIdx] and config.ids[barIdx][i] | 174 local hint = config.buttons and config.buttons.actions[barIdx] |
| 172 if hint == nil and i > 1 and ids[i-1] then | 175 if hint == nil and i > 1 and ids[i-1] then |
| 173 hint = ids[i-1] + (buttonsPerPage or 0) | 176 hint = ids[i-1] + (buttonsPerPage or 0) |
| 174 end | 177 end |
| 175 local id, p = self:GetAvailableID(config.subtype, hint) | 178 local id, p = self:GetAvailableID(config.subtype, hint) |
| 176 if id == nil then | 179 if id == nil then |
| 185 if primary then | 188 if primary then |
| 186 if not primary.button then | 189 if not primary.button then |
| 187 primary.button = btnType:new(ids[1]) | 190 primary.button = btnType:new(ids[1]) |
| 188 end | 191 end |
| 189 if primary.button then | 192 if primary.button then |
| 190 config.ids[barIdx] = ids | 193 config.buttons.actions[barIdx] = ids |
| 191 primary.button:Configure(config,barIdx) | 194 primary.button:Configure(config,barIdx) |
| 192 end | 195 end |
| 193 end | 196 end |
| 194 | 197 |
| 195 return primary and primary.button | 198 return primary and primary.button |
| 196 end | 199 end |
| 197 | 200 |
| 198 function ReAction:Release( b ) | 201 function ReAction:Release( b ) |
| 199 if b then | 202 if b then |
| 200 for i = 1, #b.config.ids[b.barIdx] do | 203 for i = 1, #b.config.buttons.actions[b.barIdx] do |
| 201 local id = b:GetID(i) | 204 local id = b:GetID(i) |
| 202 if id then | 205 if id then |
| 203 b.class._idTbl[id].inUse = false | 206 b.class._idTbl[id].inUse = false |
| 204 end | 207 end |
| 205 end | 208 end |
| 265 b:SetPoint(point,x/scale,y/scale) | 268 b:SetPoint(point,x/scale,y/scale) |
| 266 end | 269 end |
| 267 | 270 |
| 268 function ReAction.prototype:SetPages( n ) | 271 function ReAction.prototype:SetPages( n ) |
| 269 n = tonumber(n) | 272 n = tonumber(n) |
| 270 local ids = self.config.ids[self.barIdx] | 273 local ids = self.config.buttons.actions[self.barIdx] |
| 271 if n and n >= 1 then | 274 if n and n >= 1 then |
| 272 -- note that as long as n >= 1 then id[1] will never be modified, which is what we want | 275 -- note that as long as n >= 1 then id[1] will never be modified, which is what we want |
| 273 -- because then the button frame ID would be out of sync with the static button name | 276 -- because then the button frame ID would be out of sync with the static button name |
| 274 while #ids < n do | 277 while #ids < n do |
| 275 local id = ReAction:GetAvailableID(self.config.subtype, ids[#ids] + #self.config.ids) | 278 local id = ReAction:GetAvailableID(self.config.subtype, ids[#ids] + #self.config.buttons.actions) |
| 276 if id == nil then | 279 if id == nil then |
| 277 break | 280 break |
| 278 end | 281 end |
| 279 self:SetID( id, #ids + 1 ) | 282 self:SetID( id, #ids + 1 ) |
| 280 table.insert(ids, id) | 283 table.insert(ids, id) |
| 310 | 313 |
| 311 function ReAction.prototype:Configure( config, barIdx ) | 314 function ReAction.prototype:Configure( config, barIdx ) |
| 312 self.config = config | 315 self.config = config |
| 313 self.barIdx = barIdx | 316 self.barIdx = barIdx |
| 314 | 317 |
| 315 local ids = config.ids[barIdx] | 318 local ids = config.buttons.actions[barIdx] |
| 316 self:SetID(ids[1]) -- default id | 319 self:SetID(ids[1]) -- default id |
| 317 for i = 1, #ids do | 320 for i = 1, #ids do |
| 318 self:SetID(ids[i], i) -- paged ids | 321 self:SetID(ids[i], i) -- paged ids |
| 319 end | 322 end |
| 320 self:UpdateAction() | 323 self:UpdateAction() |
