diff 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
line wrap: on
line diff
--- a/Gui.lua	Sat Apr 07 13:35:57 2012 -0400
+++ b/Gui.lua	Sun Apr 08 22:13:17 2012 -0400
@@ -33,7 +33,6 @@
     PersonList:RefreshRaidList()
     local pulldown = AceGUI:Create("Dropdown")
     local pull = {}
-    local ltemp = 0
     local lids = LootLists:GetAllIds()
     for _,v in pairs(lids) do
         local l = LootLists:Select(v)
@@ -41,16 +40,13 @@
         --local entry = {value=i,text=v.name}
         if l:GetLength() > 0 then
             pulldown:SetItemDisabled(i,true)
-            if ltemp == 0 then
-                ltemp = l:GetId()
-            end
         end
     end
     pulldown:SetWidth(175)
     pulldown:SetList(pull)
     SListPopulator:SetSwidget(pulldown)
     pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:PulldownEvent(value) end)
-    if ltemp > 0 then SListPopulator:PulldownEvent(ltemp) end -- default value
+    if stateactivelist > 0 then SListPopulator:PulldownEvent(stateactivelist) end -- default value
     return pulldown
 end
 
@@ -175,6 +171,7 @@
         self:Redraw()
     end,
     ["StateEvent"] = function(self)
+        print("State event in SL: ", state, admin)
         if state == "bidding" or (state == "looting" and not admin) then
             self.swidget:SetDisabled(true)
             self:SelectList(stateactivelist)
@@ -210,9 +207,17 @@
     data = {},
     widget = nil,
     ["Release"] = function(self) self.data = {}; self.widget = nil end,
+    ["ItemListEvent"] = function(self) self:Redraw() end,
     ["Redraw"]= function(self)
-        self.widget:SetList(self.data)
-        LListEventDispatch:Event("Redraw")
+        self.data = {}
+        for i,v in pairs(stateitemlist) do
+            local entry = {value=i, text=v, link=v}
+            table.insert(self.data,entry)
+        end
+        if self.widget then
+            self.widget:SetList(self.data)
+            LListEventDispatch:Event("Redraw")
+        end
     end,
     ["SetWidget"] = function(self,w)
         if type(w) ~= "table" or type(w.SetList) ~= "function" then
@@ -325,6 +330,7 @@
     RegisterListenerActiveListChanged(SListPopulator)
     RegisterListenerStateChange(SListPopulator)
     RegisterListenerRolls(RListPopulator)
+    RegisterItemListListener(LListPopulator)
 end
 
 function CreateGUI()