local _,ns = ...
local L = ns.L

local dialogADVOptionsW, dialogADVOptionsH = 380-24, 440
local timerADVOptions  = ns.Utils.crear9SliceFrame(UIParent,136, 171, 74, 100, 146, 158, 84, 88, dialogADVOptionsW,dialogADVOptionsH, "mailpanel", 512, 512)
timerADVOptions:SetClampedToScreen(true)
timerADVOptions:SetMovable(true)
timerADVOptions:SetResizable(false)
timerADVOptions:EnableMouse(true)
timerADVOptions:SetToplevel(true)
timerADVOptions:SetFrameStrata("HIGH")
timerADVOptions:SetScript("OnMouseDown",function (self,button) if button=="LeftButton" then timerADVOptions:StartMoving() end end)
timerADVOptions:SetScript("OnMouseUp",function (self,button) if button=="LeftButton" then timerADVOptions:StopMovingOrSizing()end end)
timerADVOptions:SetPoint("CENTER")

timerADVOptions.texBGMoreThan1 = timerADVOptions:CreateTexture()
timerADVOptions.texBGMoreThan1:SetColorTexture(0/255, 2/255, 11/255 , 0.5)
timerADVOptions.texBGMoreThan1:SetPoint("TOPLEFT", timerADVOptions, "TOPLEFT", 14, -145)
timerADVOptions.texBGMoreThan1:SetPoint("BOTTOMRIGHT", timerADVOptions, "TOPLEFT", 183, -430)


local checkDMB = CreateFrame("CheckButton", nil, timerADVOptions, "UICheckButtonTemplate");
checkDMB:SetPoint("TOPLEFT", timerADVOptions, "TOPLEFT", 15, -20);
checkDMB.text:SetText(L["/DBM break Timer"]);
checkDMB:SetScript("OnClick", function (self)
    AutoScrap_CharSettings.lastTimerconfig.DBMTimer = self:GetChecked()
    ns.updateTimerLocalSetup ()
end)

local checkCountDown = CreateFrame("CheckButton", nil, timerADVOptions, "UICheckButtonTemplate");
checkCountDown:SetPoint("TOPLEFT", checkDMB, "BOTTOMLEFT", 0, 10);
checkCountDown.text:SetText(L["/CountDown Timer"]);
checkCountDown:SetScript("OnClick", function (self)
    AutoScrap_CharSettings.lastTimerconfig.countDownTimer = self:GetChecked()
    ns.updateTimerLocalSetup ()
end)

local textoKillTimerADV = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontNormal")
textoKillTimerADV:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
textoKillTimerADV:SetText(L["Kill Timer: (seconds)"])
textoKillTimerADV:SetPoint("TOPLEFT", checkCountDown, "BOTTOMLEFT", 7, -9)

local editBoxW, editBoxH = 40, 18

local ebBg = CreateFrame ("Frame", nil, timerADVOptions)
ebBg:SetSize(editBoxW, editBoxH)
ebBg.tex = ebBg:CreateTexture()
ebBg.tex:SetAllPoints(ebBg)
ebBg.tex:SetColorTexture(0/255, 2/255, 11/255 , 0.7)
ebBg:SetPoint("TOPLEFT", textoKillTimerADV, "BOTTOMLEFT", 0, -5)

local function validateNumber(type, number)
    if number and tonumber(number) and (tonumber(number)%1==0) and (tonumber(number)<=3600) and (tonumber(number)>=1) then
        if type == "kill" then
            AutoScrap_CharSettings.lastTimerconfig.killTimer = tonumber(number)
        elseif type == "break" then
            AutoScrap_CharSettings.lastTimerconfig.breakTimer = tonumber(number)
        elseif type == "sell" then
            AutoScrap_CharSettings.lastTimerconfig.sellTimer = tonumber(number)
        end
    end
    ns.populateTimerADVOptionsInfo()
end

local eb = CreateFrame("EditBox", nil, timerADVOptions)
eb:SetSize(editBoxW, editBoxH)
eb:SetMaxLetters(4)
eb:SetPoint("CENTER", ebBg, "CENTER")
eb:SetMultiLine(false)
eb:SetAutoFocus(false)
eb:SetFontObject("ChatFontNormal")
eb:SetText("91")
--eb:HighlightText(0)
eb:SetScript("OnEscapePressed",function(self) self:ClearFocus()  end)
eb:SetScript("OnEnterPressed",function(self) self:ClearFocus()  validateNumber("kill", self:GetText())  end)
--eb:SetScript("OnTextChanged", function (self) validateNumber("kill", self:GetText()) end)

