diff --git a/ElvUI_SLE/modules/backgrounds/options.lua b/ElvUI_SLE/modules/backgrounds/options.lua index d88ba9f..c15e889 100644 --- a/ElvUI_SLE/modules/backgrounds/options.lua +++ b/ElvUI_SLE/modules/backgrounds/options.lua @@ -1,6 +1,14 @@ local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore local BG = E:GetModule('BackGrounds') +local drop = { + --Group name = {short name, order, minimum width} + ["Bottom BG"] = {"bottom", 1, 200}, + ["Left BG"] = {"left", 2, 150}, + ["Right BG"] = {"right", 3, 150}, + ["Actionbar BG"] = {"action", 4, 200}, +} + --Options for additional background frames. Main group E.Options.args.sle.args.backgrounds = { type = "group", @@ -57,319 +65,85 @@ E.Options.args.sle.args.backgrounds = { }, } } ---Subgroup for 1st frame. They are based on the same pattern -E.Options.args.sle.args.backgrounds.args.bottom = { - type = "group", - name = L["Bottom BG"], - order = 1, - get = function(info) return E.db.sle.backgrounds.bottom[ info[#info] ] end, - disabled = function() return not E.db.sle.backgrounds.bottom.enabled end, - args = { - width = { --setting width (obviously) - order = 3, - type = "range", - name = L['Width'], - desc = L["Sets width of the frame"], - min = 200, max = E.screenwidth, step = 1, - set = function(info, value) E.db.sle.backgrounds.bottom.width = value; BG:FramesSize() end, - }, - height = { - order = 4, - type = "range", - name = L['Height'], - desc = L["Sets height of the frame"], - min = 50, max = E.screenheight/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.bottom.height = value; BG:FramesSize() end, - }, - spacer = { --Empty slot for making sliders move to next line - order = 5, - type = "description", - name = "", - }, - --Main means of moving frames. To create actual mover for them is veeeeeeeeeeery crapy idea. - xoffset = { - order = 6, - type = "range", - name = L['X Offset'], - desc = L["Sets X offset of the frame"], - min = -E.screenwidth/2, max = E.screenwidth/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.bottom.xoffset = value; BG:FramesPositions() end, - }, - yoffset = { - order = 7, - type = "range", - name = L['Y Offset'], - desc = L["Sets Y offset of the frame"], - min = -21, max = E.screenheight, step = 1, - set = function(info, value) E.db.sle.backgrounds.bottom.yoffset = value; BG:FramesPositions() end, - }, - --Setting custom texture for those who like it - texture = { - order = 8, - type = 'input', - width = 'full', - name = L["Texture"], - desc = L["Set the texture to use in this frame. Requirements are the same as the chat textures."], - set = function(info, value) - E.db.sle.backgrounds.bottom.texture = value - E:UpdateMedia() - BG:UpdateTex() - end, - }, - template = { - order = 9, - type = "select", - name = L["Backdrop Template"], - desc = L["Change the template used for this backdrop."], - get = function(info) return E.private.sle.backgrounds.bottom.template end, - set = function(info, value) E.private.sle.backgrounds.bottom.template = value; E:StaticPopup_Show("PRIVATE_RL") end, - values = { - ['Default'] = L["Default"], - ['Transparent'] = L["Transparent"], + +--Subgroups +for k,v in pairs(drop) do + E.Options.args.sle.args.backgrounds.args[v[1]] = { + type = "group", + name = L[k], + order = v[2], + get = function(info) return E.db.sle.backgrounds[v[1]][ info[#info] ] end, + disabled = function() return not E.db.sle.backgrounds[v[1]].enabled end, + args = { + width = { --setting width (obviously) + order = 3, + type = "range", + name = L['Width'], + desc = L["Sets width of the frame"], + min = v[3], max = E.screenwidth, step = 1, + set = function(info, value) E.db.sle.backgrounds[v[1]].width = value; BG:FramesSize() end, }, - }, - pethide = { - order = 10, - type = "toggle", - name = L["Hide in Pet Batlle"], - desc = L["Show/Hide this frame during Pet Battles."], - set = function(info, value) E.db.sle.backgrounds.bottom.pethide = value; BG:RegisterHide() end - }, - }, -} ---Subgroup for 2nd frame -E.Options.args.sle.args.backgrounds.args.left = { - order = 2, - type = "group", - name = L["Left BG"], - get = function(info) return E.db.sle.backgrounds.left[ info[#info] ] end, - disabled = function() return not E.db.sle.backgrounds.left.enabled end, - args = { - width = { - order = 3, - type = "range", - name = L['Width'], - desc = L["Sets width of the frame"], - min = 150, max = E.screenwidth, step = 1, - set = function(info, value) E.db.sle.backgrounds.left.width = value; BG:FramesSize() end, - }, - height = { - order = 4, - type = "range", - name = L['Height'], - desc = L["Sets height of the frame"], - min = 50, max = E.screenheight/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.left.height = value; BG:FramesSize() end, - }, - spacer = { - order = 5, - type = "description", - name = "", - }, - xoffset = { - order = 6, - type = "range", - name = L['X Offset'], - desc = L["Sets X offset of the frame"], - min = -E.screenwidth/2, max = E.screenwidth/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.left.xoffset = value; BG:FramesPositions() end, - }, - yoffset = { - order = 7, - type = "range", - name = L['Y Offset'], - desc = L["Sets Y offset of the frame"], - min = -21, max = E.screenheight, step = 1, - set = function(info, value) E.db.sle.backgrounds.left.yoffset = value; BG:FramesPositions() end, - }, - texture = { - order = 8, - type = 'input', - width = 'full', - name = L["Texture"], - desc = L["Set the texture to use in this frame. Requirements are the same as the chat textures."], - set = function(info, value) - E.db.sle.backgrounds.left.texture = value - E:UpdateMedia() - BG:UpdateTex() - end, - }, - template = { - order = 9, - type = "select", - name = L["Backdrop Template"], - desc = L["Change the template used for this backdrop."], - get = function(info) return E.private.sle.backgrounds.left.template end, - set = function(info, value) E.private.sle.backgrounds.left.template = value; E:StaticPopup_Show("PRIVATE_RL") end, - values = { - ['Default'] = L["Default"], - ['Transparent'] = L["Transparent"], + height = { + order = 4, + type = "range", + name = L['Height'], + desc = L["Sets height of the frame"], + min = 50, max = E.screenheight/2, step = 1, + set = function(info, value) E.db.sle.backgrounds[v[1]].height = value; BG:FramesSize() end, }, - }, - pethide = { - order = 10, - type = "toggle", - name = L["Hide in Pet Batlle"], - desc = L["Show/Hide this frame during Pet Battles."], - set = function(info, value) E.db.sle.backgrounds.left.pethide = value; BG:RegisterHide() end - }, - }, -} ---Subgroup for 3rd frame -E.Options.args.sle.args.backgrounds.args.right = { - order = 2, - type = "group", - name = L["Right BG"], - get = function(info) return E.db.sle.backgrounds.right[ info[#info] ] end, - disabled = function() return not E.db.sle.backgrounds.right.enabled end, - args = { - width = { - order = 3, - type = "range", - name = L['Width'], - desc = L["Sets width of the frame"], - min = 150, max = E.screenwidth, step = 1, - set = function(info, value) E.db.sle.backgrounds.right.width = value; BG:FramesSize() end, - }, - height = { - order = 4, - type = "range", - name = L['Height'], - desc = L["Sets height of the frame"], - min = 50, max = E.screenheight/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.right.height = value; BG:FramesSize() end, - }, - spacer = { - order = 5, - type = "description", - name = "", - }, - xoffset = { - order = 6, - type = "range", - name = L['X Offset'], - desc = L["Sets X offset of the frame"], - min = -E.screenwidth/2, max = E.screenwidth/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.right.xoffset = value; BG:FramesPositions() end, - }, - yoffset = { - order = 7, - type = "range", - name = L['Y Offset'], - desc = L["Sets Y offset of the frame"], - min = -21, max = E.screenheight, step = 1, - set = function(info, value) E.db.sle.backgrounds.right.yoffset = value; BG:FramesPositions() end, - }, - texture = { - order = 8, - type = 'input', - width = 'full', - name = L["Texture"], - desc = L["Set the texture to use in this frame. Requirements are the same as the chat textures."], - set = function(info, value) - E.db.sle.backgrounds.right.texture = value - E:UpdateMedia() - BG:UpdateTex() - end, - }, - template = { - order = 9, - type = "select", - name = L["Backdrop Template"], - desc = L["Change the template used for this backdrop."], - get = function(info) return E.private.sle.backgrounds.right.template end, - set = function(info, value) E.private.sle.backgrounds.right.template = value; E:StaticPopup_Show("PRIVATE_RL") end, - values = { - ['Default'] = L["Default"], - ['Transparent'] = L["Transparent"], + spacer = { --Empty slot for making sliders move to next line + order = 5, + type = "description", + name = "", }, - }, - pethide = { - order = 10, - type = "toggle", - name = L["Hide in Pet Batlle"], - desc = L["Show/Hide this frame during Pet Battles."], - set = function(info, value) E.db.sle.backgrounds.right.pethide = value; BG:RegisterHide() end - }, - }, -} ---Subgroup for 4th frame -E.Options.args.sle.args.backgrounds.args.action = { - order = 4, - type = "group", - name = L["Actionbar BG"], - get = function(info) return E.db.sle.backgrounds.action[ info[#info] ] end, - disabled = function() return not E.db.sle.backgrounds.action.enabled end, - args = { - width = { - order = 3, - type = "range", - name = L['Width'], - desc = L["Sets width of the frame"], - min = 200, max = E.screenwidth, step = 1, - set = function(info, value) E.db.sle.backgrounds.action.width = value; BG:FramesSize() end, - }, - height = { - order = 4, - type = "range", - name = L['Height'], - desc = L["Sets height of the frame"], - min = 50, max = E.screenheight/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.action.height = value; BG:FramesSize() end, - }, - spacer = { - order = 5, - type = "description", - name = "", - }, - xoffset = { - order = 6, - type = "range", - name = L['X Offset'], - desc = L["Sets X offset of the frame"], - min = -E.screenwidth/2, max = E.screenwidth/2, step = 1, - set = function(info, value) E.db.sle.backgrounds.action.xoffset = value; BG:FramesPositions() end, - }, - yoffset = { - order = 7, - type = "range", - name = L['Y Offset'], - desc = L["Sets Y offset of the frame"], - min = -21, max = E.screenheight, step = 1, - set = function(info, value) E.db.sle.backgrounds.action.yoffset = value; BG:FramesPositions() end, - }, - texture = { - order = 8, - type = 'input', - width = 'full', - name = L["Texture"], - desc = L["Set the texture to use in this frame. Requirements are the same as the chat textures."], - get = function(info) return E.db.sle.backgrounds.action.texture end, - set = function(info, value) - E.db.sle.backgrounds.action.texture = value - E:UpdateMedia() - BG:UpdateTex() - end, - }, - template = { - order = 9, - type = "select", - name = L["Backdrop Template"], - desc = L["Change the template used for this backdrop."], - get = function(info) return E.private.sle.backgrounds.action.template end, - set = function(info, value) E.private.sle.backgrounds.action.template = value; E:StaticPopup_Show("PRIVATE_RL") end, - values = { - ['Default'] = L["Default"], - ['Transparent'] = L["Transparent"], + xoffset = { + order = 6, + type = "range", + name = L['X Offset'], + desc = L["Sets X offset of the frame"], + min = -E.screenwidth/2, max = E.screenwidth/2, step = 1, + set = function(info, value) E.db.sle.backgrounds[v[1]].xoffset = value; BG:FramesPositions() end, + }, + yoffset = { + order = 7, + type = "range", + name = L['Y Offset'], + desc = L["Sets Y offset of the frame"], + min = -21, max = E.screenheight, step = 1, + set = function(info, value) E.db.sle.backgrounds[v[1]].yoffset = value; BG:FramesPositions() end, + }, + --Setting custom texture for those who like it + texture = { + order = 8, + type = 'input', + width = 'full', + name = L["Texture"], + desc = L["Set the texture to use in this frame. Requirements are the same as the chat textures."], + set = function(info, value) + E.db.sle.backgrounds[v[1]].texture = value + E:UpdateMedia() + BG:UpdateTex() + end, + }, + template = { + order = 9, + type = "select", + name = L["Backdrop Template"], + desc = L["Change the template used for this backdrop."], + get = function(info) return E.private.sle.backgrounds[v[1]].template end, + set = function(info, value) E.private.sle.backgrounds[v[1]].template = value; E:StaticPopup_Show("PRIVATE_RL") end, + values = { + ['Default'] = L["Default"], + ['Transparent'] = L["Transparent"], + }, + }, + pethide = { + order = 10, + type = "toggle", + name = L["Hide in Pet Batlle"], + desc = L["Show/Hide this frame during Pet Battles."], + set = function(info, value) E.db.sle.backgrounds[v[1]].pethide = value; BG:RegisterHide() end }, }, - pethide = { - order = 10, - type = "toggle", - name = L["Hide in Pet Batlle"], - desc = L["Show/Hide this frame during Pet Battles."], - set = function(info, value) E.db.sle.backgrounds.action.pethide = value; BG:RegisterHide() end - }, - }, -} - + } +end