changeset 60:dcf7c835d0a7

Not leaking resources is better ...
author John@Yosemite-PC
date Sun, 25 Mar 2012 18:07:00 -0400
parents c7330bc4a9ea
children 9b1588bd4398
files Gui.lua
diffstat 1 files changed, 43 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/Gui.lua	Sun Mar 25 17:43:31 2012 -0400
+++ b/Gui.lua	Sun Mar 25 18:07:00 2012 -0400
@@ -67,7 +67,7 @@
 {
     shown = false,
     ["IsShown"] = function(self) return self.shown end,
-    ["Hide"] = function(self) if f then bsk.print("Release!");AceGUI:Release(f); self.shown=false end end
+    ["Hide"] = function(self) if f then AceGUI:Release(f); self.shown=false end end
 }
 
 function CreateGUI()
@@ -76,16 +76,16 @@
     --_G["BSK_ESCAPEBUTTON"] = escapeButton
     --table.insert(_G.UISpecialFrames, "BSK_ESCAPEBUTTON")
 
-    local admin = bsk.admin
+    if f then return end -- no second gui please
+    local admin = bsk.admin or true
     f = AceGUI:Create("Frame")
 
-    f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget) end)
+    f:SetCallback("OnClose",function(widget) escapeButton.shown = false; AceGUI:Release(widget); f=nil end)
     f:SetTitle("BSK")
     f:SetLayout("Flow")
     f:SetHeight(680) 
     f:SetWidth(580)
 
-
     local left = AceGUI:Create("InlineGroup")
     left:SetLayout("List")
     left:SetWidth(175)
@@ -144,15 +144,20 @@
         },
     })
 
-    local alb1 = AceGUI:Create("Button")
-    alb1:SetWidth(100)
-    alb1:SetText("Open Bids")
-    local alb2 = AceGUI:Create("Button")
-    alb2:SetWidth(100)
-    alb2:SetText("Assign")
-    local alb3 = AceGUI:Create("Button")
-    alb3:SetWidth(100)
-    alb3:SetText("Suicide")
+    local alb1, alb2, alb3
+    if admin then 
+        alb1 = AceGUI:Create("Button")
+        alb1:SetWidth(100)
+        alb1:SetText("Open Bids")
+
+        alb2 = AceGUI:Create("Button")
+        alb2:SetWidth(100)
+        alb2:SetText("Assign")
+
+        alb3 = AceGUI:Create("Button")
+        alb3:SetWidth(100)
+        alb3:SetText("Suicide")
+    end
 
     local spacer = AceGUI:Create("Label")
     spacer:SetText(" ")
@@ -191,27 +196,34 @@
     rollButton:SetText("Offset Roll")
     rollButton:SetWidth(100)
 
-    b1.alignoffset = 0.25 -- or else g1 won't align well
-    local g1 = AceGUI:Create("SimpleGroup")
-    g1.alignoffset = 0.25
-    g1:SetWidth(120)
-    g1:SetLayout("List")
-    local adminForce = AceGUI:Create("Button")
-    adminForce:SetText("Force bid")
-    adminForce:SetWidth(100)
-    local adminRetract = AceGUI:Create("Button")
-    adminRetract:SetText("Retract bid")
-    adminRetract:SetWidth(100)
-    g1:AddChildren(adminForce,adminRetract)
+    local g1, suicideSelected, undo
+    if admin then
+        b1.alignoffset = 0.25 -- or else g1 won't align well
+        g1 = AceGUI:Create("SimpleGroup")
+        g1.alignoffset = 0.25
+        g1:SetWidth(120)
+        g1:SetLayout("List")
 
+        adminForce = AceGUI:Create("Button")
+        adminForce:SetText("Force bid")
+        adminForce:SetWidth(100)
 
+        adminRetract = AceGUI:Create("Button")
+        adminRetract:SetText("Retract bid")
+        adminRetract:SetWidth(100)
 
-    local suicideSelected = AceGUI:Create("Button")
-    suicideSelected:SetFullWidth(true)
-    suicideSelected:SetText("Suicide")
-    local undo = AceGUI:Create("Button")
-    undo:SetText("Undo")
-    undo:SetFullWidth(true)
+        g1:AddChildren(adminForce,adminRetract)
+
+        suicideSelected = AceGUI:Create("Button")
+        suicideSelected:SetFullWidth(true)
+        suicideSelected:SetText("Suicide")
+
+        undo = AceGUI:Create("Button")
+        undo:SetText("Undo")
+        undo:SetFullWidth(true)
+    end
+
+
     local filter = AceGUI:Create("CheckBox")
     filter:SetLabel("Only show active")
     filter:SetFullWidth(true)