eb.bSet = CreateFrame("Button", nil, timerADVOptions, "UIPanelButtonTemplate")
eb.bSet:SetPoint("LEFT",ebBg,"RIGHT",1,0)
eb.bSet:SetSize(30, 18)
eb.bSet:SetText("Set")
eb.bSet:SetScript("OnClick", function(self, button)
	if(button == "LeftButton") then
        validateNumber("kill", eb:GetText())
    end
end)
local textoKillTimerADVresult = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontHighlightSmall")
textoKillTimerADVresult:SetFont("Fonts\\FRIZQT__.TTF", 10, "")
textoKillTimerADVresult:SetText(L["Kill Time: "]..ns.Utils.horaBonita(91))
textoKillTimerADVresult:SetPoint("TOPLEFT", ebBg, "BOTTOMLEFT", 0, -3)

local checkMultipleRounds = CreateFrame("CheckButton", nil, timerADVOptions, "UICheckButtonTemplate");
checkMultipleRounds:SetPoint("TOPLEFT", textoKillTimerADVresult, "BOTTOMLEFT", -7, -12);
checkMultipleRounds.text:SetText(L["Enable Break Timer"]);
checkMultipleRounds:SetScript("OnClick", function (self)
    AutoScrap_CharSettings.lastTimerconfig.enableBreak = self:GetChecked()
    ns.updateTimerLocalSetup ()
end)

local textoBreakTimerADV = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontNormal")
textoBreakTimerADV:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
textoBreakTimerADV:SetText(L["Break Timer: (seconds)"])
textoBreakTimerADV:SetPoint("TOPLEFT", checkMultipleRounds, "BOTTOMLEFT", 7, 0)

local ebBreakBg = CreateFrame ("Frame", nil, timerADVOptions)
ebBreakBg:SetSize(editBoxW, editBoxH)
ebBreakBg.tex = ebBreakBg:CreateTexture()
ebBreakBg.tex:SetAllPoints(ebBreakBg)
ebBreakBg.tex:SetColorTexture(0/255, 2/255, 11/255 , 0.7)
ebBreakBg:SetPoint("TOPLEFT", textoBreakTimerADV, "BOTTOMLEFT", 0, -5)

local ebBreak = CreateFrame("EditBox", nil, timerADVOptions)
ebBreak:SetSize(editBoxW, editBoxH)
ebBreak:SetMaxLetters(4)
ebBreak:SetPoint("CENTER", ebBreakBg, "CENTER")
ebBreak:SetMultiLine(false)
ebBreak:SetAutoFocus(false)
ebBreak:SetFontObject("ChatFontNormal")
ebBreak:SetText("91")
--eb:HighlightText(0)
ebBreak:SetScript("OnEscapePressed",function(self) self:ClearFocus()  end)
ebBreak:SetScript("OnEnterPressed",function(self) self:ClearFocus() validateNumber("break", self:GetText()) end)

ebBreak.bSet = CreateFrame("Button", nil, timerADVOptions, "UIPanelButtonTemplate")
ebBreak.bSet:SetPoint("LEFT",ebBreakBg,"RIGHT",1,0)
ebBreak.bSet:SetSize(30, 18)
ebBreak.bSet:SetText("Set")
ebBreak.bSet:SetScript("OnClick", function(self, button)
	if(button == "LeftButton") then
        validateNumber("break", ebBreak:GetText())
    end
end)

local textoBreakTimerADVresult = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontHighlightSmall")
textoBreakTimerADVresult:SetFont("Fonts\\FRIZQT__.TTF", 10, "")
textoBreakTimerADVresult:SetText(L["Break Time: "]..ns.Utils.horaBonita(91))
textoBreakTimerADVresult:SetPoint("TOPLEFT", ebBreak, "BOTTOMLEFT", 0, -3)


local autoSellTimerText = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontNormal")
autoSellTimerText:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
autoSellTimerText:SetText("AutoSell Bag: (%)")
autoSellTimerText:SetPoint("TOPLEFT", textoBreakTimerADVresult, "BOTTOMLEFT", 0, -17)

