-- This file is part of AutoInvite
--
-- (C) 2014 Scott Yeskie (Sasky)
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

AutoInviteUI = AutoInviteUI or {}
local ui = AutoInviteUI
local wm = WINDOW_MANAGER

function AutoInviteUI:CreateEnabledFragment()
    ui.main = wm:CreateTopLevelWindow("AutoInviteEnabledFragment")
    ui.main:SetHidden(true)
    ui.scroll = ui.main -- For using LAM controls
    ui.data = {}

    ui.enabled = LAMCreateControl.checkbox(ui, {
        type = "checkbox",
        name = GetString(SI_AUTO_INVITE_OPT_ENABLED),
        tooltip = GetString(SI_AUTO_INVITE_TT_ENABLED),
        getFunc = function() return AutoInvite.listening end,
        setFunc = function(val)
            if val then AutoInvite.startListening() else AutoInvite.disable() end
        end,
        width = "half"
    })
    ui.enabled:SetDimensions(250, 26)
    ui.enabled:SetAnchor(TOP, ZO_GroupList, TOP, 0, 20)

    --TODO: Sanity check between enable and blank string
    ui.text = LAMCreateControl.editbox(ui, {
        type = "editbox",
        name = GetString(SI_AUTO_INVITE_OPT_STRING),
        tooltip = GetString(SI_AUTO_INVITE_TT_STRING),
        getFunc = function() return AutoInvite.cfg.watchStr end,
        setFunc = function(val) AutoInvite.cfg.watchStr = val end,
        --width = "half"
    })
    ui.text:SetWidth(260)
    ui.text:SetAnchor(TOPRIGHT, ZO_GroupList, TOPRIGHT, -40, 20)

    AUTO_INVITE_ENABLED_FRAGMENT = ZO_FadeSceneFragment:New(ui.main)
end