CoAClassColors: mirror RAID_CLASS_COLORS into CUSTOM_CLASS_COLORS

The previous file augmented _G.RAID_CLASS_COLORS with hand-picked
placeholder colors. On both the Voljin/CoA and Ascension classic+
clients the table is already populated by FrameXML
(SharedXML/SharedConstants.lua) with all 32 class tokens, so the
augmentation was dead code (only-set-if-nil never triggered) and the
hand-picked palette diverged from what the realm itself ships.

The path that DOES still need fixing is !ClassColors. When that addon
is loaded it injects a separate _G.CUSTOM_CLASS_COLORS populated only
with the vanilla 10, and Omen.lua:914-917 prefers CUSTOM_CLASS_COLORS
over RAID_CLASS_COLORS. So on a !ClassColors-equipped client the 22
CoA tokens silently fall through and the bar reverts to
dbBar.BarColor.

Rewritten to: when CUSTOM_CLASS_COLORS exists, copy missing entries
from RAID_CLASS_COLORS — same nil-only policy. RAID_CLASS_COLORS is
left untouched (the client is authoritative). No more divergence
between Omen and the realm palette.
This commit is contained in:
2026-05-08 22:48:50 +02:00
parent 5e00afc363
commit 7b318475e8
+48 -72
View File
@@ -1,90 +1,66 @@
-- CoAClassColors.lua -- CoAClassColors.lua
-- --
-- Augments _G.RAID_CLASS_COLORS with the 22 Conquest-of-Azeroth class -- Forwards the live client's RAID_CLASS_COLORS palette into
-- file-tokens (10 vanilla-style + 21 Ascension custom + HERO) that -- _G.CUSTOM_CLASS_COLORS so Omen renders Conquest-of-Azeroth class
-- stock Blizzard / Omen don't know about. -- bars correctly when the !ClassColors addon is loaded.
-- --
-- Why this fixes the threat-meter -- Background
-- ------------------------------- -- ----------
-- Omen's bar-color path (Omen.lua:1629) does: -- The CoA Voljin client (and the Ascension classic+ client) ship
-- dbBar.UseClassColors and (RAID_CLASS_COLORS[class] or ...) -- Interface/SharedXML/SharedConstants.lua with all 32 class
-- where `class` is the second return of UnitClass(unit) — i.e. -- file_strings populated in _G.RAID_CLASS_COLORS — 10 vanilla + HERO +
-- ChrClasses.dbc `file_string`. For a Venomancer that is "PROPHET", -- 21 CoA customs (BARBARIAN, WITCHDOCTOR, DEMONHUNTER, FLESHWARDEN,
-- a Templar "MONK", a Knight of Xoroth "FLESHWARDEN", and so on; none -- MONK = Templar, PROPHET = Venomancer, …). Omen.lua:1629 reads
-- of those keys exist in stock RAID_CLASS_COLORS, so the lookup -- RAID_CLASS_COLORS directly, so the unmodified addon already paints
-- returns nil, the whole and/or chain collapses, and the bar -- CoA classes with the realm-canonical palette.
-- silently falls back to the generic dbBar.BarColor.
-- --
-- We populate the table with sensible thematic defaults below. We -- The exception is the !ClassColors path. !ClassColors injects a
-- only set keys that are missing, so the vanilla 10 (WARRIOR … -- separate _G.CUSTOM_CLASS_COLORS table, populated from its own
-- DRUID + DEATHKNIGHT) keep their Blizzard / !ClassColors values. -- (vanilla-10-only) defaults plus user overrides. Omen prefers
-- CUSTOM_CLASS_COLORS over RAID_CLASS_COLORS when present (Omen.lua
-- :914-917, options at :2828), so on a !ClassColors-equipped client
-- the 22 CoA tokens silently fall through and bars revert to the
-- generic dbBar.BarColor.
-- --
-- The colours below are deliberate placeholders chosen to be -- Strategy
-- visually distinct on a dark threat bar. They can be retuned -- --------
-- in-game via !ClassColors (Bartender4-style) without re-patching. -- If CUSTOM_CLASS_COLORS exists at file-load time (i.e. !ClassColors
-- already loaded — Omen.toc declares it as an OptionalDep, so it loads
-- first when installed), copy any RAID_CLASS_COLORS entry that
-- CUSTOM_CLASS_COLORS is missing. Never overwrite — !ClassColors user
-- preferences and any other addon's earlier write win.
--
-- We deliberately don't touch RAID_CLASS_COLORS itself: the client
-- already populates it, and any value we'd choose here would be a
-- guess relative to the realm-authoritative palette in
-- SharedConstants.lua.
--
-- Source of truth: _G.RAID_CLASS_COLORS at FrameXML load time
-- (Voljin/PTR realm: patch-B.MPQ → SharedXML/SharedConstants.lua).
local CCC = _G.CUSTOM_CLASS_COLORS
if type(CCC) ~= "table" then return end
local CC = _G.RAID_CLASS_COLORS local CC = _G.RAID_CLASS_COLORS
if type(CC) ~= "table" then if type(CC) ~= "table" then return end
CC = {}
_G.RAID_CLASS_COLORS = CC
end
-- file_string -> {r, g, b} (0..1 floats)
-- Display name in comment is the in-game class name on Ascension CoA.
-- Source of truth: coa-db `class.file_string` (ChrClasses.dbc record id).
local COA_COLORS = {
HERO = { 1.000, 0.820, 0.000 }, -- #FFD100 CoA brand gold (Ascension all-class archetype)
BARBARIAN = { 0.757, 0.400, 0.420 }, -- #C1666B Barbarian, dusty crimson
WITCHDOCTOR = { 0.502, 0.780, 0.694 }, -- #80C7B1 Witch Doctor, voodoo teal
DEMONHUNTER = { 0.639, 0.188, 0.788 }, -- #A330C9 Felsworn, fel purple (same hex retail uses)
WITCHHUNTER = { 0.722, 0.690, 0.627 }, -- #B8B0A0 Witch Hunter, plate-bone
STORMBRINGER = { 0.306, 0.851, 1.000 }, -- #4ED9FF Stormbringer, lightning cyan
FLESHWARDEN = { 0.361, 0.180, 0.451 }, -- #5C2E73 Knight of Xoroth, necrotic purple
GUARDIAN = { 0.290, 0.616, 0.349 }, -- #4A9D59 Guardian, emerald
MONK = { 0.000, 1.000, 0.729 }, -- #00FFBA Templar, jade (matches retail Monk)
SONOFARUGAL = { 0.667, 0.122, 0.122 }, -- #AA1F1F Bloodmage, blood red
RANGER = { 0.369, 0.549, 0.227 }, -- #5E8C3A Ranger, forest green (kept distinct from Hunter)
CHRONOMANCER = { 0.839, 0.541, 0.227 }, -- #D68A3A Chronomancer, bronze
NECROMANCER = { 0.302, 0.478, 0.353 }, -- #4D7A5A Necromancer, grave green
PYROMANCER = { 1.000, 0.416, 0.000 }, -- #FF6A00 Pyromancer, fire orange
CULTIST = { 0.478, 0.251, 0.722 }, -- #7A40B8 Cultist, eldritch purple
STARCALLER = { 0.475, 0.784, 0.839 }, -- #79C8D6 Starcaller, astral cyan
SUNCLERIC = { 0.949, 0.757, 0.306 }, -- #F2C14E Sun Cleric, solar gold
TINKER = { 0.769, 0.486, 0.310 }, -- #C47C4F Tinker, copper
PROPHET = { 0.722, 0.824, 0.275 }, -- #B8D246 Venomancer, toxic chartreuse
REAPER = { 0.431, 0.227, 0.541 }, -- #6E3A8A Reaper, death violet
WILDWALKER = { 0.545, 0.435, 0.278 }, -- #8B6F47 Primalist, earth brown
SPIRITMAGE = { 0.435, 0.714, 0.878 }, -- #6FB6E0 Runemaster, rune frost
}
-- Build the colorStr lazily — Blizzard's |c%02x%02x%02x%02x escape format,
-- so frames that ask for it (chat link colouring, threat-warning prints,
-- etc.) get a string that matches the rgb.
local function colorStr(r, g, b) local function colorStr(r, g, b)
return string.format("ff%02x%02x%02x", r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5) return string.format("ff%02x%02x%02x", r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5)
end end
for token, rgb in pairs(COA_COLORS) do local function unpackColor(c)
-- Only set if missing — !ClassColors and any user override wins. if type(c) ~= "table" then return end
if CC[token] == nil then if c.GetRGB then return c:GetRGB() end
CC[token] = { return c.r, c.g, c.b
r = rgb[1], g = rgb[2], b = rgb[3],
colorStr = colorStr(rgb[1], rgb[2], rgb[3]),
}
end
end end
-- Ascension exposes CUSTOM_CLASS_COLORS only when the !ClassColors addon for token, src in pairs(CC) do
-- is loaded; if it is, fold our entries in there too so any addon that if CCC[token] == nil then
-- prefers CUSTOM_CLASS_COLORS (Omen does, see Omen.lua:914) still local r, g, b = unpackColor(src)
-- renders CoA classes correctly. Same nil-only policy. if r and g and b then
if type(_G.CUSTOM_CLASS_COLORS) == "table" then
local CCC = _G.CUSTOM_CLASS_COLORS
for token, rgb in pairs(COA_COLORS) do
if CCC[token] == nil then
CCC[token] = { CCC[token] = {
r = rgb[1], g = rgb[2], b = rgb[3], r = r, g = g, b = b,
colorStr = colorStr(rgb[1], rgb[2], rgb[3]), colorStr = colorStr(r, g, b),
} }
end end
end end