autoSellTimerText.slider1 = CreateFrame("SLIDER", nil, timerADVOptions, "OptionsSliderTemplate");
autoSellTimerText.slider1:SetPoint("TOPLEFT", autoSellTimerText, "BOTTOMLEFT", 0, -17);
autoSellTimerText.slider1:SetMinMaxValues(1, 100);
autoSellTimerText.slider1.Low:SetText("1")
autoSellTimerText.slider1.High:SetText("100")
autoSellTimerText.slider1:SetValue(20);
autoSellTimerText.slider1.Text:SetText("20%")

autoSellTimerText.slider1:SetValueStep(1)
autoSellTimerText.slider1:SetObeyStepOnDrag(true) --fuerza moverse en steps la barrita

local autoSellTimerRoundsText = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontNormal")
autoSellTimerRoundsText:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
autoSellTimerRoundsText:SetText("Max Rounds to Sell:")
autoSellTimerRoundsText:SetPoint("TOPLEFT", autoSellTimerText.slider1, "BOTTOMLEFT", 0, -17)

autoSellTimerRoundsText.slider1 = CreateFrame("SLIDER", nil, timerADVOptions, "OptionsSliderTemplate");
autoSellTimerRoundsText.slider1:SetPoint("TOPLEFT", autoSellTimerRoundsText, "BOTTOMLEFT", 0, -17);
autoSellTimerRoundsText.slider1:SetMinMaxValues(1, 20);
autoSellTimerRoundsText.slider1.Low:SetText("1")
autoSellTimerRoundsText.slider1.High:SetText("20")
autoSellTimerRoundsText.slider1:SetValue(5)
autoSellTimerRoundsText.slider1.Text:SetText("5")

autoSellTimerRoundsText.slider1:SetValueStep(1)
autoSellTimerRoundsText.slider1:SetObeyStepOnDrag(true) --fuerza moverse en steps la barrita


local textoSellTimerADV = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontNormal")
textoSellTimerADV:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
textoSellTimerADV:SetText(L["Sell Timer: (seconds)"])
textoSellTimerADV:SetPoint("TOPLEFT", autoSellTimerRoundsText.slider1, "BOTTOMLEFT", 0, -20)

local ebSellBg = CreateFrame ("Frame", nil, timerADVOptions)
ebSellBg:SetSize(editBoxW, editBoxH)
ebSellBg.tex = ebSellBg:CreateTexture()
ebSellBg.tex:SetAllPoints(ebSellBg)
ebSellBg.tex:SetColorTexture(0/255, 2/255, 11/255 , 0.7)
ebSellBg:SetPoint("TOPLEFT", textoSellTimerADV, "BOTTOMLEFT", 0, -5)

local ebSell = CreateFrame("EditBox", nil, timerADVOptions)
ebSell:SetSize(editBoxW, editBoxH)
ebSell:SetMaxLetters(4)
ebSell:SetPoint("CENTER", ebSellBg, "CENTER")
ebSell:SetMultiLine(false)
ebSell:SetAutoFocus(false)
ebSell:SetFontObject("ChatFontNormal")
ebSell:SetText("91")
--eb:HighlightText(0)
ebSell:SetScript("OnEscapePressed",function(self) self:ClearFocus()  end)
ebSell:SetScript("OnEnterPressed",function(self) self:ClearFocus()  validateNumber("sell", self:GetText()) end)

ebSell.bSet = CreateFrame("Button", nil, timerADVOptions, "UIPanelButtonTemplate")
ebSell.bSet:SetPoint("LEFT",ebSellBg,"RIGHT",1,0)
ebSell.bSet:SetSize(30, 18)
ebSell.bSet:SetText("Set")
ebSell.bSet:SetScript("OnClick", function(self, button)
	if(button == "LeftButton") then
        validateNumber("sell", ebSell:GetText())
    end
end)

local textoSellTimerADVresult = timerADVOptions:CreateFontString (nil, "ARTWORK", "GameFontHighlightSmall")
textoSellTimerADVresult:SetFont("Fonts\\FRIZQT__.TTF", 10, "")
textoSellTimerADVresult:SetText(L["Sell Time: "]..ns.Utils.horaBonita(91))
textoSellTimerADVresult:SetPoint("TOPLEFT", ebSell, "BOTTOMLEFT", 0, -3)

