Add UI configuration window

Sasky [06-12-14 - 04:48]
Add UI configuration window
Filename
AutoInvite.lua
AutoInvite.txt
AutoInviteUI.lua
diff --git a/AutoInvite.lua b/AutoInvite.lua
index 8ac44fa..46e4f80 100644
--- a/AutoInvite.lua
+++ b/AutoInvite.lua
@@ -3,7 +3,7 @@
   * Author: Sasky
 ]]--

-local AutoInvite = {}
+AutoInvite = {}
 AutoInvite.watch = ""
 AutoInvite.AddonId = "AutoInvite"
 AutoInvite.listening = false
diff --git a/AutoInvite.txt b/AutoInvite.txt
index 6a72f18..e6a897b 100644
--- a/AutoInvite.txt
+++ b/AutoInvite.txt
@@ -2,6 +2,22 @@
 ## Title: AutoInvite
 ## Version: 1.1.1
 ## Author: Sasky
+## OptionalDependsOn: LibAddonMenu-2.0

-AutoInvite.lua
+lib/LibStub.lua
+lib/LibAddonMenu-2.0/LibAddonMenu-2.0.lua
+lib/LibAddonMenu-2.0/controls/panel.lua
+lib/LibAddonMenu-2.0/controls/submenu.lua
+lib/LibAddonMenu-2.0/controls/button.lua
+lib/LibAddonMenu-2.0/controls/checkbox.lua
+lib/LibAddonMenu-2.0/controls/colorpicker.lua
+lib/LibAddonMenu-2.0/controls/custom.lua
+lib/LibAddonMenu-2.0/controls/description.lua
+lib/LibAddonMenu-2.0/controls/dropdown.lua
+lib/LibAddonMenu-2.0/controls/editbox.lua
+lib/LibAddonMenu-2.0/controls/header.lua
+lib/LibAddonMenu-2.0/controls/slider.lua
+lib/LibAddonMenu-2.0/controls/texture.lua

+AutoInviteUI.lua
+AutoInvite.lua
\ No newline at end of file
diff --git a/AutoInviteUI.lua b/AutoInviteUI.lua
new file mode 100644
index 0000000..796a903
--- /dev/null
+++ b/AutoInviteUI.lua
@@ -0,0 +1,146 @@
+
+AutoInviteUI = {}
+local ui = AutoInviteUI
+local wm = WINDOW_MANAGER
+
+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.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:SetAnchor(TOPLEFT, ui.main, TOPLEFT, 0, 0)
+    ui.bg:SetCenterColor( 0, 0, 0, .7 )
+    ui.bg:SetEdgeColor( 1, 1, 1, 0 )
+
+    ui.title = LAMCreateControl.header(ui, {
+        type = "header",
+        name = "AutoInvite Options",
+        width = "half"
+    })
+    ui.title:SetAnchor(TOPLEFT, ui.main, TOPLEFT, 5, 5)
+    ui.title:SetWidth(270)
+    ui.title.divider:ClearAnchors()
+    ui.title.divider:SetAnchor(BOTTOM)
+    ui.title.header:ClearAnchors()
+    ui.title.header:SetAnchor(TOPLEFT)
+
+    ui.enabled = LAMCreateControl.checkbox(ui, {
+        type = "checkbox",
+        name = "Enabled",
+        tooltip = "AutoInvite is currently enabled to run",
+        getFunc = function() return AutoInvite.listening end,
+        setFunc = function(val) AutoInvite.listening = val end,
+        width = "half"
+    })
+    ui.enabled:SetDimensions(250, 26)
+    ui.enabled:SetAnchor(TOPLEFT, ui.title, BOTTOMLEFT, 10, 5)
+
+    ui.text = LAMCreateControl.editbox(ui, {
+        type = "editbox",
+        name = "Invite String",
+        tooltip = "Text to check messages to auto-invite for",
+        getFunc = function() return AutoInvite.watch end,
+        setFunc = function(val) AutoInvite.watch = val end,
+        width = "half"
+    })
+    ui.text:SetWidth(260)
+    ui.text:SetAnchor(TOPLEFT, ui.enabled, BOTTOMLEFT, 0, 5)
+
+    ui.max = LAMCreateControl.slider(ui, {
+        type = "slider",
+        name = "Max group size",
+        tooltip = "Maximum number of players to invite to group",
+        min = 4,
+        max = 24,
+        getFunc = function() return AutoInvite.maxSize end,
+        setFunc = function(val) AutoInvite.maxSize = val end,
+        default = 24,
+        width = "half"
+    })
+    ui.max:SetAnchor(TOPLEFT, ui.text, BOTTOMLEFT, 0, 10)
+
+    ui.restart = LAMCreateControl.checkbox(ui, {
+        type = "checkbox",
+        name = "Restart",
+        tooltip = "Restart AutoInvite if drop below max",
+        getFunc = function() return false end,
+        setFunc = function(val)  end,
+        width = "half",
+        disabled = true
+    })
+    ui.restart:SetDimensions(250, 26)
+    ui.restart:SetAnchor(TOPLEFT, ui.max, BOTTOMLEFT, 0, 12)
+
+    ui.cyr = LAMCreateControl.checkbox(ui, {
+        type = "checkbox",
+        name = "Cyrodiil Check",
+        tooltip = "Only invite players that are in Cyrodiil",
+        getFunc = function() return false end,
+        setFunc = function(val)  end,
+        width = "half",
+        disabled = true
+    })
+    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 false end,
+        setFunc = function(val)  end,
+        width = "half",
+        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 300 end,
+        setFunc = function(val) end,
+        default = 300,
+        width = "half",
+        disabled = true
+    })
+    ui.kickTime:SetAnchor(TOPLEFT, ui.kick, BOTTOMLEFT, 0, 5)
+end
+
+function AutoInviteUI.menuShow()
+    AutoInviteUI.showIfGroup()
+    EVENT_MANAGER:RegisterForUpdate("AutoInviteMenuCheck", 100, AutoInviteUI.showIfGroup)
+end
+
+function AutoInviteUI.showIfGroup()
+    ui.main:SetHidden(ZO_GroupList:IsHidden())
+end
+
+function AutoInviteUI.menuHide()
+    ui.main:SetHidden(true)
+    EVENT_MANAGER:UnregisterForUpdate("AutoInviteMenuCheck")
+end
+
+function AutoInviteUI.init()
+    if ui.created then return end
+    ui.created = true
+    AutoInviteUI.create()
+
+    --Register events
+    EVENT_MANAGER:RegisterForEvent('AutoInvite', EVENT_ACTION_LAYER_POPPED, AutoInviteUI.menuHide)
+    EVENT_MANAGER:RegisterForEvent('AutoInvite', EVENT_ACTION_LAYER_PUSHED, AutoInviteUI.menuShow)
+end
+
+SLASH_COMMANDS["/aiui"] = AutoInviteUI.init
+SLASH_COMMANDS["/zzg"] = function()
+    d(ZO_GroupList:IsHidden())
+end