Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions DBM-PvP/PvPGeneral.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local L = mod:GetLocalizedStrings()
local DBM = DBM
local AceTimer = LibStub("AceTimer-3.0")

mod:SetRevision("20220827002800")
mod:SetRevision("20240911213453")
mod:SetZone(DBM_DISABLE_ZONE_DETECTION)

mod:RegisterEvents(
Expand Down Expand Up @@ -109,7 +109,7 @@ end)

local CreateFrame, GetCurrentMapAreaID = CreateFrame, GetCurrentMapAreaID
local scoreFrame1, scoreFrame2, scoreFrameToWin, scoreFrame1Text, scoreFrame2Text, scoreFrameToWinText, flagFrame1, flagButton1, flagFrame2, flagButton2, flagFrame1Text, flagFrame2Text
local allyFlag, hordeFlag
local allyFlag, hordeFlag, requestedScoreData

local function ShowEstimatedPoints()
if AlwaysUpFrame1 and AlwaysUpFrame2 then
Expand Down Expand Up @@ -237,13 +237,38 @@ local function HideFlagDisplay()
end
end

local function colorizeFlagName(name)
-- if not mod.Options.ColorByClass then return name end
local classUpper
for i = 1, GetNumBattlefieldScores() do
local nameScoreboard, _, _, _, _, _, _, _, _, classToken = GetBattlefieldScore(i)
local noRealmName = strsplit("-", nameScoreboard) -- remove realm name, since Flag msg events never contain realm name
if noRealmName == name then
classUpper = classToken
break
end
end

if classUpper then
local classTextColor = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[classUpper] or RAID_CLASS_COLORS[classUpper]
local hexClassColor = format("ff%02X%02X%02X", 255 * classTextColor.r, 255 * classTextColor.g, 255 * classTextColor.b)
name = format("|c%s%s|r", hexClassColor, name)
else
DBM:Debug("Couldn't find class for "..name..", requesting data from server")
requestedScoreData = true
RequestBattlefieldScoreData()
end

return name
end

local function UpdateFlagDisplay()
if flagFrame1Text and flagFrame2Text then
if allyFlag then
if GetCurrentMapAreaID() == 483 then -- EotS
flagFrame1Text:SetText(L.Flag..": "..allyFlag)
flagFrame1Text:SetText(L.Flag..": "..colorizeFlagName(allyFlag))
else
flagFrame1Text:SetText(allyFlag)
flagFrame1Text:SetText(colorizeFlagName(allyFlag))
end
flagButton1:SetAttribute("macrotext", "/targetexact "..allyFlag)
else
Expand All @@ -253,9 +278,9 @@ local function UpdateFlagDisplay()

if hordeFlag then
if GetCurrentMapAreaID() == 483 then -- EotS
flagFrame2Text:SetText(L.Flag..": "..hordeFlag)
flagFrame2Text:SetText(L.Flag..": "..colorizeFlagName(hordeFlag))
else
flagFrame2Text:SetText(hordeFlag)
flagFrame2Text:SetText(colorizeFlagName(hordeFlag))
end
flagButton2:SetAttribute("macrotext", "/targetexact "..hordeFlag)
else
Expand Down Expand Up @@ -370,7 +395,8 @@ function mod:SubscribeFlags()
end
self:RegisterShortTermEvents(
"CHAT_MSG_BG_SYSTEM_ALLIANCE",
"CHAT_MSG_BG_SYSTEM_HORDE"
"CHAT_MSG_BG_SYSTEM_HORDE",
"UPDATE_BATTLEFIELD_SCORE"
)
end

Expand Down Expand Up @@ -660,6 +686,13 @@ do
end
end

function mod:UPDATE_BATTLEFIELD_SCORE()
if requestedScoreData then -- Attempt to scope this only to run when flag coloring runs
UpdateFlagDisplay()
requestedScoreData = false
end
end

function mod:CHAT_MSG_BG_SYSTEM_ALLIANCE(...)
updateflagcarrier(self, ...)
if self.Options.ShowFlagCarrier then
Expand Down