Skip to content

Commit 51d894e

Browse files
committed
PVP: add class color to flag carrier
1 parent 6ff9a18 commit 51d894e

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

DBM-PvP/PvPGeneral.lua

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local L = mod:GetLocalizedStrings()
44
local DBM = DBM
55
local AceTimer = LibStub("AceTimer-3.0")
66

7-
mod:SetRevision("20220827002800")
7+
mod:SetRevision("20240910182741")
88
mod:SetZone(DBM_DISABLE_ZONE_DETECTION)
99

1010
mod:RegisterEvents(
@@ -237,13 +237,36 @@ local function HideFlagDisplay()
237237
end
238238
end
239239

240+
local function colorizeFlagName(name)
241+
-- if not mod.Options.ColorByClass then return name end
242+
local classUpper
243+
for i = 1, GetNumBattlefieldScores() do
244+
local nameScoreboard, _, _, _, _, _, _, _, _, classToken = GetBattlefieldScore(i)
245+
local noRealmName = strsplit("-", nameScoreboard) -- remove realm name, since Flag msg events never contain realm name
246+
if noRealmName == name then
247+
classUpper = classToken
248+
break
249+
end
250+
end
251+
if classUpper then
252+
if CUSTOM_CLASS_COLORS then
253+
local classTextColor = CUSTOM_CLASS_COLORS[classUpper]
254+
local hexClassColor = format("ff%02X%02X%02X", 255 * classTextColor.r, 255 * classTextColor.g, 255 * classTextColor.b)
255+
name = format("|c%s%s|r", hexClassColor, name)
256+
else
257+
name = format("|c%s%s|r", RAID_CLASS_COLORS[classUpper].colorStr, name)
258+
end
259+
end
260+
return name
261+
end
262+
240263
local function UpdateFlagDisplay()
241264
if flagFrame1Text and flagFrame2Text then
242265
if allyFlag then
243266
if GetCurrentMapAreaID() == 483 then -- EotS
244-
flagFrame1Text:SetText(L.Flag..": "..allyFlag)
267+
flagFrame1Text:SetText(L.Flag..": "..colorizeFlagName(allyFlag))
245268
else
246-
flagFrame1Text:SetText(allyFlag)
269+
flagFrame1Text:SetText(colorizeFlagName(allyFlag))
247270
end
248271
flagButton1:SetAttribute("macrotext", "/targetexact "..allyFlag)
249272
else
@@ -253,9 +276,9 @@ local function UpdateFlagDisplay()
253276

254277
if hordeFlag then
255278
if GetCurrentMapAreaID() == 483 then -- EotS
256-
flagFrame2Text:SetText(L.Flag..": "..hordeFlag)
279+
flagFrame2Text:SetText(L.Flag..": "..colorizeFlagName(hordeFlag))
257280
else
258-
flagFrame2Text:SetText(hordeFlag)
281+
flagFrame2Text:SetText(colorizeFlagName(hordeFlag))
259282
end
260283
flagButton2:SetAttribute("macrotext", "/targetexact "..hordeFlag)
261284
else

0 commit comments

Comments
 (0)