Quantcast

backgrounds

Darthpred [06-27-14 - 22:02]
backgrounds
Filename
ElvUI_SLE/modules/backgrounds/backgrounds.lua
ElvUI_SLE/modules/backgrounds/options.lua
diff --git a/ElvUI_SLE/modules/backgrounds/backgrounds.lua b/ElvUI_SLE/modules/backgrounds/backgrounds.lua
index e159367..405970b 100755
--- a/ElvUI_SLE/modules/backgrounds/backgrounds.lua
+++ b/ElvUI_SLE/modules/backgrounds/backgrounds.lua
@@ -1,20 +1,34 @@
 local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
-local BG = E:NewModule('BackGrounds', 'AceHook-3.0', 'AceEvent-3.0');
+local BG = E:NewModule('SLE_BackGrounds', 'AceHook-3.0', 'AceEvent-3.0');

-local BGb = CreateFrame('Frame', "BottomBG", E.UIParent);
+local BGb, BGl, BGr, BGa, Fr
+
+--[[local BGb = CreateFrame('Frame', "BottomBG", E.UIParent);
 local BGl = CreateFrame('Frame', "LeftBG", E.UIParent);
 local BGr = CreateFrame('Frame', "RightBG", E.UIParent);
-local BGa = CreateFrame('Frame', "ActionBG", E.UIParent);
+local BGa = CreateFrame('Frame', "ActionBG", E.UIParent);]]

-local Fr = {
+--[[local Fr = {
 	BottomBG = {BGb,"bottom"},
 	LeftBG = {BGl,"left"},
 	RightBG = {BGr,"right"},
 	ActionBG = {BGa,"action"},
-}
+}]]

 --Frames setup
 function BG:FramesCreate()
+	BGb = CreateFrame('Frame', "BottomBG", E.UIParent);
+	BGl = CreateFrame('Frame', "LeftBG", E.UIParent);
+	BGr = CreateFrame('Frame', "RightBG", E.UIParent);
+	BGa = CreateFrame('Frame', "ActionBG", E.UIParent);
+
+	Fr = {
+		BottomBG = {BGb,"bottom"},
+		LeftBG = {BGl,"left"},
+		RightBG = {BGr,"right"},
+		ActionBG = {BGa,"action"},
+	}
+
 	for _,v in pairs(Fr) do
 		v[1]:SetFrameLevel(v[1]:GetFrameLevel() - 1)
 		v[1]:SetScript("OnShow", function() v[1]:SetFrameStrata('BACKGROUND') end)
@@ -36,6 +50,7 @@ end

 --Frames Size
 function BG:FramesSize()
+	if not BGb then return end
 	local db = E.db.sle.backgrounds
 	for _,v in pairs(Fr) do
 		v[1]:SetSize(db[v[2]].width, db[v[2]].height)
@@ -44,6 +59,7 @@ end

 --Frames points
 function BG:FramesPositions()
+	if not BGb then return end
 	BGb:Point("BOTTOM", E.UIParent, "BOTTOM", 0, 21);
 	BGl:Point("BOTTOMRIGHT", E.UIParent, "BOTTOM", -(E.screenwidth/4 + 32)/2 - 1, 21);
 	BGr:Point("BOTTOMLEFT", E.UIParent, "BOTTOM", (E.screenwidth/4 + 32)/2 + 1, 21);
@@ -52,6 +68,7 @@ end

 --Updating textures
 function BG:UpdateTex()
+	if not BGb then return end
 	local db = E.db.sle.backgrounds
 	for _,v in pairs(Fr) do
 		v[1].tex:Point('TOPLEFT', v[1], 'TOPLEFT', 2, -2)
@@ -62,6 +79,7 @@ end

 --Visibility / Enable check
 function BG:FramesVisibility()
+	if not BGb then return end
 	local db = E.db.sle.backgrounds
 	for _,v in pairs(Fr) do
 		if db[v[2]].enabled then
@@ -73,6 +91,7 @@ function BG:FramesVisibility()
 end

 function BG:UpdateFrames()
+	if not BGb then return end
 	local db = E.db.sle.backgrounds
 	for _,v in pairs(Fr) do
 				v[1]:SetTemplate(db[v[2]].template, true)