local closeButtonADVOptions = CreateFrame("Button", nil, timerADVOptions)
closeButtonADVOptions:SetNormalTexture(130832) --"Interface\\Buttons\\UI-Panel-MinimizeButton-Up"
closeButtonADVOptions:SetPushedTexture(130830) --"Interface\\Buttons\\UI-Panel-MinimizeButton-Down"
closeButtonADVOptions:SetHighlightTexture(130831) --"Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight"
closeButtonADVOptions:SetSize(32, 32)
closeButtonADVOptions:SetPoint("TOPRIGHT", timerADVOptions, "TOPRIGHT", 10,2)
closeButtonADVOptions:SetScript("OnClick", function() ns.toggleTimerADVOptions() end)


local savedFrame = CreateFrame("Frame", nil, timerADVOptions)
local savedFrameW, savedFrameH = 160,390
savedFrame:SetSize(savedFrameW,savedFrameH)
savedFrame.bg = savedFrame:CreateTexture(nil, "BACKGROUND")
savedFrame.bg:SetColorTexture(0/255, 2/255, 11/255 , 0.5)
savedFrame.bg:SetAllPoints(savedFrame)
savedFrame:SetPoint("BOTTOMRIGHT", timerADVOptions, "BOTTOMRIGHT", -5, 10)

local ebSlotInfoBg = CreateFrame ("Frame", nil, timerADVOptions)
ebSlotInfoBg:SetSize(savedFrameW, 30)
ebSlotInfoBg.tex = ebSellBg:CreateTexture(nil, "BACKGROUND")
ebSlotInfoBg.tex:SetAllPoints(ebSlotInfoBg)
ebSlotInfoBg.tex:SetColorTexture(64/255, 64/255, 64/255 , 0.7)
ebSlotInfoBg:SetPoint("BOTTOMLEFT", savedFrame, "BOTTOMLEFT", 0, 30)

local ebSlotInfo = CreateFrame("EditBox", nil, timerADVOptions)
ebSlotInfo:SetSize(savedFrameW-20, 30)
ebSlotInfo:SetMaxLetters(20)
ebSlotInfo:SetPoint("CENTER", ebSlotInfoBg, "CENTER")
ebSlotInfo:SetMultiLine(false)
ebSlotInfo:SetAutoFocus(false)
ebSlotInfo:SetFontObject("ChatFontNormal")
ebSlotInfo:SetText("")
--eb:HighlightText(0)
ebSlotInfo:SetScript("OnEscapePressed",function(self) self:ClearFocus()  end)
ebSlotInfo:SetScript("OnEnterPressed",function() end)

local savedFrameTable = {}
local function unSelectAll()
    for k,v in pairs (savedFrameTable) do
        v:unSelected()
    end
end

function ns.populateTimerADVOptionsInfo()
    checkDMB:SetChecked(AutoScrap_CharSettings.lastTimerconfig.DBMTimer)
    checkCountDown:SetChecked(AutoScrap_CharSettings.lastTimerconfig.countDownTimer)
    eb:SetText(AutoScrap_CharSettings.lastTimerconfig.killTimer)
    ebBreak:SetText(AutoScrap_CharSettings.lastTimerconfig.breakTimer)
    ebSell:SetText(AutoScrap_CharSettings.lastTimerconfig.sellTimer)
    textoKillTimerADVresult:SetText(L["Kill Time: "]..ns.Utils.horaBonita(AutoScrap_CharSettings.lastTimerconfig.killTimer))
    textoBreakTimerADVresult:SetText(L["Break Time: "]..ns.Utils.horaBonita(AutoScrap_CharSettings.lastTimerconfig.breakTimer))
    textoSellTimerADVresult:SetText(L["Sell Time: "]..ns.Utils.horaBonita(AutoScrap_CharSettings.lastTimerconfig.sellTimer))
    checkMultipleRounds:SetChecked(AutoScrap_CharSettings.lastTimerconfig.enableBreak)
    ns.timerFrameRemoveSliders()
    autoSellTimerText.slider1:SetValue(AutoScrap_CharSettings.lastTimerconfig.autoSell)
    autoSellTimerText.slider1.Text:SetText(""..AutoScrap_CharSettings.lastTimerconfig.autoSell.."%")
    autoSellTimerRoundsText.slider1:SetValue(AutoScrap_CharSettings.lastTimerconfig.maxRounds)
    autoSellTimerRoundsText.slider1.Text:SetText(""..AutoScrap_CharSettings.lastTimerconfig.maxRounds)
    ns.timerFrameLoadSliders()
    ns.populateTimerBreakTimeOnMain(AutoScrap_CharSettings.lastTimerconfig.breakTimer)
    ns.updateTimerLocalSetup ()
