diff Gui.lua @ 72:9e5b0a2368ad

Big progress towards GUI usefulness and communication between clients
author John@Yosemite-PC
date Sat, 07 Apr 2012 13:35:57 -0400
parents d5e2dfe0c269
children 7eb2963eea7d
line wrap: on
line diff
--- a/Gui.lua	Tue Apr 03 23:23:22 2012 -0400
+++ b/Gui.lua	Sat Apr 07 13:35:57 2012 -0400
@@ -49,12 +49,12 @@
     pulldown:SetWidth(175)
     pulldown:SetList(pull)
     SListPopulator:SetSwidget(pulldown)
-    pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:SelectList(value) end)
-    if ltemp > 0 then SListPopulator:SelectList(ltemp) end -- default value
+    pulldown:SetCallback("OnValueChanged", function(_,_,value) SListPopulator:PulldownEvent(value) end)
+    if ltemp > 0 then SListPopulator:PulldownEvent(ltemp) end -- default value
     return pulldown
 end
 
-local f, right
+local f, right -- important gui elements
 local escapeButton = 
 {
     shown = false,
@@ -154,15 +154,46 @@
         self.filtered = value
         self:Redraw()
     end,
-    ["SelectList"] = function(self,value) 
+    ["SelectList"] = function(self,value,nocomm) 
         self.swidget:SetValue(value)
-        self.lref = LootLists:Select(value)
-        self:Redraw()
-        Comm:ActivateList(value)
+        local l = LootLists:Select(value)
+        if l ~= self.lref then
+            self.lref = l
+            self:Redraw() 
+        end
+        if nocomm then InitiateActiveList(value) end
+    end,
+
+
+    ["PulldownEvent"] = function(self,value)
+        self:SelectList(value)
+        if admin and state == "looting" then
+            InitiateActivateList(value)
+        end
     end,
     ["DataEvent"] = function(self)
         self:Redraw()
     end,
+    ["StateEvent"] = function(self)
+        if state == "bidding" or (state == "looting" and not admin) then
+            self.swidget:SetDisabled(true)
+            self:SelectList(stateactivelist)
+        elseif state == "looting" and admin then
+            self.swidget:SetDisabled(false)
+        else
+            self.swidget:SetDisabled(false)
+        end
+        -- if bidding then disable pulldown
+        -- if looting and not admin then disable pulldown
+        -- if looting and admin then enable pulldown
+        -- otherwise enable pulldown
+    end,
+    ["ActiveListEvent"] = function(self)
+        self:SelectList(stateactivelist)
+    end,
+
+
+
     ["GetMe"] = function(self)
         local me = _G.UnitName("player")
         for i,v in pairs(self.data) do
@@ -291,6 +322,8 @@
 function OnInitializeSetStaticData()
     SetChangeListener(DataEventDispatch)
     DataEventDispatch:RegisterListener(SListPopulator)
+    RegisterListenerActiveListChanged(SListPopulator)
+    RegisterListenerStateChange(SListPopulator)
     RegisterListenerRolls(RListPopulator)
 end
 
@@ -301,7 +334,6 @@
     --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON")
 
     if f then return end -- no second gui please
-    local admin = admin or true
     f = AceGUI:Create("Frame")
 
     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)