Mercurial > wow > breuesk
comparison Lists.lua @ 68:a177b863ed6c
Event chaining from the data storage to the GUI elements
author | John@Yosemite-PC |
---|---|
date | Wed, 28 Mar 2012 23:29:36 -0400 |
parents | 93acdcd6ace5 |
children | 236117ab8a49 |
comparison
equal
deleted
inserted
replaced
67:8387dc2ff658 | 68:a177b863ed6c |
---|---|
82 local assert=assert | 82 local assert=assert |
83 local getmetatable=getmetatable | 83 local getmetatable=getmetatable |
84 local setmetatable=setmetatable | 84 local setmetatable=setmetatable |
85 setfenv(1,bsk) | 85 setfenv(1,bsk) |
86 | 86 |
87 local changeListener = nil -- todo: really should not be scoped like this | |
88 | |
87 ListEntry = | 89 ListEntry = |
88 { | 90 { |
89 index = 0.0, | 91 index = 0.0, |
90 id = 0, | 92 id = 0, |
91 } | 93 } |
528 local le = self:Select(id) | 530 local le = self:Select(id) |
529 if le then | 531 if le then |
530 -- todo: check that they're not already reserved | 532 -- todo: check that they're not already reserved |
531 self.active.reserve[le:GetId()] = true | 533 self.active.reserve[le:GetId()] = true |
532 end | 534 end |
535 changeListener:DataEvent() -- todo: revisit | |
533 end | 536 end |
534 -- todo: remove reserve | 537 -- todo: remove reserve |
535 function PersonList:IsActive(id) -- todo: support LE as input - saves IsActive(le:GetId()) | 538 function PersonList:IsActive(id) -- todo: support LE as input - saves IsActive(le:GetId()) |
536 return self.active.raid[id] or self.active.reserve[id] | 539 return self.active.raid[id] or self.active.reserve[id] |
537 end | 540 end |
610 end | 613 end |
611 end | 614 end |
612 return ctime | 615 return ctime |
613 end | 616 end |
614 | 617 |
618 function SetChangeListener(object) | |
619 changeListener = object -- todo: needs correctness checking, at a minimum | |
620 end | |
615 function InitiateChange(finalizeAction,acceptor,arg) | 621 function InitiateChange(finalizeAction,acceptor,arg) |
616 local change = {} | 622 local change = {} |
617 change.time = GetSafeTimestamp() | 623 change.time = GetSafeTimestamp() |
618 change.action = finalizeAction | 624 change.action = finalizeAction |
619 change.arg = arg | 625 change.arg = arg |
620 | 626 |
621 if acceptor[finalizeAction](acceptor,arg,change.time) then | 627 if acceptor[finalizeAction](acceptor,arg,change.time) then |
622 table.insert(db.profile.changes,change) | 628 table.insert(db.profile.changes,change) |
629 if changeListener then | |
630 changeListener:DataEvent(change) | |
631 end | |
623 -- TODO: broadcast | 632 -- TODO: broadcast |
624 return arg | 633 return arg |
625 else | 634 else |
626 return nil | 635 return nil |
627 end | 636 end |