John@38
|
1 local AceGUI = LibStub("AceGUI-3.0")
|
John@42
|
2 local bsk=bsk
|
John@42
|
3 local _G=_G
|
John@42
|
4 local table=table
|
John@42
|
5 local pairs=pairs
|
John@65
|
6 local setmetatable=setmetatable
|
John@42
|
7 local ipairs=ipairs
|
John@42
|
8 local string=string
|
John@67
|
9 local sformat=string.format
|
John@42
|
10 local tostring=tostring
|
John@42
|
11 local type=type
|
John@42
|
12 local getn=getn
|
John@42
|
13 setfenv(1,bsk)
|
John@1
|
14
|
John@69
|
15 -- todo: switching lists should close a presently-open bid
|
John@69
|
16
|
John@56
|
17 local copy = function(t)
|
John@56
|
18 local c = {}
|
John@56
|
19 if not t then return c end
|
John@56
|
20 for i,v in pairs(t) do c[i] = v end
|
John@56
|
21 return c
|
John@56
|
22 end
|
John@56
|
23 local colorize = function(str,color)
|
John@56
|
24 if str==nil or str=="" then return "" end
|
John@56
|
25 if type(color) == "table" then
|
John@56
|
26 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
|
John@56
|
27 end
|
John@56
|
28 if color == nil then return str end
|
John@56
|
29 return "|cff"..tostring(color or "ffffff")..str.."|r"
|
John@56
|
30 end
|
John@1
|
31
|
John@63
|
32 local CreateListSelector = function(SListPopulator)
|
John@56
|
33 PersonList:RefreshRaidList()
|
John@56
|
34 local pulldown = AceGUI:Create("Dropdown")
|
John@56
|
35 local pull = {}
|
John@56
|
36 local ltemp = 0
|
John@56
|
37 local lids = LootLists:GetAllIds()
|
John@56
|
38 for _,v in pairs(lids) do
|
John@56
|
39 local l = LootLists:Select(v)
|
John@56
|
40 pull[l:GetId()] = l:GetName()
|
John@56
|
41 --local entry = {value=i,text=v.name}
|
John@56
|
42 if l:GetLength() > 0 then
|
John@56
|
43 pulldown:SetItemDisabled(i,true)
|
John@56
|
44 if ltemp == 0 then
|
John@56
|
45 ltemp = l:GetId()
|
John@51
|
46 end
|
John@51
|
47 end
|
John@1
|
48 end
|
John@56
|
49 pulldown:SetWidth(175)
|
John@56
|
50 pulldown:SetList(pull)
|
John@71
|
51 SListPopulator:SetSwidget(pulldown)
|
John@68
|
52 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SelectList(value) end)
|
John@71
|
53 if ltemp > 0 then SListPopulator:SelectList(ltemp) end -- default value
|
John@56
|
54 return pulldown
|
John@1
|
55 end
|
John@1
|
56
|
John@65
|
57 local f, right
|
John@59
|
58 local escapeButton =
|
John@59
|
59 {
|
John@59
|
60 shown = false,
|
John@59
|
61 ["IsShown"] = function(self) return self.shown end,
|
John@60
|
62 ["Hide"] = function(self) if f then AceGUI:Release(f); self.shown=false end end
|
John@59
|
63 }
|
John@38
|
64
|
John@65
|
65 SelectorListEventDispatcher =
|
John@63
|
66 {
|
John@65
|
67 listeners = nil,
|
John@63
|
68 target = nil,
|
John@67
|
69 line = nil,
|
John@63
|
70 ["SetTarget"] = function(self,other)
|
John@63
|
71 self.target = other
|
John@65
|
72 self.target:SetCallback("OnSelectionCleared",function(...) self:OnSelectionCleared(...) end)
|
John@65
|
73 self.target:SetCallback("OnSelection",function(...) self:OnSelection(...) end)
|
John@63
|
74 end,
|
John@63
|
75 ["RegisterListener"] = function(self,other) table.insert(self.listeners,other) end,
|
John@63
|
76 ["OnSelectionCleared"] = function(self,_)
|
John@67
|
77 self.line = nil
|
John@63
|
78 self:Event("OnSelectionCleared")
|
John@63
|
79 end,
|
John@65
|
80 ["OnSelection"] = function(self,_,_,line)
|
John@67
|
81 self.line = line
|
John@63
|
82 self:Event("OnSelection",line)
|
John@63
|
83 end,
|
John@63
|
84 ["Event"] = function(self,event,arg)
|
John@63
|
85 if not self.target then error("Event called with no listener...") end
|
John@63
|
86 if not self.listeners then return end
|
John@63
|
87 for i,v in pairs(self.listeners) do
|
John@67
|
88 --bsk.print("listener")
|
John@63
|
89 if type(v) == "table" then
|
John@63
|
90 if v[event] then
|
John@63
|
91 v[event](v,arg)
|
John@63
|
92 end
|
John@63
|
93 elseif type(v) == "function" then
|
John@63
|
94 v(event,arg)
|
John@63
|
95 elseif type(v) ~= "nil" then -- allow nils to pass quietly
|
John@63
|
96 _G.error("Bad listener - "..type(v))
|
John@63
|
97 end
|
John@63
|
98 end
|
John@63
|
99 end,
|
John@67
|
100 ["Release"] = function(self) self.listeners = {}; self.target=nil; self.line=nil end,
|
John@67
|
101 ["LatestValue"] = function(self) return self.line end
|
John@63
|
102 }
|
John@65
|
103 function SelectorListEventDispatcher:new()
|
John@65
|
104 local t = {}
|
John@65
|
105 setmetatable(t,SelectorListEventDispatcher)
|
John@65
|
106 self.__index = self
|
John@65
|
107 t.listeners = {}
|
John@65
|
108 return t
|
John@63
|
109 end
|
John@65
|
110
|
John@65
|
111 SListEventDispatch = SelectorListEventDispatcher:new()
|
John@65
|
112 LListEventDispatch = SelectorListEventDispatcher:new()
|
John@67
|
113 RListEventDispatch = SelectorListEventDispatcher:new()
|
John@65
|
114
|
John@63
|
115 local SListPopulator =
|
John@63
|
116 {
|
John@63
|
117 filtered = false,
|
John@63
|
118 widget = nil,
|
John@71
|
119 swidget = nil,
|
John@63
|
120 data = nil,
|
John@63
|
121 lref = nil,
|
John@63
|
122
|
John@71
|
123 ["Release"] = function(self) self.filtered, self.widget, self.swidget, self.data, self.lref = false, nil, nil, nil, nil end,
|
John@63
|
124 ["Redraw"] = function(self)
|
John@63
|
125 if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized
|
John@63
|
126 self.data = {}
|
John@63
|
127 for le in self.lref:OrderedListEntryIter() do
|
John@63
|
128 local disabled = not PersonList:IsActive(le:GetId())
|
John@63
|
129 if not self.filtered or not disabled then
|
John@63
|
130 local line = {value=le:GetId(),text=le:GetName(),icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
|
John@63
|
131 line.iconCoords=_G.CLASS_ICON_TCOORDS[le:GetClass()]
|
John@67
|
132 line.textPlain = line.text
|
John@63
|
133 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[le:GetClass()])
|
John@63
|
134 line.disabled = disabled
|
John@63
|
135 table.insert(self.data,line)
|
John@63
|
136 end
|
John@63
|
137 end
|
John@63
|
138 self.widget:SetList(self.data)
|
John@65
|
139 SListEventDispatch:Event("Redraw")
|
John@63
|
140 end,
|
John@71
|
141 ["SetSwidget"] = function(self,w)
|
John@71
|
142 if type(w) ~= "table" or type(w.SetList) ~= "function" then
|
John@71
|
143 _G.error("Bad SetWidget")
|
John@71
|
144 end
|
John@71
|
145 self.swidget = w
|
John@71
|
146 end,
|
John@63
|
147 ["SetWidget"] = function(self,w)
|
John@65
|
148 if type(w) ~= "table" or type(w.SetList) ~= "function" then
|
John@63
|
149 _G.error("Bad SetWidget")
|
John@63
|
150 end
|
John@63
|
151 self.widget = w
|
John@63
|
152 end,
|
John@63
|
153 ["SetFiltered"] = function(self,value)
|
John@63
|
154 self.filtered = value
|
John@63
|
155 self:Redraw()
|
John@63
|
156 end,
|
John@68
|
157 ["SelectList"] = function(self,value)
|
John@71
|
158 self.swidget:SetValue(value)
|
John@63
|
159 self.lref = LootLists:Select(value)
|
John@63
|
160 self:Redraw()
|
John@71
|
161 Comm:ActivateList(value)
|
John@68
|
162 end,
|
John@68
|
163 ["DataEvent"] = function(self)
|
John@68
|
164 self:Redraw()
|
John@69
|
165 end,
|
John@69
|
166 ["GetMe"] = function(self)
|
John@69
|
167 local me = _G.UnitName("player")
|
John@69
|
168 for i,v in pairs(self.data) do
|
John@69
|
169 if v.textPlain == me then
|
John@69
|
170 return v
|
John@69
|
171 end
|
John@69
|
172 end
|
John@69
|
173 end,
|
John@69
|
174 }
|
John@69
|
175
|
John@69
|
176 local LListPopulator =
|
John@69
|
177 {
|
John@69
|
178 -- todo: set event receivers from the comm and for loot
|
John@69
|
179 data = {},
|
John@69
|
180 widget = nil,
|
John@69
|
181 ["Release"] = function(self) self.data = {}; self.widget = nil end,
|
John@69
|
182 ["Redraw"]= function(self)
|
John@69
|
183 self.widget:SetList(self.data)
|
John@69
|
184 LListEventDispatch:Event("Redraw")
|
John@69
|
185 end,
|
John@69
|
186 ["SetWidget"] = function(self,w)
|
John@69
|
187 if type(w) ~= "table" or type(w.SetList) ~= "function" then
|
John@69
|
188 _G.error("Bad SetWidget")
|
John@69
|
189 end
|
John@69
|
190 self.widget = w
|
John@69
|
191 if debug then
|
John@69
|
192 self.data = {
|
John@69
|
193 {
|
John@69
|
194 value=1,
|
John@69
|
195 text = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
|
John@69
|
196 link = "|cffa335ee|Hitem:77109:4080:4009:0:0:0:0:0:85:0|h[Band of Reconstruction]|h|r",
|
John@69
|
197 },
|
John@69
|
198 {
|
John@69
|
199 value=2,
|
John@69
|
200 text = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r",
|
John@69
|
201 link = "|cffa335ee|Hitem:19351:0:0:0:0:0:0:0:85:0|h[Maladath, Runed Blade of the Black Flight]|h|r"
|
John@69
|
202 },
|
John@69
|
203 {
|
John@69
|
204 value=3,
|
John@69
|
205 text = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r",
|
John@69
|
206 link = "|cffa335ee|Hitem:31986:0:0:0:0:0:0:0:85:0|h[Merciless Gladiator's Crossbow of the Phoenix]|h|r"
|
John@69
|
207 },
|
John@69
|
208 {
|
John@69
|
209 value=4,
|
John@69
|
210 text = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r",
|
John@69
|
211 link = "|cffa335ee|Hitem:65003:0:0:0:0:0:0:0:85:0|h[Reclaimed Ashkandi, Greatsword of the Brotherhood]|h|r"
|
John@69
|
212 },
|
John@69
|
213 {
|
John@69
|
214 value=5,
|
John@69
|
215 text = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r",
|
John@69
|
216 link = "|cffff8000|Hitem:19019:0:0:0:0:0:0:0:85:0|h[Thunderfury, Blessed Blade of the Windseeker]|h|r"
|
John@69
|
217 },
|
John@69
|
218 }
|
John@69
|
219 end
|
John@69
|
220 self:Redraw()
|
John@69
|
221 end,
|
John@69
|
222 }
|
John@69
|
223
|
John@69
|
224 local RListPopulator =
|
John@69
|
225 {
|
John@69
|
226 widget = nil,
|
John@71
|
227 ["RollEvent"] = function(self) self:Redraw() end,
|
John@71
|
228 ["Release"] = function(self) self.widget = nil end,
|
John@69
|
229 ["Redraw"] = function(self)
|
John@71
|
230 self.widget:SetList(statebids)
|
John@69
|
231 RListEventDispatch:Event("Redraw")
|
John@69
|
232 end,
|
John@69
|
233 ["SetWidget"] = function(self,w)
|
John@69
|
234 if type(w) ~= "table" or type(w.SetList) ~= "function" then
|
John@69
|
235 _G.error("Bad SetWidget")
|
John@69
|
236 end
|
John@69
|
237 self.widget = w
|
John@71
|
238 --if debug then
|
John@71
|
239 -- local dummydata = {}
|
John@71
|
240 -- local tree = SListPopulator.data
|
John@71
|
241 -- for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end
|
John@71
|
242 -- if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end
|
John@71
|
243 -- self.data = dummydata
|
John@71
|
244 --end
|
John@69
|
245 self:Redraw()
|
John@69
|
246 end,
|
John@69
|
247 ["Force"] = function(self,who)
|
John@69
|
248 local new = self.Convert(who,72)
|
John@71
|
249 InitiateBid(new)
|
John@71
|
250 --self:Redraw()
|
John@69
|
251 end,
|
John@69
|
252 ["Retract"] = function(self,who)
|
John@71
|
253 -- todo
|
John@71
|
254 --for i,v in pairs(self.data) do
|
John@71
|
255 -- if who.value == v.value then
|
John@71
|
256 -- table.remove(self.data,i)
|
John@71
|
257 -- end
|
John@71
|
258 --end
|
John@71
|
259 InitiateRetract(copy(who))
|
John@71
|
260 --self:Redraw()
|
John@69
|
261 end,
|
John@69
|
262 ["Convert"] = function(who,roll) -- convert an LE object into one suitable to put in a SelectorList
|
John@69
|
263 local new = copy(who)
|
John@69
|
264 new.disabled = false -- todo: should be unnessary - they can't get on the list like this
|
John@69
|
265 if roll then
|
John@69
|
266 new.text = new.text .. " (roll 73)"
|
John@69
|
267 end
|
John@69
|
268 return new
|
John@69
|
269 end,
|
John@63
|
270 }
|
John@63
|
271
|
John@68
|
272 DataEventDispatch =
|
John@68
|
273 {
|
John@68
|
274 -- todo: batch events
|
John@68
|
275 listeners = {},
|
John@68
|
276 ["DataEvent"] = function(self,_) --todo: pass along the received event
|
John@68
|
277 for i,v in pairs(self.listeners) do
|
John@68
|
278 if v and v["DataEvent"] then
|
John@68
|
279 v:DataEvent()
|
John@68
|
280 end
|
John@68
|
281 end
|
John@68
|
282 end,
|
John@68
|
283 ["RegisterListener"] = function(self,listener)
|
John@68
|
284 if not listener or not listener["DataEvent"] then
|
John@68
|
285 _G.error("Bad listener")
|
John@68
|
286 end
|
John@68
|
287 table.insert(self.listeners,listener)
|
John@68
|
288 end
|
John@68
|
289 }
|
John@68
|
290
|
John@68
|
291 function OnInitializeSetStaticData()
|
John@68
|
292 SetChangeListener(DataEventDispatch)
|
John@68
|
293 DataEventDispatch:RegisterListener(SListPopulator)
|
John@71
|
294 RegisterListenerRolls(RListPopulator)
|
John@68
|
295 end
|
John@68
|
296
|
John@42
|
297 function CreateGUI()
|
John@59
|
298 -- special registration procedure to be closable with the escape button
|
John@59
|
299 --escapeButton.shown = true
|
John@59
|
300 --_G["BSK_ESCAPEBUTTON"] = escapeButton
|
John@59
|
301 --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON")
|
John@59
|
302
|
John@60
|
303 if f then return end -- no second gui please
|
John@69
|
304 local admin = admin or true
|
John@59
|
305 f = AceGUI:Create("Frame")
|
John@1
|
306
|
John@69
|
307 f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil; right=nil; SListEventDispatch:Release(); LListEventDispatch:Release(); SListPopulator:Release(); RListEventDispatch:Release(); LListPopulator:Release(); RListPopulator:Release() end)
|
John@56
|
308 f:SetTitle("BSK")
|
John@56
|
309 f:SetLayout("Flow")
|
John@56
|
310 f:SetHeight(680)
|
John@56
|
311 f:SetWidth(580)
|
John@1
|
312
|
John@56
|
313 local left = AceGUI:Create("InlineGroup")
|
John@56
|
314 left:SetLayout("List")
|
John@56
|
315 left:SetWidth(175)
|
John@56
|
316 left:SetFullHeight(true)
|
John@56
|
317 left.alignoffset=0.25 -- hack, as per http://forums.wowace.com/showthread.php?t=17114
|
John@1
|
318
|
John@65
|
319 right = AceGUI:Create("InlineGroup")
|
John@56
|
320 right:SetLayout("Flow")
|
John@56
|
321 right:SetWidth(700-175-160)
|
John@56
|
322 right:SetFullHeight(true)
|
John@56
|
323 right.alignoffset=0.25
|
John@38
|
324
|
John@56
|
325 local t1 = AceGUI:Create("SelectorList")
|
John@56
|
326 t1:SetNumLines(25)
|
John@56
|
327 t1:SetFullWidth(true)
|
John@56
|
328 t1:SetInteractive(admin)
|
John@69
|
329 SListEventDispatch:SetTarget(t1)
|
John@63
|
330 SListPopulator:SetWidget(t1)
|
John@38
|
331
|
John@63
|
332 local p1 = CreateListSelector(SListPopulator)
|
John@56
|
333 p1:SetFullWidth(true)
|
John@38
|
334
|
John@56
|
335 left:AddChild(p1)
|
John@56
|
336 left:AddChild(t1)
|
John@38
|
337
|
John@56
|
338 local t2 = AceGUI:Create("SelectorList")
|
John@56
|
339 t2:SetNumLines(7)
|
John@56
|
340 t2:SetFullWidth(true)
|
John@56
|
341 t2:EnableButtonTooltips(true)
|
John@65
|
342 LListEventDispatch:SetTarget(t2)
|
John@69
|
343 LListPopulator:SetWidget(t2)
|
John@65
|
344
|
John@65
|
345 local biddingZone = AceGUI:Create("SimpleGroup")
|
John@65
|
346 biddingZone:SetLayout("Flow")
|
John@65
|
347 biddingZone:SetFullWidth(true)
|
John@38
|
348
|
John@60
|
349 local alb1, alb2, alb3
|
John@60
|
350 if admin then
|
John@60
|
351 alb1 = AceGUI:Create("Button")
|
John@60
|
352 alb1:SetWidth(100)
|
John@60
|
353 alb1:SetText("Open Bids")
|
John@65
|
354 alb1.userdata =
|
John@65
|
355 {
|
John@65
|
356 state = false,
|
John@65
|
357 widget = alb1,
|
John@65
|
358 ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.item = nil end,
|
John@65
|
359 ["OnSelection"] = function(self,value) self.widget:SetDisabled(false); self.item = value end,
|
John@65
|
360 ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.item = nil end
|
John@65
|
361 }
|
John@65
|
362 alb1:SetDisabled(true)
|
John@65
|
363 LListEventDispatch:RegisterListener(alb1.userdata)
|
John@65
|
364 alb1:SetCallback("OnClick",
|
John@65
|
365 function(widget)
|
John@65
|
366 if widget.userdata.state then -- we were bidding when the button was pressed
|
John@65
|
367 biddingZone:ReleaseChildren()
|
John@68
|
368 widget:SetText("Open Bids")
|
John@67
|
369 RListEventDispatch:Release()
|
John@70
|
370 RListPopulator:Release()
|
John@65
|
371 else
|
John@68
|
372 widget:SetText("Close bids")
|
John@65
|
373 local spacer = AceGUI:Create("Label")
|
John@65
|
374 spacer:SetText(" ")
|
John@65
|
375 spacer:SetFullWidth(true)
|
John@65
|
376 local spacer2 = AceGUI:Create("Label")
|
John@65
|
377 spacer2:SetText(" ")
|
John@65
|
378 spacer2:SetFullWidth(true)
|
John@65
|
379
|
John@65
|
380 local label = AceGUI:Create("Label")
|
John@65
|
381 label:SetText("Bidding now open for ...")
|
John@65
|
382 local biddingOn = AceGUI:Create("InteractiveLabel")
|
John@67
|
383 biddingOn.userdata = { LListEventDispatch:LatestValue().link }
|
John@65
|
384 biddingOn:SetText(biddingOn.userdata[1])
|
John@65
|
385 biddingOn:SetFullWidth(true)
|
John@65
|
386 biddingOn:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink(widget.userdata[1]); _G.GameTooltip:Show() end )
|
John@65
|
387 biddingOn:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
|
John@65
|
388 local b1 = AceGUI:Create("SelectorList")
|
John@65
|
389 b1:SetNumLines(6)
|
John@65
|
390 b1:SetInteractive(admin)
|
John@65
|
391 local bidTitle = AceGUI:Create("Label")
|
John@65
|
392 bidTitle:SetText("Current bids")
|
John@65
|
393 bidTitle:SetFullWidth(true)
|
John@65
|
394
|
John@65
|
395 local bidRetractButton = AceGUI:Create("Button")
|
John@65
|
396 bidRetractButton:SetText("Place Bid")
|
John@65
|
397 bidRetractButton:SetWidth(100)
|
John@70
|
398 bidRetractButton:SetCallback("OnClick", function(widget) RListPopulator:Force(SListPopulator:GetMe()) end) -- todo: Force is not the desired thing here.
|
John@65
|
399 local rollButton = AceGUI:Create("Button")
|
John@65
|
400 rollButton:SetText("Offset Roll")
|
John@65
|
401 rollButton:SetWidth(100)
|
John@65
|
402
|
John@69
|
403 RListEventDispatch:SetTarget(b1)
|
John@69
|
404 RListPopulator:SetWidget(b1)
|
John@67
|
405
|
John@71
|
406 InitiateOpenBid(LListEventDispatch:LatestValue())
|
John@71
|
407
|
John@65
|
408 local g1
|
John@65
|
409 if admin then
|
John@65
|
410 b1.alignoffset = 0.25 -- or else g1 won't align well
|
John@65
|
411 g1 = AceGUI:Create("SimpleGroup")
|
John@65
|
412 g1.alignoffset = 0.25
|
John@65
|
413 g1:SetWidth(120)
|
John@65
|
414 g1:SetLayout("List")
|
John@65
|
415
|
John@67
|
416 -- todo: convoluted and repetitive - surely there's a
|
John@67
|
417 -- better way than this ...
|
John@65
|
418 adminForce = AceGUI:Create("Button")
|
John@67
|
419 if SListEventDispatch:LatestValue() then
|
John@67
|
420 adminForce:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain))
|
John@67
|
421 adminForce:SetDisabled(false)
|
John@67
|
422 else
|
John@67
|
423 adminForce:SetText("Force bid")
|
John@67
|
424 adminForce:SetDisabled(true)
|
John@67
|
425 end
|
John@67
|
426 adminForce:SetWidth(160)
|
John@69
|
427 adminForce:SetCallback("OnClick",function(widget) RListPopulator:Force(SListEventDispatch:LatestValue()) end)
|
John@67
|
428 adminForce.userdata =
|
John@67
|
429 {
|
John@67
|
430 widget = adminForce,
|
John@67
|
431 ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end,
|
John@67
|
432 ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Force bid (%s)",SListEventDispatch:LatestValue().textPlain)) end,
|
John@67
|
433 ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Force bid") end
|
John@67
|
434 }
|
John@67
|
435 SListEventDispatch:RegisterListener(adminForce.userdata)
|
John@65
|
436
|
John@65
|
437 adminRetract = AceGUI:Create("Button")
|
John@67
|
438 if RListEventDispatch:LatestValue() then
|
John@67
|
439 adminRetract:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain))
|
John@67
|
440 adminRetract:SetDisabled(false)
|
John@67
|
441 else
|
John@67
|
442 adminRetract:SetText("Retract bid")
|
John@67
|
443 adminRetract:SetDisabled(true)
|
John@67
|
444 end
|
John@67
|
445 adminRetract:SetWidth(160)
|
John@67
|
446 adminRetract.userdata =
|
John@67
|
447 {
|
John@67
|
448 widget = adminRetract,
|
John@67
|
449 ["Redraw"] = function(self,_) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end,
|
John@67
|
450 ["OnSelection"] = function(self,_) self.widget:SetDisabled(false); self.widget:SetText(sformat("Retract bid (%s)",RListEventDispatch:LatestValue().textPlain)) end,
|
John@67
|
451 ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true); self.widget:SetText("Retract bid") end
|
John@67
|
452 }
|
John@69
|
453 adminRetract:SetCallback("OnClick",function(widget) RListPopulator:Retract(RListEventDispatch:LatestValue()) end)
|
John@67
|
454 RListEventDispatch:RegisterListener(adminRetract.userdata)
|
John@67
|
455 adminRetract:SetDisabled(true)
|
John@65
|
456
|
John@65
|
457 g1:AddChildren(adminForce,adminRetract)
|
John@65
|
458 end
|
John@65
|
459
|
John@65
|
460 biddingZone:AddChildren(spacer,label,biddingOn,bidRetractButton,rollButton,spacer2,bidTitle,b1)
|
John@65
|
461 if admin then biddingZone:AddChildren(g1) end
|
John@65
|
462 end
|
John@65
|
463 widget.userdata.state = not widget.userdata.state
|
John@65
|
464 end
|
John@65
|
465 )
|
John@60
|
466
|
John@60
|
467 alb2 = AceGUI:Create("Button")
|
John@60
|
468 alb2:SetWidth(100)
|
John@60
|
469 alb2:SetText("Assign")
|
John@65
|
470 alb2.userdata =
|
John@65
|
471 {
|
John@65
|
472 widget = alb2,
|
John@65
|
473 ["OnUpdate"] = function(self) self.widget:SetDisabled(not (self.slist.checked and self.llist.checked)) end,
|
John@65
|
474 }
|
John@65
|
475 alb2.userdata.slist =
|
John@65
|
476 {
|
John@65
|
477 parent = alb2.userdata,
|
John@65
|
478 checked = false,
|
John@65
|
479 ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
480 ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end,
|
John@65
|
481 ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
482 }
|
John@65
|
483 alb2.userdata.llist =
|
John@65
|
484 {
|
John@65
|
485 parent = alb2.userdata,
|
John@65
|
486 checked = false,
|
John@65
|
487 ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
488 ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end,
|
John@65
|
489 ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
490 }
|
John@65
|
491 SListEventDispatch:RegisterListener(alb2.userdata.slist)
|
John@65
|
492 LListEventDispatch:RegisterListener(alb2.userdata.llist)
|
John@60
|
493
|
John@60
|
494 alb3 = AceGUI:Create("Button")
|
John@60
|
495 alb3:SetWidth(100)
|
John@60
|
496 alb3:SetText("Suicide")
|
John@65
|
497 alb3.userdata = -- TODO: holy hell, come up with a pattern or something for this ....
|
John@65
|
498 {
|
John@65
|
499 widget = alb3,
|
John@65
|
500 ["OnUpdate"] = function(self) self.widget:SetDisabled(not (self.slist.checked and self.llist.checked)) end,
|
John@65
|
501 }
|
John@65
|
502 alb3.userdata.slist =
|
John@65
|
503 {
|
John@65
|
504 parent = alb3.userdata,
|
John@65
|
505 checked = false,
|
John@65
|
506 ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
507 ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end,
|
John@65
|
508 ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
509 }
|
John@65
|
510 alb3.userdata.llist =
|
John@65
|
511 {
|
John@65
|
512 parent = alb3.userdata,
|
John@65
|
513 checked = false,
|
John@65
|
514 ["Redraw"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
515 ["OnSelection"] = function(self) self.checked = true; self.parent:OnUpdate() end,
|
John@65
|
516 ["OnSelectionCleared"] = function(self) self.checked = false; self.parent:OnUpdate() end,
|
John@65
|
517 }
|
John@65
|
518 SListEventDispatch:RegisterListener(alb3.userdata.slist)
|
John@65
|
519 LListEventDispatch:RegisterListener(alb3.userdata.llist)
|
John@60
|
520 end
|
John@38
|
521
|
John@65
|
522 local suicideSelected, undo
|
John@60
|
523 if admin then
|
John@60
|
524
|
John@60
|
525 suicideSelected = AceGUI:Create("Button")
|
John@60
|
526 suicideSelected:SetFullWidth(true)
|
John@60
|
527 suicideSelected:SetText("Suicide")
|
John@68
|
528 suicideSelected:SetCallback("OnClick",
|
John@68
|
529 function(_)
|
John@68
|
530 local p = SListEventDispatch:LatestValue()
|
John@68
|
531 local lref = SListPopulator.lref
|
John@68
|
532 lref:SuicidePerson(p.value)
|
John@68
|
533 end
|
John@68
|
534 )
|
John@68
|
535
|
John@63
|
536 -- use userdata + SListEventDispatch to toggle state
|
John@63
|
537 suicideSelected.userdata =
|
John@63
|
538 {
|
John@63
|
539 widget = suicideSelected,
|
John@65
|
540 ["Redraw"] = function(self,_) self.widget:SetDisabled(true) end,
|
John@63
|
541 ["OnSelection"] = function(self,_) self.widget:SetDisabled(false) end,
|
John@63
|
542 ["OnSelectionCleared"] = function(self) self.widget:SetDisabled(true) end
|
John@63
|
543 }
|
John@63
|
544 SListEventDispatch:RegisterListener(suicideSelected.userdata)
|
John@60
|
545
|
John@60
|
546 undo = AceGUI:Create("Button")
|
John@63
|
547 undo:SetText("Undo / out of order")
|
John@60
|
548 undo:SetFullWidth(true)
|
John@63
|
549 undo:SetDisabled(true)
|
John@60
|
550 end
|
John@60
|
551
|
John@56
|
552 local filter = AceGUI:Create("CheckBox")
|
John@56
|
553 filter:SetLabel("Only show active")
|
John@56
|
554 filter:SetFullWidth(true)
|
John@63
|
555 filter:SetValue(false)
|
John@63
|
556 SListPopulator:SetFiltered(false)
|
John@63
|
557 filter:SetCallback("OnValueChanged",function(widget,_,value) SListPopulator:SetFiltered(value) end)
|
John@56
|
558
|
John@56
|
559 left:AddChildren(filter)
|
John@56
|
560 if admin then left:AddChildren(suicideSelected,undo) end
|
John@56
|
561 right:AddChildren(t2)
|
John@56
|
562 if admin then right:AddChildren(alb1,alb2,alb3) end
|
John@56
|
563 right:AddChildren(biddingZone)
|
John@56
|
564 f:AddChildren(left,right)
|
John@58
|
565
|
John@58
|
566
|
John@1
|
567 end
|