end
local saveADVOptions
local function crearSlot(parent, w,h, text, left, ancle, right, xOff, yOff, slot)
    local frame = CreateFrame("Frame", nil, parent)
    frame.mySlot = slot
    frame:SetSize(w,h)
    frame.textoGuardado = text
    frame.text = frame:CreateFontString (nil, "ARTWORK", "GameFontHighlight")
    frame.text:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
    frame.text:SetText(frame.textoGuardado)
    frame.text:SetJustifyH("CENTER")
    frame.text:SetPoint("CENTER", frame, "CENTER", 0,0)
    frame.texBG = frame:CreateTexture(nil, "BACKGROUND")
    frame.texBG:SetColorTexture(0/255, 105/255, 107/255 , 0.7)
    frame.texBG:SetAllPoints(frame)
    frame.texBG:Hide()
    local selected = false
    frame:SetPoint(left, ancle, right, xOff, yOff)
    frame:SetScript("OnEnter", function (self)
        self.texBG:Show()
    end)
    frame:SetScript("OnLeave", function (self)
        if not selected then
            self.texBG:Hide()
        end
    end)
    function frame:SetName(name)
        self.textoGuardado = name
        if not selected then
            self.text:SetText(self.textoGuardado)
        else
            self.text:SetText("|cFFf5b041"..self.textoGuardado.."|r")
        end
    end
    function frame:selectedFunc()
        unSelectAll()
        selected = true
        self.text:SetText("|cFFf5b041"..self.textoGuardado.."|r")
        ebSlotInfo:SetText(self.textoGuardado)
        self.texBG:Show()
        saveADVOptions:EnableAgain()
    end
    function frame:unSelected()
        selected = false
        self.text:SetText(self.textoGuardado)
        self.texBG:Hide()
    end
    function frame:getSelected()
        return selected
    end
    frame:SetScript("OnMouseDown", function (self, button)
        if button == "LeftButton" then
            self:selectedFunc()
        end
    end)
    return frame
end

for x = 1, 10 do
    if x == 1 then
        savedFrameTable[x] = crearSlot(timerADVOptions, savedFrameW, 30, "Slot 1", "TOPLEFT", savedFrame, "TOPLEFT", 0 ,0 , 1)
    else
        savedFrameTable[x] = crearSlot(timerADVOptions, savedFrameW, 30, "Slot "..x, "TOPLEFT", savedFrameTable[x-1], "BOTTOMLEFT", 0 ,0 ,x)
    end
end

local loadADVOptions = ns.Utils.crearBoton(savedFrame,80,30,L["Load"],function ()
    for x = 1, 10 do
        if savedFrameTable[x]:getSelected() then
            if AutoScrap_CharSettings.timerConfigSlots[x] then
                AutoScrap_CharSettings.lastTimerconfig.DBMTimer = AutoScrap_CharSettings.timerConfigSlots[x].DBMTimer
                AutoScrap_CharSettings.lastTimerconfig.countDownTimer = AutoScrap_CharSettings.timerConfigSlots[x].countDownTimer
                AutoScrap_CharSettings.lastTimerconfig.killTimer = AutoScrap_CharSettings.timerConfigSlots[x].killTimer
                AutoScrap_CharSettings.lastTimerconfig.enableBreak = AutoScrap_CharSettings.timerConfigSlots[x].enableBreak
                AutoScrap_CharSettings.lastTimerconfig.breakTimer = AutoScrap_CharSettings.timerConfigSlots[x].breakTimer
                AutoScrap_CharSettings.lastTimerconfig.autoSell = AutoScrap_CharSettings.timerConfigSlots[x].autoSell
                AutoScrap_CharSettings.lastTimerconfig.maxRounds = AutoScrap_CharSettings.timerConfigSlots[x].maxRounds
                AutoScrap_CharSettings.lastTimerconfig.sellTimer = AutoScrap_CharSettings.timerConfigSlots[x].sellTimer
                ns.populateTimerADVOptionsInfo()
                break
            end
        end
    end
end)
loadADVOptions:SetPoint("BOTTOMLEFT", savedFrame, "BOTTOMLEFT",  -1,0)
saveADVOptions = ns.Utils.crearBoton(savedFrame,80,30,"Save",function ()
    for x = 1, 10 do
        if savedFrameTable[x]:getSelected() then
            local thename = ebSlotInfo:GetText()
            if thename == "" then
                thename = "Slot "..x
            end
            if not AutoScrap_CharSettings.timerConfigSlots[x] then
                AutoScrap_CharSettings.timerConfigSlots[x] = {}
            end
            AutoScrap_CharSettings.timerConfigSlots[x].name = thename
            AutoScrap_CharSettings.timerConfigSlots[x].DBMTimer = AutoScrap_CharSettings.lastTimerconfig.DBMTimer
            AutoScrap_CharSettings.timerConfigSlots[x].countDownTimer = AutoScrap_CharSettings.lastTimerconfig.countDownTimer
            AutoScrap_CharSettings.timerConfigSlots[x].killTimer = AutoScrap_CharSettings.lastTimerconfig.killTimer
            AutoScrap_CharSettings.timerConfigSlots[x].enableBreak = AutoScrap_CharSettings.lastTimerconfig.enableBreak
            AutoScrap_CharSettings.timerConfigSlots[x].breakTimer = AutoScrap_CharSettings.lastTimerconfig.breakTimer
            AutoScrap_CharSettings.timerConfigSlots[x].autoSell = AutoScrap_CharSettings.lastTimerconfig.autoSell
            AutoScrap_CharSettings.timerConfigSlots[x].maxRounds = AutoScrap_CharSettings.lastTimerconfig.maxRounds
            AutoScrap_CharSettings.timerConfigSlots[x].sellTimer = AutoScrap_CharSettings.lastTimerconfig.sellTimer
            savedFrameTable[x]:SetName(thename)
            break
        end
    end
end)
saveADVOptions:SetPoint("LEFT", loadADVOptions, "RIGHT",  0,0)
saveADVOptions:GrayedOut()

