Quantcast

Some rearrangements in nameplates. WTB testing

Darth Predator [09-25-17 - 14:01]
Some rearrangements in nameplates. WTB testing
Filename
ElvUI_SLE/modules/nameplates.lua
diff --git a/ElvUI_SLE/modules/nameplates.lua b/ElvUI_SLE/modules/nameplates.lua
index 43c74da..ad07986 100644
--- a/ElvUI_SLE/modules/nameplates.lua
+++ b/ElvUI_SLE/modules/nameplates.lua
@@ -2,7 +2,6 @@ local SLE, T, E, L, V, P, G = unpack(select(2, ...))
 local NP = E:GetModule('NamePlates')
 local N = SLE:NewModule("Nameplates", 'AceHook-3.0', 'AceEvent-3.0', 'AceTimer-3.0')
 local rosterTimer
-N.targetCount = 0

 local GetNamePlates = C_NamePlate.GetNamePlates

@@ -30,24 +29,32 @@ function N:UpdatePlateFonts()
 	end
 end

+function N:CreateTargetCounter(plate)
+	plate.targetcount = plate.HealthBar:CreateFontString(nil, "OVERLAY")
+	plate.targetcount:SetPoint('BOTTOMRIGHT', plate.HealthBar, 'BOTTOMRIGHT', 1, 2)
+	plate.targetcount:SetJustifyH("RIGHT")
+	plate.targetCount = 0
+	plate.targetcount:FontTemplate(E.LSM:Fetch("font", N.db.targetcount.font), N.db.targetcount.size, N.db.targetcount.fontOutline)
+	plate.targetcount:SetText()
+end
+
+function N:CreateThreatIndicator(plate)
+	plate.threatInfo = plate.HealthBar:CreateFontString(nil, "OVERLAY")
+	plate.threatInfo:SetPoint("BOTTOMLEFT", plate.HealthBar, "BOTTOMLEFT", 1, 2)
+	plate.threatInfo:SetJustifyH("LEFT")
+	plate.threatInfo:FontTemplate(E.LSM:Fetch("font", N.db.threat.font), N.db.threat.size, N.db.threat.fontOutline)
+end
+
 function N:CreateNameplate(event, frame)
 	local plate = frame.unitFrame
 	if not plate then return end

 	if not plate.threatInfo then
-		plate.threatInfo = plate.HealthBar:CreateFontString(nil, "OVERLAY")
-		plate.threatInfo:SetPoint("BOTTOMLEFT", plate.HealthBar, "BOTTOMLEFT", 1, 2)
-		plate.threatInfo:SetJustifyH("LEFT")
+		N:CreateThreatIndicator(plate)
 	end
 	if not plate.targetcount then
-		plate.targetcount = plate.HealthBar:CreateFontString(nil, "OVERLAY")
-		plate.targetcount:SetPoint('BOTTOMRIGHT', plate.HealthBar, 'BOTTOMRIGHT', 1, 2)
-		plate.targetcount:SetJustifyH("RIGHT")
-		plate.targetCount = 0
+		N:CreateTargetCounter(plate)
 	end
-	plate.threatInfo:FontTemplate(E.LSM:Fetch("font", N.db.threat.font), N.db.threat.size, N.db.threat.fontOutline)
-	plate.targetcount:FontTemplate(E.LSM:Fetch("font", N.db.targetcount.font), N.db.targetcount.size, N.db.targetcount.fontOutline)
-	plate.targetcount:SetText()
 end

 hooksecurefunc(NP, 'Update_ThreatList', function(self, myPlate)
@@ -94,10 +101,6 @@ 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
 						end
 					end
 				end
@@ -105,11 +108,9 @@ function N:UpdateCount(event,unit,force)
 					plate.guid = T.UnitGUID(plate.unit)
 					if plate.guid and T.UnitExists("target") then
 						if T.UnitGUID("target") == plate.guid then plate.targetCount = plate.targetCount + 1 end
-						if not (plate.targetCount == 0) then
-							plate.targetcount:SetText(T.format('[%d]', plate.targetCount))
-						end
 					end
 				end
+				if not (plate.targetCount == 0) then plate.targetcount:SetText(T.format('[%d]', plate.targetCount))	end
 			end
 		end
 	end
@@ -117,9 +118,7 @@ end

 local function AddToRoster(unitId)
 	local unitName = T.UnitName(unitId)
-	if unitName then
-		N.GroupMembers[unitName] = unitId
-	end
+	if unitName then N.GroupMembers[unitName] = unitId end
 end

 function N:UpdateRoster()
@@ -128,13 +127,9 @@ function N:UpdateRoster()
 	local groupSize = T.IsInRaid() and T.GetNumGroupMembers() or T.IsInGroup() and T.GetNumSubgroupMembers() or 0
 	local groupType = T.IsInRaid() and "raid" or T.IsInGroup() and "party" or "solo"

-	for index = 1, groupSize do
-		AddToRoster(groupType..index)
-	end
+	for index = 1, groupSize do AddToRoster(groupType..index) end

-	if groupType == 'party' then
-		AddToRoster('player')
-	end
+	if groupType == 'party' then AddToRoster('player') end
 end

 function N:StartRosterUpdate()
@@ -151,10 +146,13 @@ end

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

 function N:UpdateAllFrame(frame)