Quantcast

Added an option to display faction icons next to player names.

Xruptor [07-24-18 - 02:04]
Added an option to display faction icons next to player names.
Fixed an issue where the checkmark were being displayed for characters with the same name on multiple realms.
Filename
BagSync.lua
locale/enUS.lua
modules/config.lua
diff --git a/BagSync.lua b/BagSync.lua
index e5e287e..91595fd 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -199,6 +199,7 @@ function BSYC:StartupDB()
 	if self.options.enableRealmAstrickName == nil then self.options.enableRealmAstrickName = false end
 	if self.options.enableRealmShortName == nil then self.options.enableRealmShortName = false end
 	if self.options.enableLoginVersionInfo == nil then self.options.enableLoginVersionInfo = true end
+	if self.options.enableFactionIcons == nil then self.options.enableFactionIcons = true end

 	--setup the default colors
 	if self.options.colors == nil then self.options.colors = {} end
@@ -459,9 +460,10 @@ function BSYC:GetRealmTags(srcName, srcRealm, isGuild)
 	if not isGuild then
 		local ReadyCheck = [[|TInterface\RaidFrame\ReadyCheck-Ready:0|t]]
 		--local NotReadyCheck = [[|TInterface\RaidFrame\ReadyCheck-NotReady:0|t]]
-
-		--put a green check next to the currently logged in character name
-		if srcName == self.currentPlayer and self.options.enableTooltipGreenCheck then
+		--Interface\\TargetingFrame\\UI-PVP-FFA
+
+		--put a green check next to the currently logged in character name, make sure to put it as current realm only.  You can have toons with same name on multiple realms
+		if srcName == self.currentPlayer and srcRealm == self.currentRealm and self.options.enableTooltipGreenCheck then
 			srcName = srcName.." "..ReadyCheck
 		end
 	else
@@ -477,6 +479,19 @@ function BSYC:GetRealmTags(srcName, srcRealm, isGuild)
 		end
 	end

+	--make sure we work with player data not guild data
+	if self.options.enableFactionIcons and self.db.global[srcRealm] and self.db.global[srcRealm][srcName] then
+		local FactionIcon = [[|TInterface\Icons\Achievement_worldevent_brewmaster:18|t]]
+
+		if self.db.global[srcRealm][srcName].faction == "Alliance" then
+			FactionIcon = [[|TInterface\Icons\Inv_misc_tournaments_banner_human:18|t]]
+		elseif self.db.global[srcRealm][srcName].faction == "Horde" then
+			FactionIcon = [[|TInterface\Icons\Inv_misc_tournaments_banner_orc:18|t]]
+		end
+
+		srcName = FactionIcon.." "..srcName
+	end
+
 	--add Cross-Realm and BNet identifiers to Characters not on same realm
 	local crossString = ""
 	local bnetString = ""
@@ -1463,7 +1478,7 @@ function BSYC:OnEnable()
 	self.db.player.class = self.playerClass

 	--save the faction information
-	--"Alliance", "Horde" or nil
+	--"Alliance", "Horde" or nil (Neutral)
 	self.db.player.faction = self.playerFaction

 	--save player Realm for quick access later
diff --git a/locale/enUS.lua b/locale/enUS.lua
index f045235..bb1194a 100644
--- a/locale/enUS.lua
+++ b/locale/enUS.lua
@@ -92,6 +92,7 @@ L.DisplayGreenCheck = "Display %s next to current character name."
 L.DisplayRealmIDTags = "Display |cffff7d0a[XR]|r and |cff3587ff[BNet]|r realm identifiers."
 L.DisplayRealmAstrick = "Display [*] instead of server names for |cffff7d0a[XR]|r and |cff3587ff[BNet]|r."
 L.DisplayShortRealmName = "Display short realm names for |cffff7d0a[XR]|r and |cff3587ff[BNet]|r."
+L.DisplayFactionIcons = "Display faction icons in tooltip."
 L.ColorPrimary = "Primary BagSync tooltip color."
 L.ColorSecondary = "Secondary BagSync tooltip color."
 L.ColorTotal = "BagSync [Total] tooltip color."
diff --git a/modules/config.lua b/modules/config.lua
index edce58d..f284d55 100644
--- a/modules/config.lua
+++ b/modules/config.lua
@@ -6,6 +6,10 @@ local configDialog = LibStub("AceConfigDialog-3.0")
 local options = {}
 local ReadyCheck = [[|TInterface\RaidFrame\ReadyCheck-Ready:0|t]]

+local 	factionString = " ( "..[[|TInterface\Icons\Inv_misc_tournaments_banner_orc:18|t]]
+		factionString = factionString.." "..[[|TInterface\Icons\Inv_misc_tournaments_banner_human:18|t]]
+		factionString = factionString.." "..[[|TInterface\Icons\Achievement_worldevent_brewmaster:18|t]]..")"
+
 options.type = "group"
 options.name = "BagSync"

@@ -327,6 +331,16 @@ options.args.display = {
 			set = set,
 			arg = "display.enableRealmShortName",
 		},
+		factionicon = {
+			order = 16,
+			type = "toggle",
+			name = L.DisplayFactionIcons..factionString,
+			width = "full",
+			descStyle = "hide",
+			get = get,
+			set = set,
+			arg = "display.enableFactionIcons",
+		},
 	},
 }