local timerADVoptionsShown = true
function ns.toggleTimerADVOptions()
    if not timerADVoptionsShown then
        timerADVoptionsShown = true
        ns.populateTimerADVOptionsInfo()
        timerADVOptions:Show()
    else
        timerADVoptionsShown = false
        timerADVOptions:Hide()
    end
end
ns.toggleTimerADVOptions()

function ns.timerFrameLoadSliders()
    autoSellTimerText.slider1:SetScript("OnValueChanged", function (self, value)
        AutoScrap_CharSettings.lastTimerconfig.autoSell = value
        ns.populateTimerADVOptionsInfo()
    end)
    autoSellTimerText.slider1:SetScript("OnMouseWheel", function (self, delta) 
        if AutoScrap_CharSettings.lastTimerconfig.autoSell + (delta * self:GetValueStep()) >= 1 and AutoScrap_CharSettings.lastTimerconfig.autoSell + (delta * self:GetValueStep()) <=100 then
            AutoScrap_CharSettings.lastTimerconfig.autoSell = AutoScrap_CharSettings.lastTimerconfig.autoSell + (delta * self:GetValueStep())
        end
        ns.populateTimerADVOptionsInfo()
    end) 
    autoSellTimerRoundsText.slider1:SetScript("OnValueChanged", function (self, value)
        AutoScrap_CharSettings.lastTimerconfig.maxRounds = value
        ns.populateTimerADVOptionsInfo()
    end)
    autoSellTimerRoundsText.slider1:SetScript("OnMouseWheel", function (self, delta) 
        if AutoScrap_CharSettings.lastTimerconfig.maxRounds + (delta * self:GetValueStep()) >= 1 and AutoScrap_CharSettings.lastTimerconfig.maxRounds + (delta * self:GetValueStep()) <=20 then
            AutoScrap_CharSettings.lastTimerconfig.maxRounds = AutoScrap_CharSettings.lastTimerconfig.maxRounds + (delta * self:GetValueStep())
        end
        ns.populateTimerADVOptionsInfo()
    end)
end

function ns.timerFrameRemoveSliders()
    autoSellTimerText.slider1:SetScript("OnValueChanged", nil)
    autoSellTimerText.slider1:SetScript("OnMouseWheel", nil)
    autoSellTimerRoundsText.slider1:SetScript("OnValueChanged", nil)
    autoSellTimerRoundsText.slider1:SetScript("OnMouseWheel", nil)
end


function ns.selectSlotNumber(number)
    savedFrameTable[number]:selectedFunc()
end

function ns.timerADVOoptionesUpdateList()
    for k,v in pairs(AutoScrap_CharSettings.timerConfigSlots)do
        savedFrameTable[k]:SetName(v.name)
    end
    ns.populateTimerADVOptionsInfo()
end
--ns.selectSlotNumber(3)