comparison Gui.lua @ 73:7eb2963eea7d

Further splitting up GUI and State Starting to integrate looting events
author John@Yosemite-PC
date Sun, 08 Apr 2012 22:13:17 -0400
parents 9e5b0a2368ad
children ed1c9fd4cc95
comparison
equal deleted inserted replaced
72:9e5b0a2368ad 73:7eb2963eea7d
31 31
32 local CreateListSelector = function(SListPopulator) 32 local CreateListSelector = function(SListPopulator)
33 PersonList:RefreshRaidList() 33 PersonList:RefreshRaidList()
34 local pulldown = AceGUI:Create("Dropdown") 34 local pulldown = AceGUI:Create("Dropdown")
35 local pull = {} 35 local pull = {}
36 local ltemp = 0
37 local lids = LootLists:GetAllIds() 36 local lids = LootLists:GetAllIds()
38 for _,v in pairs(lids) do 37 for _,v in pairs(lids) do
39 local l = LootLists:Select(v) 38 local l = LootLists:Select(v)
40 pull[l:GetId()] = l:GetName() 39 pull[l:GetId()] = l:GetName()
41 --local entry = {value=i,text=v.name} 40 --local entry = {value=i,text=v.name}
42 if l:GetLength() > 0 then 41 if l:GetLength() > 0 then
43 pulldown:SetItemDisabled(i,true) 42 pulldown:SetItemDisabled(i,true)
44 if ltemp == 0 then
45 ltemp = l:GetId()
46 end
47 end 43 end
48 end 44 end
49 pulldown:SetWidth(175) 45 pulldown:SetWidth(175)
50 pulldown:SetList(pull) 46 pulldown:SetList(pull)
51 SListPopulator:SetSwidget(pulldown) 47 SListPopulator:SetSwidget(pulldown)
52 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:PulldownEvent(value) end) 48 pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:PulldownEvent(value) end)
53 if ltemp > 0 then SListPopulator:PulldownEvent(ltemp) end -- default value 49 if stateactivelist > 0 then SListPopulator:PulldownEvent(stateactivelist) end -- default value
54 return pulldown 50 return pulldown
55 end 51 end
56 52
57 local f, right -- important gui elements 53 local f, right -- important gui elements
58 local escapeButton = 54 local escapeButton =
173 end, 169 end,
174 ["DataEvent"] = function(self) 170 ["DataEvent"] = function(self)
175 self:Redraw() 171 self:Redraw()
176 end, 172 end,
177 ["StateEvent"] = function(self) 173 ["StateEvent"] = function(self)
174 print("State event in SL: ", state, admin)
178 if state == "bidding" or (state == "looting" and not admin) then 175 if state == "bidding" or (state == "looting" and not admin) then
179 self.swidget:SetDisabled(true) 176 self.swidget:SetDisabled(true)
180 self:SelectList(stateactivelist) 177 self:SelectList(stateactivelist)
181 elseif state == "looting" and admin then 178 elseif state == "looting" and admin then
182 self.swidget:SetDisabled(false) 179 self.swidget:SetDisabled(false)
208 { 205 {
209 -- todo: set event receivers from the comm and for loot 206 -- todo: set event receivers from the comm and for loot
210 data = {}, 207 data = {},
211 widget = nil, 208 widget = nil,
212 ["Release"] = function(self) self.data = {}; self.widget = nil end, 209 ["Release"] = function(self) self.data = {}; self.widget = nil end,
210 ["ItemListEvent"] = function(self) self:Redraw() end,
213 ["Redraw"]= function(self) 211 ["Redraw"]= function(self)
214 self.widget:SetList(self.data) 212 self.data = {}
215 LListEventDispatch:Event("Redraw") 213 for i,v in pairs(stateitemlist) do
214 local entry = {value=i, text=v, link=v}
215 table.insert(self.data,entry)
216 end
217 if self.widget then
218 self.widget:SetList(self.data)
219 LListEventDispatch:Event("Redraw")
220 end
216 end, 221 end,
217 ["SetWidget"] = function(self,w) 222 ["SetWidget"] = function(self,w)
218 if type(w) ~= "table" or type(w.SetList) ~= "function" then 223 if type(w) ~= "table" or type(w.SetList) ~= "function" then
219 _G.error("Bad SetWidget") 224 _G.error("Bad SetWidget")
220 end 225 end
323 SetChangeListener(DataEventDispatch) 328 SetChangeListener(DataEventDispatch)
324 DataEventDispatch:RegisterListener(SListPopulator) 329 DataEventDispatch:RegisterListener(SListPopulator)
325 RegisterListenerActiveListChanged(SListPopulator) 330 RegisterListenerActiveListChanged(SListPopulator)
326 RegisterListenerStateChange(SListPopulator) 331 RegisterListenerStateChange(SListPopulator)
327 RegisterListenerRolls(RListPopulator) 332 RegisterListenerRolls(RListPopulator)
333 RegisterItemListListener(LListPopulator)
328 end 334 end
329 335
330 function CreateGUI() 336 function CreateGUI()
331 -- special registration procedure to be closable with the escape button 337 -- special registration procedure to be closable with the escape button
332 --escapeButton.shown = true 338 --escapeButton.shown = true