Quantcast

I heard you like options...

Darth Predator [09-17-17 - 11:49]
I heard you like options...
Filename
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/modules/nameplates.lua
ElvUI_SLE/options/nameplates_c.lua
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index e10a104..f83c4aa 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -557,8 +557,18 @@ P["sle"] = {
 	},
 	--Nameplate Options
 	["nameplates"] = {
-		["showthreat"] = false,
-		["targetcount"] = false,
+		["threat"] = {
+			["enable"] = false,
+			["font"] = "PT Sans Narrow",
+			["fontOutline"] = "OUTLINE",
+			["size"] = 12,
+		},
+		["targetcount"] = {
+			["enable"] = false,
+			["font"] = "PT Sans Narrow",
+			["fontOutline"] = "OUTLINE",
+			["size"] = 12,
+		},
 		["visibleRange"] = 60,
 	},
 	--Order Halls
diff --git a/ElvUI_SLE/modules/nameplates.lua b/ElvUI_SLE/modules/nameplates.lua
index efbdbd4..49281be 100644
--- a/ElvUI_SLE/modules/nameplates.lua
+++ b/ElvUI_SLE/modules/nameplates.lua
@@ -12,7 +12,25 @@ end

 N.GroupMembers = {}

-hooksecurefunc(NP, 'NAME_PLATE_CREATED', function(self, event, frame)
+function N:UpdateFonts(plate)
+	if not plate then return end
+
+	if plate.targetcount then
+		plate.targetcount:FontTemplate(E.LSM:Fetch("font", N.db.targetcount.font), N.db.targetcount.size, N.db.targetcount.fontOutline)
+	end
+	if plate.threatInfo then
+		plate.threatInfo:FontTemplate(E.LSM:Fetch("font", N.db.threat.font), N.db.threat.size, N.db.threat.fontOutline)
+	end
+end
+
+function N:UpdatePlateFonts()
+	self:ForEachPlate("UpdateFonts")
+	if self.PlayerFrame__ then
+		self:UpdateFonts(self.PlayerFrame__.unitFrame)
+	end
+end
+
+function N:CreateNameplate(event, frame)
 	local myPlate = frame.unitFrame
 	if not myPlate then return end

@@ -27,10 +45,10 @@ hooksecurefunc(NP, 'NAME_PLATE_CREATED', function(self, event, frame)
 		myPlate.targetcount:SetJustifyH("RIGHT")
 		myPlate.targetCount = 0
 	end
-	myPlate.threatInfo:FontTemplate(E.LSM:Fetch("font", NP.db.font), NP.db.fontSize, NP.db.fontOutline)
-	myPlate.targetcount:FontTemplate(E.LSM:Fetch("font", NP.db.font), NP.db.fontSize, NP.db.fontOutline)
+	myPlate.threatInfo:FontTemplate(E.LSM:Fetch("font", N.db.threat.font), N.db.threat.size, N.db.threat.fontOutline)
+	myPlate.targetcount:FontTemplate(E.LSM:Fetch("font", N.db.targetcount.font), N.db.targetcount.size, N.db.targetcount.fontOutline)
 	myPlate.targetcount:SetText()
-end)
+end

 hooksecurefunc(NP, 'Update_ThreatList', function(self, myPlate)
 	if not myPlate then return end
@@ -38,7 +56,7 @@ hooksecurefunc(NP, 'Update_ThreatList', function(self, myPlate)
 	if myPlate.threatInfo then
 		myPlate.threatInfo:SetText()

-		if E.db.sle.nameplates.showthreat and myPlate.UnitType == "ENEMY_NPC" then
+		if E.db.sle.nameplates.threat.enable and myPlate.UnitType == "ENEMY_NPC" then
 			local unit = myPlate.unit
 			if not unit then
 				for i=1, 4 do
@@ -67,7 +85,7 @@ function N:UpdateCount(event,unit,force)
 			local plate = frame.unitFrame
 			plate.targetcount:SetText("")
 			plate.targetCount = 0
-			if N.db.targetcount and plate.targetcount then
+			if N.db.targetcount.enable and plate.targetcount then
 				if T.IsInRaid() or T.IsInGroup() then
 					for name, unitid in T.pairs(N.GroupMembers) do
 						if not T.UnitIsUnit(unitid,"player") and plate.unit then
@@ -76,6 +94,7 @@ function N:UpdateCount(event,unit,force)
 							if plate.guid and T.UnitExists(target) then
 								if T.UnitGUID(target) == plate.guid then plate.targetCount = plate.targetCount + 1 end
 							end
+
 							if not (plate.targetCount == 0) then
 								plate.targetcount:SetText(T.format('[%d]', plate.targetCount))
 							end
@@ -117,22 +136,49 @@ end

 function N:NAME_PLATE_UNIT_ADDED(event, unit, frame)
 	local frame = frame or NP:GetNamePlateForUnit(unit);
+
 	N:UpdateCount(nil,"player", true)
 end

 function N:NAME_PLATE_UNIT_REMOVED(event, unit, frame, ...)
 	local frame = frame or NP:GetNamePlateForUnit(unit);
 	if not frame.unitFrame then return end
-	frame.unitFrame.unit = nil
 	frame.unitFrame.threatInfo:SetText("")
 	frame.unitFrame.targetcount:SetText("")
 	frame.unitFrame.targetCount = 0
 end

+function N:UpdateAllFrame(frame)
+	if(frame == self.PlayerFrame__) then return end
+
+	local unit = frame.unit
+	N:NAME_PLATE_UNIT_REMOVED("NAME_PLATE_UNIT_REMOVED", unit)
+	N:NAME_PLATE_UNIT_ADDED("NAME_PLATE_UNIT_ADDED", unit)
+end
+
 function N:Initialize()
 	if not SLE.initialized or not E.private.nameplates.enable then return end
-	if E.db.sle.nameplate then E.db.sle.nameplates = E.db.sle.nameplate; E.db.sle.nameplate = nil end --DB converts
+	--DB converts
+	if E.db.sle.nameplates.targetcount and T.type(E.db.sle.nameplates.targetcount) == "boolean" then
+		local oldEnable = E.db.sle.nameplates.targetcount
+		E.db.sle.nameplates.targetcount = {
+			["enable"] = oldEnable,
+			["font"] = "PT Sans Narrow",
+			["size"] = 12,
+			["fontOutline"] = "OUTLINE",
+		}
+	end
+	if E.db.sle.nameplates.showthreat then
+		E.db.sle.nameplates.threat.enable = E.db.sle.nameplates.showthreat
+		E.db.sle.nameplates.showthreat = nil
+	end
+
 	N.db = E.db.sle.nameplates
+
+	hooksecurefunc(NP, 'NAME_PLATE_CREATED', N.CreateNameplate)
+	hooksecurefunc(NP, "UpdateFonts", N.UpdateFonts)
+	hooksecurefunc(NP, "UpdateAllFrame", N.UpdateAllFrame)
+
 	self:RegisterEvent("GROUP_ROSTER_UPDATE", "StartRosterUpdate")
 	self:RegisterEvent("UNIT_TARGET", "UpdateCount")
 	self:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
diff --git a/ElvUI_SLE/options/nameplates_c.lua b/ElvUI_SLE/options/nameplates_c.lua
index e67ee6e..ba22802 100644
--- a/ElvUI_SLE/options/nameplates_c.lua
+++ b/ElvUI_SLE/options/nameplates_c.lua
@@ -1,4 +1,5 @@
 local SLE, T, E, L, V, P, G = unpack(select(2, ...))
+local NP = E:GetModule('NamePlates')

 local function configTable()
 	if not SLE.initialized then return end
@@ -7,8 +8,8 @@ local function configTable()
 		name = L["NamePlates"],
 		order = 14,
 		disabled = function() return not E.private.nameplates.enable end,
-		get = function(info) return E.db.sle.nameplates[ info[#info] ] end,
-		set = function(info, value) E.db.sle.nameplates[ info[#info] ] = value; E:GetModule('NamePlates'):ConfigureAll() end,
+		-- get = function(info) return E.db.sle.nameplates[ info[#info] ] end,
+		-- set = function(info, value) E.db.sle.nameplates[ info[#info] ] = value; E:GetModule('NamePlates'):ConfigureAll() end,
 		args = {
 			header = {
 				order = 1,
@@ -16,16 +17,97 @@ local function configTable()
 				name = L["NamePlates"],
 			},
 			targetcount = {
-				type = "toggle",
+				type = "group",
 				order = 2,
 				name = L["Target Count"],
-				desc = L["Display the number of party / raid members targetting the nameplate unit."],
+				guiInline = true,
+				args = {
+					enable = {
+						type = "toggle",
+						order = 1,
+						name = L["Enable"],
+						desc = L["Display the number of party / raid members targetting the nameplate unit."],
+						get = function(info) return E.db.sle.nameplates.targetcount[ info[#info] ] end,
+						-- set = function(info, value) E.db.sle.nameplates.targetcount[ info[#info] ] = value; NP:ConfigureAll() end,
+						set = function(info, value) E.db.sle.nameplates.targetcount[ info[#info] ] = value; NP:ConfigureAll() end,
+					},
+					font = {
+						type = "select", dialogControl = 'LSM30_Font',
+						order = 4,
+						name = L["Font"],
+						values = AceGUIWidgetLSMlists.font,
+						get = function(info) return E.db.sle.nameplates.targetcount[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.targetcount[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+					size = {
+						order = 5,
+						name = FONT_SIZE,
+						type = "range",
+						min = 4, max = 25, step = 1,
+						get = function(info) return E.db.sle.nameplates.targetcount[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.targetcount[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+					fontOutline = {
+						order = 6,
+						name = L["Font Outline"],
+						desc = L["Set the font outline."],
+						type = "select",
+						values = {
+							['NONE'] = NONE,
+							['OUTLINE'] = 'OUTLINE',
+							['MONOCHROMEOUTLINE'] = 'MONOCROMEOUTLINE',
+							['THICKOUTLINE'] = 'THICKOUTLINE',
+						},
+						get = function(info) return E.db.sle.nameplates.targetcount[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.targetcount[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+				},
 			},
-			showthreat = {
-				type = "toggle",
+			threat = {
+				type = "group",
 				order = 3,
 				name = L["Threat Text"],
-				desc = L["Display threat level as text on targeted, boss or mouseover nameplate."],
+				guiInline = true,
+				args = {
+					enable = {
+						type = "toggle",
+						order = 1,
+						name = L["Enable"],
+						desc = L["Display threat level as text on targeted, boss or mouseover nameplate."],
+						get = function(info) return E.db.sle.nameplates.threat[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.threat[ info[#info] ] = value; NP:ConfigureAll() end,
+					},
+					font = {
+						type = "select", dialogControl = 'LSM30_Font',
+						order = 4,
+						name = L["Font"],
+						values = AceGUIWidgetLSMlists.font,
+						get = function(info) return E.db.sle.nameplates.threat[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.threat[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+					size = {
+						order = 5,
+						name = FONT_SIZE,
+						type = "range",
+						min = 4, max = 25, step = 1,
+						get = function(info) return E.db.sle.nameplates.threat[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.threat[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+					fontOutline = {
+						order = 6,
+						name = L["Font Outline"],
+						desc = L["Set the font outline."],
+						type = "select",
+						values = {
+							['NONE'] = NONE,
+							['OUTLINE'] = 'OUTLINE',
+							['MONOCHROMEOUTLINE'] = 'MONOCROMEOUTLINE',
+							['THICKOUTLINE'] = 'THICKOUTLINE',
+						},
+						get = function(info) return E.db.sle.nameplates.threat[ info[#info] ] end,
+						set = function(info, value) E.db.sle.nameplates.threat[ info[#info] ] = value; NP:UpdatePlateFonts() end,
+					},
+				},
 			},
 		},
 	}