Mercurial > wow > breuesk
comparison Gui.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 | 8387dc2ff658 |
children | b7352f007028 |
comparison
equal
deleted
inserted
replaced
67:8387dc2ff658 | 68:a177b863ed6c |
---|---|
44 end | 44 end |
45 end | 45 end |
46 end | 46 end |
47 pulldown:SetWidth(175) | 47 pulldown:SetWidth(175) |
48 pulldown:SetList(pull) | 48 pulldown:SetList(pull) |
49 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SetList(value) end) | 49 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SelectList(value) end) |
50 if ltemp > 0 then pulldown:SetValue(ltemp); SListPopulator:SetList(ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged | 50 if ltemp > 0 then pulldown:SetValue(ltemp); SListPopulator:SelectList(ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged |
51 return pulldown | 51 return pulldown |
52 end | 52 end |
53 | 53 |
54 local f, right | 54 local f, right |
55 local escapeButton = | 55 local escapeButton = |
108 | 108 |
109 SListEventDispatch = SelectorListEventDispatcher:new() | 109 SListEventDispatch = SelectorListEventDispatcher:new() |
110 LListEventDispatch = SelectorListEventDispatcher:new() | 110 LListEventDispatch = SelectorListEventDispatcher:new() |
111 RListEventDispatch = SelectorListEventDispatcher:new() | 111 RListEventDispatch = SelectorListEventDispatcher:new() |
112 | 112 |
113 local AdminLootEventCollector = | |
114 { | |
115 listeners = {}, | |
116 target1 = | |
117 { | |
118 }, | |
119 target2 = | |
120 { | |
121 }, | |
122 | |
123 | |
124 } | |
125 | |
126 local SListPopulator = | 113 local SListPopulator = |
127 { | 114 { |
128 filtered = false, | 115 filtered = false, |
129 widget = nil, | 116 widget = nil, |
130 data = nil, | 117 data = nil, |
156 end, | 143 end, |
157 ["SetFiltered"] = function(self,value) | 144 ["SetFiltered"] = function(self,value) |
158 self.filtered = value | 145 self.filtered = value |
159 self:Redraw() | 146 self:Redraw() |
160 end, | 147 end, |
161 ["SetList"] = function(self,value) | 148 ["SelectList"] = function(self,value) |
162 self.lref = LootLists:Select(value) | 149 self.lref = LootLists:Select(value) |
163 self:Redraw() | 150 self:Redraw() |
151 end, | |
152 ["DataEvent"] = function(self) | |
153 self:Redraw() | |
164 end | 154 end |
165 } | 155 } |
156 | |
157 DataEventDispatch = | |
158 { | |
159 -- todo: batch events | |
160 listeners = {}, | |
161 ["DataEvent"] = function(self,_) --todo: pass along the received event | |
162 for i,v in pairs(self.listeners) do | |
163 if v and v["DataEvent"] then | |
164 v:DataEvent() | |
165 end | |
166 end | |
167 end, | |
168 ["RegisterListener"] = function(self,listener) | |
169 if not listener or not listener["DataEvent"] then | |
170 _G.error("Bad listener") | |
171 end | |
172 table.insert(self.listeners,listener) | |
173 end | |
174 } | |
175 | |
176 function OnInitializeSetStaticData() | |
177 SetChangeListener(DataEventDispatch) | |
178 DataEventDispatch:RegisterListener(SListPopulator) | |
179 end | |
166 | 180 |
167 function CreateGUI() | 181 function CreateGUI() |
168 -- special registration procedure to be closable with the escape button | 182 -- special registration procedure to be closable with the escape button |
169 --escapeButton.shown = true | 183 --escapeButton.shown = true |
170 --_G["BSK_ESCAPEBUTTON"] = escapeButton | 184 --_G["BSK_ESCAPEBUTTON"] = escapeButton |
259 LListEventDispatch:RegisterListener(alb1.userdata) | 273 LListEventDispatch:RegisterListener(alb1.userdata) |
260 alb1:SetCallback("OnClick", | 274 alb1:SetCallback("OnClick", |
261 function(widget) | 275 function(widget) |
262 if widget.userdata.state then -- we were bidding when the button was pressed | 276 if widget.userdata.state then -- we were bidding when the button was pressed |
263 biddingZone:ReleaseChildren() | 277 biddingZone:ReleaseChildren() |
278 widget:SetText("Open Bids") | |
264 RListEventDispatch:Release() | 279 RListEventDispatch:Release() |
265 else | 280 else |
281 widget:SetText("Close bids") | |
266 local spacer = AceGUI:Create("Label") | 282 local spacer = AceGUI:Create("Label") |
267 spacer:SetText(" ") | 283 spacer:SetText(" ") |
268 spacer:SetFullWidth(true) | 284 spacer:SetFullWidth(true) |
269 local spacer2 = AceGUI:Create("Label") | 285 local spacer2 = AceGUI:Create("Label") |
270 spacer2:SetText(" ") | 286 spacer2:SetText(" ") |
415 if admin then | 431 if admin then |
416 | 432 |
417 suicideSelected = AceGUI:Create("Button") | 433 suicideSelected = AceGUI:Create("Button") |
418 suicideSelected:SetFullWidth(true) | 434 suicideSelected:SetFullWidth(true) |
419 suicideSelected:SetText("Suicide") | 435 suicideSelected:SetText("Suicide") |
436 suicideSelected:SetCallback("OnClick", | |
437 function(_) | |
438 local p = SListEventDispatch:LatestValue() | |
439 local lref = SListPopulator.lref | |
440 lref:SuicidePerson(p.value) | |
441 end | |
442 ) | |
443 | |
420 -- use userdata + SListEventDispatch to toggle state | 444 -- use userdata + SListEventDispatch to toggle state |
421 suicideSelected.userdata = | 445 suicideSelected.userdata = |
422 { | 446 { |
423 widget = suicideSelected, | 447 widget = suicideSelected, |
424 ["Redraw"] = function(self,_) self.widget:SetDisabled(true) end, | 448 ["Redraw"] = function(self,_) self.widget:SetDisabled(true) end, |