@@ -83,6 +102,7 @@ function BG:UpdateFrames()
 end

 function BG:RegisterHide()
+	if not BGb then return end
 	local db = E.db.sle.backgrounds
 	for k,v in pairs(Fr) do
 		if db[v[2]].pethide then
@@ -94,6 +114,7 @@ function BG:RegisterHide()
 end

 function BG:Initialize()
+	if not E.private.sle.backgrounds then return end
 	BG:FramesCreate()
 	BG:FramesPositions()
 	BG:UpdateFrames()
diff --git a/ElvUI_SLE/modules/backgrounds/options.lua b/ElvUI_SLE/modules/backgrounds/options.lua
index e79896c..421bf9b 100755
--- a/ElvUI_SLE/modules/backgrounds/options.lua
+++ b/ElvUI_SLE/modules/backgrounds/options.lua
@@ -1,5 +1,5 @@
 local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
-local BG = E:GetModule('BackGrounds')
+local BG = E:GetModule('SLE_BackGrounds')
 local function configTable()
 local drop = {
 	--Group name = {short name, order}
@@ -25,52 +25,65 @@ E.Options.args.sle.args.datatext.args.backgrounds = {
 			type = "description",
 			name = L["BG_DESC"]
 		},
-		Reset = {
+		enabled = {
 			order = 3,
+			type = "toggle",
+			name = L["Enable"],
+			desc = L["Show/Hide this frame."],
+			get = function(info) return E.private.sle.backgrounds end,
+			set = function(info, value) E.private.sle.backgrounds = value; E:StaticPopup_Show("PRIVATE_RL") end
+		},
+		Reset = {
+			order = 4,
 			type = 'execute',
 			name = L['Restore Defaults'],
 			desc = L["Reset these options to defaults"],
+			disabled = function() return not E.private.sle.backgrounds end,
 			func = function() E:GetModule('SLE'):Reset(nil, nil, nil, true) end,
 		},
 		spacerreset = {
-			order = 4,
+			order = 5,
 			type = 'description',
 			name = "",
 		},
 		bottom_enabled = {
-			order = 5,
+			order = 6,
 			type = "toggle",
 			name = L["Bottom BG"],
 			desc = L["Show/Hide this frame."],
+			disabled = function() return not E.private.sle.backgrounds end,
 			get = function(info) return E.db.sle.backgrounds.bottom.enabled end,
 			set = function(info, value) E.db.sle.backgrounds.bottom.enabled = value; BG:FramesVisibility() end
 		},
 		left_enabled = {
-			order = 6,
+			order = 7,
 			type = "toggle",
 			name = L["Left BG"],
 			desc = L["Show/Hide this frame."],
+			disabled = function() return not E.private.sle.backgrounds end,
 			get = function(info) return E.db.sle.backgrounds.left.enabled end,
 			set = function(info, value) E.db.sle.backgrounds.left.enabled = value; BG:FramesVisibility() end
 		},
 		spacer = {
-			order = 7,
+			order = 8,
 			type = "description",
 			name = "",
 		},
 		right_enabled = {
-			order = 8,
+			order = 9,
 			type = "toggle",
 			name = L["Right BG"],
 			desc = L["Show/Hide this frame."],
+			disabled = function() return not E.private.sle.backgrounds end,
 			get = function(info) return E.db.sle.backgrounds.right.enabled end,
 			set = function(info, value) E.db.sle.backgrounds.right.enabled = value; BG:FramesVisibility() end
 		},
 		action_enabled = {
-			order = 9,
+			order = 10,
 			type = "toggle",
 			name = L["Actionbar BG"],
 			desc = L["Show/Hide this frame."],
+			disabled = function() return not E.private.sle.backgrounds end,
 			get = function(info) return E.db.sle.backgrounds.action.enabled end,
 			set = function(info, value) E.db.sle.backgrounds.action.enabled = value; BG:FramesVisibility() end
 		},
@@ -84,7 +97,7 @@ for k,v in pairs(drop) do
 		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,
+		disabled = function() return not E.db.sle.backgrounds[v[1]].enabled or not E.private.sle.backgrounds end,
 		args = {
 			width = { --setting width (obviously)
 				order = 1,