Quantcast

Added threat module to adjust location of datatext panel of our choice.

Repooc [08-17-14 - 01:48]
Added threat module to adjust location of datatext panel of our choice.
Filename
ElvUI_SLE/core/modules.lua
ElvUI_SLE/modules/threat.lua
ElvUI_SLE/options/threat_c.lua
diff --git a/ElvUI_SLE/core/modules.lua b/ElvUI_SLE/core/modules.lua
index 45f25bd..cc4f8c2 100644
--- a/ElvUI_SLE/core/modules.lua
+++ b/ElvUI_SLE/core/modules.lua
@@ -16,7 +16,7 @@ local modules = {
 	['SLE_RaidFlares'] = {'AceHook-3.0', 'AceEvent-3.0'},
 	['SLE_RaidMarks'] = {'AceHook-3.0', 'AceEvent-3.0'},
 	['SLE_SquareMinimapButtons'] = {'AceHook-3.0', 'AceEvent-3.0'},
-	['SLE_Threat'] = {'AceHook-3.0'},
+	['SLE_Threat'] = {'AceHook-3.0', 'AceEvent-3.0'},
 	['SLE_PvPMover'] = {'AceHook-3.0', 'AceEvent-3.0'},
 	['SLE_UIButtons'] = {'AceHook-3.0', 'AceEvent-3.0'},
 	['SLE_EnhancedVehicleBar'] = {},
diff --git a/ElvUI_SLE/modules/threat.lua b/ElvUI_SLE/modules/threat.lua
new file mode 100644
index 0000000..abf952b
--- /dev/null
+++ b/ElvUI_SLE/modules/threat.lua
@@ -0,0 +1,35 @@
+local E, L, V, P, G = unpack(ElvUI);
+local SLT = E:GetModule('SLE_Threat');
+local T = E:GetModule('Threat');
+
+function SLT:UpdatePosition()
+	if not E.db.general.threat.enable or not E.db.sle.threat.enable then return end
+
+	T.bar:SetInside(E.db.sle.threat.position)
+	T.bar:SetParent(E.db.sle.threat.position)
+
+	T.bar.text:FontTemplate(nil, E.db.general.threat.textSize)
+	T.bar:SetFrameStrata('MEDIUM')
+	T.bar:SetAlpha(1)
+end
+
+local function LoadConfig(event, addon)
+	if addon ~= "ElvUI_Config" then return end
+
+	SLT:Update()
+	SLT:UnregisterEvent("ADDON_LOADED")
+end
+
+function SLT:Update()
+	if E.db.sle.threat.enable then
+		E.Options.args.general.args.threat.args.position.disabled = function() return true end
+	else
+		E.Options.args.general.args.threat.args.position.disabled = function() return false end
+	end
+end
+
+function SLT:Initialize()
+	hooksecurefunc(T, 'UpdatePosition', SLT.UpdatePosition)
+	SLT:RegisterEvent("ADDON_LOADED", LoadConfig)
+	SLT:UpdatePosition()
+end
\ No newline at end of file
diff --git a/ElvUI_SLE/options/threat_c.lua b/ElvUI_SLE/options/threat_c.lua
new file mode 100644
index 0000000..2857cd2
--- /dev/null
+++ b/ElvUI_SLE/options/threat_c.lua
@@ -0,0 +1,62 @@
+local E, L, V, P, G = unpack(ElvUI);
+local SLT = E:GetModule('SLE_Threat');
+
+local function configTable()
+	E.Options.args.sle.args.options.args.general.args.threat = {
+		type = "group",
+		name = L['Threat'],
+		order = 1,
+		args = {
+			header = {
+				order = 1,
+				type = "header",
+				name = L['Threat'],
+			},
+			intro = {
+				order = 2,
+				type = "description",
+				name = "Some threat changes",
+			},
+			enabled = {
+				order = 3,
+				type = "toggle",
+				name = L["Enable"],
+				--desc = L["Show/Hide UI buttons."],
+				get = function(info) return E.db.sle.threat.enable end,
+				set = function(info, value) E.db.sle.threat.enable = value; SLT:Update(); SLT:UpdatePosition() end,
+			},
+			space1 = {
+				order = 4,
+				type = 'description',
+				name = "",
+			},
+			space2 = {
+				order = 5,
+				type = 'description',
+				name = "",
+			},
+			position = {
+				order = 6,
+				type = 'select',
+				name = L['Position'],
+				desc = L['Adjust the position of the threat bar to any of the datatext panels in ElvUI & S&L.'],
+				values = {
+					['Top_Center'] = "Top Panel",
+					['Bottom_Panel'] = "Bottom Panel",
+					['DP_1'] = "Data Panel 1",
+					['DP_2'] = "Data Panel 2",
+					['DP_3'] = "Data Panel 3",
+					['DP_4'] = "Data Panel 4",
+					['DP_5'] = "Data Panel 5",
+					['DP_6'] = "Data Panel 6",
+					['LeftChatDataPanel'] = L['Left Chat'],
+					['RightChatDataPanel'] = L['Right Chat'],
+				},
+				get = function(info) return E.db.sle.threat.position end,
+				set = function(info, value) E.db.sle.threat.position = value; SLT:UpdatePosition() end,
+			},
+		},
+	}
+end
+
+table.insert(E.SLEConfigs, configTable)
\ No newline at end of file