Add UI refresh code

Sasky [06-12-14 - 07:13]
Add UI refresh code
Add experimental header to options.
Switch auto-kick to a notice
Filename
AutoInviteUI.lua
diff --git a/AutoInviteUI.lua b/AutoInviteUI.lua
index a554ae4..608a8f8 100644
--- a/AutoInviteUI.lua
+++ b/AutoInviteUI.lua
@@ -7,13 +7,13 @@ function AutoInviteUI.create()
     local pre = "AAAAutoInviteUI"
     ui.main = wm:CreateTopLevelWindow(pre .. "Panel")
     ui.main:SetAnchor(TOPRIGHT, ZO_SharedRightBackground, TOPLEFT, -50, 50)
-    ui.main:SetDimensions(280,370)
+    ui.main:SetDimensions(280,400)

     ui.scroll = ui.main -- For using LAM controls
     ui.data = {}

     ui.bg = wm:CreateControl(pre .. "bg", ui.main, CT_BACKDROP)
-    ui.bg:SetDimensions(280,370)
+    ui.bg:SetDimensions(280,400)
     ui.bg:SetAnchor(TOPLEFT, ui.main, TOPLEFT, 0, 0)
     ui.bg:SetCenterColor( 0, 0, 0, .7 )
     ui.bg:SetEdgeColor( 1, 1, 1, 0 )
@@ -33,9 +33,11 @@ function AutoInviteUI.create()
     ui.enabled = LAMCreateControl.checkbox(ui, {
         type = "checkbox",
         name = "Enabled",
-        tooltip = "AutoInvite is currently enabled to run",
+        tooltip = "Whether to enable AutoInvite",
         getFunc = function() return AutoInvite.listening end,
-        setFunc = function(val) AutoInvite.listening = val end,
+        setFunc = function(val)
+            if val then AutoInvite.startListening() else AutoInvite.disable() end
+        end,
         width = "half"
     })
     ui.enabled:SetDimensions(250, 26)
@@ -65,60 +67,79 @@ function AutoInviteUI.create()
     })
     ui.max:SetAnchor(TOPLEFT, ui.text, BOTTOMLEFT, 0, 10)

+    ui.expr = LAMCreateControl.header(ui, {
+        type = "header",
+        name = "Experimental",
+        width = "half"
+    })
+    ui.expr:SetAnchor(TOPLEFT, ui.max, TOPLEFT, 0, 65)
+    ui.expr:SetWidth(270)
+    ui.expr.divider:ClearAnchors()
+    ui.expr.divider:SetAnchor(BOTTOM)
+    ui.expr.header:ClearAnchors()
+    ui.expr.header:SetAnchor(TOPLEFT)
+    ui.expr.header:SetColor(1.0, 0.3, 0.3, 1.0)
+
     ui.restart = LAMCreateControl.checkbox(ui, {
         type = "checkbox",
         name = "Restart",
         tooltip = "Restart AutoInvite if drop below max",
         getFunc = function() return AutoInvite.cfg.restart end,
         setFunc = function(val) AutoInvite.cfg.restart = val  end,
-        width = "half",
-        warning = "Experimental"
+        width = "half"
     })
     ui.restart:SetDimensions(250, 26)
-    ui.restart:SetAnchor(TOPLEFT, ui.max, BOTTOMLEFT, 0, 12)
+    ui.restart:SetAnchor(TOPLEFT, ui.expr, BOTTOMLEFT, 0, 12)

     ui.cyr = LAMCreateControl.checkbox(ui, {
         type = "checkbox",
         name = "Cyrodiil Check",
-        tooltip = "Only invite players that are in Cyrodiil",
+        tooltip = "Only invite players that are in Cyrodiil.\n(This only runs if you are in Cyrodiil yourself.)",
         getFunc = function() return AutoInvite.cfg.cyrCheck end,
         setFunc = function(val) AutoInvite.cfg.cyrCheck = val end,
-        width = "half",
-        warning = "Experimental"
+        width = "half"
     })
     ui.cyr:SetDimensions(250, 26)
     ui.cyr:SetAnchor(TOPLEFT, ui.restart, BOTTOMLEFT, 0, 5)

-    ui.kick = LAMCreateControl.checkbox(ui, {
-        type = "checkbox",
-        name = "Auto kick",
-        tooltip = "Kick players that go offline",
-        getFunc = function() return AutoInvite.cfg.autoKick end,
-        setFunc = function(val) AutoInvite.cfg.autoKick = val  end,
-        width = "half",
-        warning = "Coming soon",
-        disabled = true
-    })
-    ui.kick:SetDimensions(250, 26)
-    ui.kick:SetAnchor(TOPLEFT, ui.cyr, BOTTOMLEFT, 0, 5)
-
-    ui.kickTime = LAMCreateControl.slider(ui, {
-        type = "slider",
-        name = "Time before kick",
-        tooltip = "Number of seconds to wait before kicking an offline player",
-        min = 5,
-        max = 600,
-        getFunc = function() return AutoInvite.cfg.kickDelay end,
-        setFunc = function(val) AutoInvite.cfg.kickDelay = 300 end,
-        default = 300,
-        width = "half",
-        disabled = true
+--    ui.kick = LAMCreateControl.checkbox(ui, {
+--        type = "checkbox",
+--        name = "Auto kick",
+--        tooltip = "Kick players that go offline",
+--        getFunc = function() return AutoInvite.cfg.autoKick end,
+--        setFunc = function(val) AutoInvite.cfg.autoKick = val  end,
+--        width = "half",
+--        warning = "Coming soon"
+--    })
+--    ui.kick:SetDimensions(250, 26)
+--    ui.kick:SetAnchor(TOPLEFT, ui.cyr, BOTTOMLEFT, 0, 5)
+--
+--    ui.kickTime = LAMCreateControl.slider(ui, {
+--        type = "slider",
+--        name = "Time before kick",
+--        tooltip = "Number of seconds to wait before kicking an offline player",
+--        min = 5,
+--        max = 600,
+--        getFunc = function() return AutoInvite.cfg.kickDelay end,
+--        setFunc = function(val) AutoInvite.cfg.kickDelay = 300 end,
+--        default = 300,
+--        width = "half"
+--    })
+--    ui.kickTime:SetAnchor(TOPLEFT, ui.kick, BOTTOMLEFT, 0, 5)
+
+    ui.note = LAMCreateControl.description(ui, {
+        type = "description",
+        title = "Coming Soon",
+        text = "Automatically kick players offline after certain time",
+        width = "half"
     })
-    ui.kickTime:SetAnchor(TOPLEFT, ui.kick, BOTTOMLEFT, 0, 5)
+    ui.note:SetAnchor(TOPLEFT, ui.cyr, BOTTOMLEFT, 0, 25)
+    ui.note.desc:SetColor(.7,.7,.7,1)
 end

 function AutoInviteUI.menuShow()
     AutoInviteUI.showIfGroup()
+    AutoInviteUI.refresh()
     EVENT_MANAGER:RegisterForUpdate("AutoInviteMenuCheck", 100, AutoInviteUI.showIfGroup)
 end

@@ -131,6 +152,14 @@ function AutoInviteUI.menuHide()
     EVENT_MANAGER:UnregisterForUpdate("AutoInviteMenuCheck")
 end

+function AutoInviteUI.refresh()
+    ui.enabled:UpdateValue()
+    ui.cyr:UpdateValue()
+    ui.restart:UpdateValue()
+    ui.max:UpdateValue()
+    ui.text:UpdateValue()
+end
+
 function AutoInviteUI.init()
     if ui.created then return end
     ui.created = true