From edb7098a830f28601bbc90717bba14128edf5591 Mon Sep 17 00:00:00 2001 From: Darthpred Date: Sat, 23 Jul 2016 13:29:07 +0300 Subject: [PATCH] UI Buttons now have advanced options --- ElvUI_SLE/defaults/private.lua | 6 +- .../LibElv-UIButtons-1.0/LibElv-UIButtons-1.0.lua | 4 +- ElvUI_SLE/modules/uibuttons.lua | 10 ++- ElvUI_SLE/options/uibuttons_c.lua | 75 ++++++++++++++------ 4 files changed, 69 insertions(+), 26 deletions(-) diff --git a/ElvUI_SLE/defaults/private.lua b/ElvUI_SLE/defaults/private.lua index 9ec31e4..da98016 100644 --- a/ElvUI_SLE/defaults/private.lua +++ b/ElvUI_SLE/defaults/private.lua @@ -162,7 +162,11 @@ V["sle"] = { ["subpages"] = 2, }, }, - ["uiButtonStyle"] = "classic" + ["uibuttons"] = { + ["style"] = "classic", + ["strata"] = "MEDIUM", + ["level"] = 5, + }, } G["sle"] = { diff --git a/ElvUI_SLE/libs/LibElv-UIButtons-1.0/LibElv-UIButtons-1.0.lua b/ElvUI_SLE/libs/LibElv-UIButtons-1.0/LibElv-UIButtons-1.0.lua index 5228759..7b33e3a 100644 --- a/ElvUI_SLE/libs/LibElv-UIButtons-1.0/LibElv-UIButtons-1.0.lua +++ b/ElvUI_SLE/libs/LibElv-UIButtons-1.0/LibElv-UIButtons-1.0.lua @@ -325,7 +325,7 @@ local function ToggleShow(menu) end --Creating of the menu -function lib:CreateFrame(name, db, default, style, styleDefault, strata) +function lib:CreateFrame(name, db, default, style, styleDefault, strata, level) --Checks to prevent a shitload of errors cause of wrong arguments passed if _G[name] then return end if not strata then strata = "MEDIUM" end @@ -337,7 +337,7 @@ function lib:CreateFrame(name, db, default, style, styleDefault, strata) menu.style = style menu:SetFrameStrata(strata) - menu:SetFrameLevel(5) + menu:SetFrameLevel(level or 5) menu:SetClampedToScreen(true) menu:Point("LEFT", E.UIParent, "LEFT", -2, 0); menu:Size(17, 17); --Cause the damn thing doesn't want to show up without default size lol diff --git a/ElvUI_SLE/modules/uibuttons.lua b/ElvUI_SLE/modules/uibuttons.lua index 2f300e2..8467697 100644 --- a/ElvUI_SLE/modules/uibuttons.lua +++ b/ElvUI_SLE/modules/uibuttons.lua @@ -62,7 +62,7 @@ function UB:RollSetup(menu) end function UB:SetupBar(menu) - if E.private.sle.uiButtonStyle == "classic" then + if E.private.sle.uibuttons.style == "classic" then menu:CreateCoreButton("Config", "C", function() E:ToggleConfig() end) menu:CreateCoreButton("Reload", "R", function() ReloadUI() end) menu:CreateCoreButton("MoveUI", "M", function(self) E:ToggleConfigMode() end) @@ -92,7 +92,7 @@ function UB:SetupBar(menu) end function UB:RightClicks(menu) - if E.private.sle.uiButtonStyle == "classic" then return end + if E.private.sle.uibuttons.style == "classic" then return end for i = 1, #menu.ToggleTable do menu.ToggleTable[i]:RegisterForClicks("LeftButtonDown", "RightButtonDown") end @@ -120,7 +120,11 @@ end function UB:Initialize() if not SLE.initialized then return end - UB.Holder = lib:CreateFrame("SLE_UIButtons", E.db.sle.uibuttons, P.sle.uibuttons, E.private.sle.uiButtonStyle, "dropdown") + if E.private.sle.uiButtonStyle then + E.private.sle.uibuttons.style = E.private.sle.uiButtonStyle + E.private.sle.uiButtonStyle = nil + end + UB.Holder = lib:CreateFrame("SLE_UIButtons", E.db.sle.uibuttons, P.sle.uibuttons, E.private.sle.uibuttons.style, "dropdown", E.private.sle.uibuttons.strata, E.private.sle.uibuttons.level) local menu = UB.Holder menu:Point("LEFT", E.UIParent, "LEFT", -2, 0); menu:SetupMover(L["S&L UI Buttons"], "ALL,S&L,S&L MISC") diff --git a/ElvUI_SLE/options/uibuttons_c.lua b/ElvUI_SLE/options/uibuttons_c.lua index a2de675..0022776 100644 --- a/ElvUI_SLE/options/uibuttons_c.lua +++ b/ElvUI_SLE/options/uibuttons_c.lua @@ -13,6 +13,17 @@ local positionValues = { BOTTOM = 'BOTTOM', }; +local stratas = { + ["BACKGROUND"] = "1. Background", + ["LOW"] = "2. Low", + ["MEDIUM"] = "3. Medium", + ["HIGH"] = "4. High", + ["DIALOG"] = "5. Dialog", + ["FULLSCREEN"] = "6. Fullscreen", + ["FULLSCREEN_DIALOG"] = "7. Fullscreen Dialog", + ["TOOLTIP"] = "8. Tooltip", +} + local function configTable() if not SLE.initialized then return end local Bar = UB.Holder @@ -48,16 +59,40 @@ local function configTable() ["dropdown"] = L["Dropdown"], }, disabled = function() return not E.db.sle.uibuttons.enable end, - get = function(info) return E.private.sle.uiButtonStyle end, - set = function(info, value) E.private.sle.uiButtonStyle = value; E:StaticPopup_Show("PRIVATE_RL") end, + get = function(info) return E.private.sle.uibuttons.style end, + set = function(info, value) E.private.sle.uibuttons.style = value; E:StaticPopup_Show("PRIVATE_RL") end, }, - space = { + advanced = { + type = "group", order = 5, + name = L["Advanced Options"], + guiInline = true, + get = function(info) return E.private.sle.uibuttons[ info[#info] ] end, + set = function(info, value) E.private.sle.uibuttons[ info[#info] ] = value; E:StaticPopup_Show("PRIVATE_RL") end, + disabled = function() return not E.db.sle.uibuttons.enable end, + hidden = function() return not E.global.sle.advanced.general end, + args = { + strata = { + order = 1, + name = L["UI Buttons Strata"], + type = "select", + values = stratas, + }, + level = { + order = 2, + type = "range", + name = L["Frame Level"], + min = 1, max = 250, step = 1, + }, + }, + }, + space = { + order = 6, type = 'description', name = "", }, size = { - order = 6, + order = 7, type = "range", name = L["Size"], desc = L["Sets size of buttons"], @@ -67,7 +102,7 @@ local function configTable() set = function(info, value) E.db.sle.uibuttons.size = value; Bar:FrameSize() end, }, spacing = { - order = 7, + order = 8, type = "range", name = L["Button Spacing"], desc = L["The spacing between buttons."], @@ -77,7 +112,7 @@ local function configTable() set = function(info, value) E.db.sle.uibuttons.spacing = value; Bar:FrameSize() end, }, mouse = { - order = 8, + order = 9, type = "toggle", name = L["Mouse Over"], desc = L["Show on mouse over."], @@ -86,7 +121,7 @@ local function configTable() set = function(info, value) E.db.sle.uibuttons.mouse = value; Bar:UpdateMouseOverSetting() end }, menuBackdrop = { - order = 9, + order = 10, type = "toggle", name = L["Backdrop"], disabled = function() return not E.db.sle.uibuttons.enable end, @@ -94,15 +129,15 @@ local function configTable() set = function(info, value) E.db.sle.uibuttons.menuBackdrop = value; Bar:UpdateBackdrop() end }, dropdownBackdrop = { - order = 10, + order = 11, type = "toggle", name = L["Dropdown Backdrop"], - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.dropdownBackdrop end, set = function(info, value) E.db.sle.uibuttons.dropdownBackdrop = value; Bar:FrameSize() end }, orientation = { - order = 11, + order = 12, name = L["Buttons position"], desc = L["Layout for UI buttons."], type = "select", @@ -119,7 +154,7 @@ local function configTable() order = 13, name = L["Anchor Point"], desc = L["What point of dropdown will be attached to the toggle button."], - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.point end, set = function(info, value) E.db.sle.uibuttons.point = value; Bar:FrameSize() end, values = positionValues, @@ -129,7 +164,7 @@ local function configTable() order = 14, name = L["Attach To"], desc = L["What point to anchor dropdown on the toggle button."], - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.anchor end, set = function(info, value) E.db.sle.uibuttons.anchor = value; Bar:FrameSize() end, values = positionValues, @@ -140,7 +175,7 @@ local function configTable() name = L["X-Offset"], desc = L["Horizontal offset of dropdown from the toggle button."], min = -10, max = 10, step = 1, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.xoffset end, set = function(info, value) E.db.sle.uibuttons.xoffset = value; Bar:FrameSize() end, }, @@ -150,7 +185,7 @@ local function configTable() name = L["Y-Offset"], desc = L["Vertical offset of dropdown from the toggle button."], min = -10, max = 10, step = 1, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.yoffset end, set = function(info, value) E.db.sle.uibuttons.yoffset = value; Bar:FrameSize() end, }, @@ -159,7 +194,7 @@ local function configTable() type = 'input', name = L["Minimum Roll Value"], desc = L["The lower limit for custom roll button."], - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.customroll.min end, set = function(info, value) E.db.sle.uibuttons.customroll.min = value; end, }, @@ -168,7 +203,7 @@ local function configTable() type = 'input', name = L["Maximum Roll Value"], desc = L["The higher limit for custom roll button."], - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, get = function(info) return E.db.sle.uibuttons.customroll.max end, set = function(info, value) E.db.sle.uibuttons.customroll.max = value; end, }, @@ -177,7 +212,7 @@ local function configTable() name = "\"C\" "..L["Quick Action"], type = "group", guiInline = true, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, args = { enabled = { order = 1, @@ -208,7 +243,7 @@ local function configTable() name = "\"A\" "..L["Quick Action"], type = "group", guiInline = true, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, args = { enabled = { order = 1, @@ -237,7 +272,7 @@ local function configTable() name = "\"S\" "..L["Quick Action"], type = "group", guiInline = true, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, args = { enabled = { order = 1, @@ -266,7 +301,7 @@ local function configTable() name = "\"R\" "..L["Quick Action"], type = "group", guiInline = true, - disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uiButtonStyle == "classic" end, + disabled = function() return not E.db.sle.uibuttons.enable or E.private.sle.uibuttons.style == "classic" end, args = { enabled = { order = 1, -- 1.7.9.5