comparison Gui.lua @ 71:d5e2dfe0c269

Starting to track loot state separately
author John@Yosemite-PC
date Tue, 03 Apr 2012 23:23:22 -0400
parents 236117ab8a49
children 9e5b0a2368ad
comparison
equal deleted inserted replaced
70:236117ab8a49 71:d5e2dfe0c269
46 end 46 end
47 end 47 end
48 end 48 end
49 pulldown:SetWidth(175) 49 pulldown:SetWidth(175)
50 pulldown:SetList(pull) 50 pulldown:SetList(pull)
51 SListPopulator:SetSwidget(pulldown)
51 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SelectList(value) end) 52 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SelectList(value) end)
52 if ltemp > 0 then pulldown:SetValue(ltemp); SListPopulator:SelectList(ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged 53 if ltemp > 0 then SListPopulator:SelectList(ltemp) end -- default value
53 return pulldown 54 return pulldown
54 end 55 end
55 56
56 local f, right 57 local f, right
57 local escapeButton = 58 local escapeButton =
113 114
114 local SListPopulator = 115 local SListPopulator =
115 { 116 {
116 filtered = false, 117 filtered = false,
117 widget = nil, 118 widget = nil,
119 swidget = nil,
118 data = nil, 120 data = nil,
119 lref = nil, 121 lref = nil,
120 122
121 ["Release"] = function(self) self.filtered, self.widget, self.data, self.lref = false, nil, nil, nil end, 123 ["Release"] = function(self) self.filtered, self.widget, self.swidget, self.data, self.lref = false, nil, nil, nil, nil end,
122 ["Redraw"] = function(self) 124 ["Redraw"] = function(self)
123 if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized 125 if self.lref == nil or self.widget == nil then return end -- don't do work if not fully initialized
124 self.data = {} 126 self.data = {}
125 for le in self.lref:OrderedListEntryIter() do 127 for le in self.lref:OrderedListEntryIter() do
126 local disabled = not PersonList:IsActive(le:GetId()) 128 local disabled = not PersonList:IsActive(le:GetId())
134 end 136 end
135 end 137 end
136 self.widget:SetList(self.data) 138 self.widget:SetList(self.data)
137 SListEventDispatch:Event("Redraw") 139 SListEventDispatch:Event("Redraw")
138 end, 140 end,
141 ["SetSwidget"] = function(self,w)
142 if type(w) ~= "table" or type(w.SetList) ~= "function" then
143 _G.error("Bad SetWidget")
144 end
145 self.swidget = w
146 end,
139 ["SetWidget"] = function(self,w) 147 ["SetWidget"] = function(self,w)
140 if type(w) ~= "table" or type(w.SetList) ~= "function" then 148 if type(w) ~= "table" or type(w.SetList) ~= "function" then
141 _G.error("Bad SetWidget") 149 _G.error("Bad SetWidget")
142 end 150 end
143 self.widget = w 151 self.widget = w
145 ["SetFiltered"] = function(self,value) 153 ["SetFiltered"] = function(self,value)
146 self.filtered = value 154 self.filtered = value
147 self:Redraw() 155 self:Redraw()
148 end, 156 end,
149 ["SelectList"] = function(self,value) 157 ["SelectList"] = function(self,value)
158 self.swidget:SetValue(value)
150 self.lref = LootLists:Select(value) 159 self.lref = LootLists:Select(value)
151 self:Redraw() 160 self:Redraw()
161 Comm:ActivateList(value)
152 end, 162 end,
153 ["DataEvent"] = function(self) 163 ["DataEvent"] = function(self)
154 self:Redraw() 164 self:Redraw()
155 end, 165 end,
156 ["GetMe"] = function(self) 166 ["GetMe"] = function(self)
211 end, 221 end,
212 } 222 }
213 223
214 local RListPopulator = 224 local RListPopulator =
215 { 225 {
216 data = {},
217 widget = nil, 226 widget = nil,
218 ["Release"] = function(self) self.data = {}; self.widget = nil end, 227 ["RollEvent"] = function(self) self:Redraw() end,
228 ["Release"] = function(self) self.widget = nil end,
219 ["Redraw"] = function(self) 229 ["Redraw"] = function(self)
220 self.widget:SetList(self.data) 230 self.widget:SetList(statebids)
221 RListEventDispatch:Event("Redraw") 231 RListEventDispatch:Event("Redraw")
222 end, 232 end,
223 ["SetWidget"] = function(self,w) 233 ["SetWidget"] = function(self,w)
224 if type(w) ~= "table" or type(w.SetList) ~= "function" then 234 if type(w) ~= "table" or type(w.SetList) ~= "function" then
225 _G.error("Bad SetWidget") 235 _G.error("Bad SetWidget")
226 end 236 end
227 self.widget = w 237 self.widget = w
228 if debug then 238 --if debug then
229 local dummydata = {} 239 -- local dummydata = {}
230 local tree = SListPopulator.data 240 -- local tree = SListPopulator.data
231 for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end 241 -- for i,v in pairs(tree) do dummydata[i] = copy(v); dummydata[i].disabled = false end
232 if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end 242 -- if dummydata[2] then dummydata[2].text = dummydata[2].text .. " (roll 73)" end
233 self.data = dummydata 243 -- self.data = dummydata
234 end 244 --end
235 self:Redraw() 245 self:Redraw()
236 end, 246 end,
237 ["Force"] = function(self,who) 247 ["Force"] = function(self,who)
238 for i,v in pairs(self.data) do
239 if who.value == v.value then
240 print(who.value .. " is already on the list")
241 return -- no double adds please
242 end
243 end
244 local new = self.Convert(who,72) 248 local new = self.Convert(who,72)
245 table.insert(self.data,new) 249 InitiateBid(new)
246 -- todo: keep this list sorted 250 --self:Redraw()
247 self:Redraw()
248 end, 251 end,
249 ["Retract"] = function(self,who) 252 ["Retract"] = function(self,who)
250 for i,v in pairs(self.data) do 253 -- todo
251 if who.value == v.value then 254 --for i,v in pairs(self.data) do
252 table.remove(self.data,i) 255 -- if who.value == v.value then
253 end 256 -- table.remove(self.data,i)
254 end 257 -- end
255 self:Redraw() 258 --end
259 InitiateRetract(copy(who))
260 --self:Redraw()
256 end, 261 end,
257 ["Convert"] = function(who,roll) -- convert an LE object into one suitable to put in a SelectorList 262 ["Convert"] = function(who,roll) -- convert an LE object into one suitable to put in a SelectorList
258 local new = copy(who) 263 local new = copy(who)
259 new.disabled = false -- todo: should be unnessary - they can't get on the list like this 264 new.disabled = false -- todo: should be unnessary - they can't get on the list like this
260 if roll then 265 if roll then
284 } 289 }
285 290
286 function OnInitializeSetStaticData() 291 function OnInitializeSetStaticData()
287 SetChangeListener(DataEventDispatch) 292 SetChangeListener(DataEventDispatch)
288 DataEventDispatch:RegisterListener(SListPopulator) 293 DataEventDispatch:RegisterListener(SListPopulator)
294 RegisterListenerRolls(RListPopulator)
289 end 295 end
290 296
291 function CreateGUI() 297 function CreateGUI()
292 -- special registration procedure to be closable with the escape button 298 -- special registration procedure to be closable with the escape button
293 --escapeButton.shown = true 299 --escapeButton.shown = true
394 rollButton:SetText("Offset Roll") 400 rollButton:SetText("Offset Roll")
395 rollButton:SetWidth(100) 401 rollButton:SetWidth(100)
396 402
397 RListEventDispatch:SetTarget(b1) 403 RListEventDispatch:SetTarget(b1)
398 RListPopulator:SetWidget(b1) 404 RListPopulator:SetWidget(b1)
405
406 InitiateOpenBid(LListEventDispatch:LatestValue())
399 407
400 local g1 408 local g1
401 if admin then 409 if admin then
402 b1.alignoffset = 0.25 -- or else g1 won't align well 410 b1.alignoffset = 0.25 -- or else g1 won't align well
403 g1 = AceGUI:Create("SimpleGroup") 411 g1 = AceGUI:Create("SimpleGroup")