From 7b318475e8267ef120e17ea199ca09643e095960 Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Fri, 8 May 2026 22:48:50 +0200 Subject: [PATCH] CoAClassColors: mirror RAID_CLASS_COLORS into CUSTOM_CLASS_COLORS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- CoAClassColors.lua | 120 ++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 72 deletions(-) diff --git a/CoAClassColors.lua b/CoAClassColors.lua index 3e44de4..273f86e 100644 --- a/CoAClassColors.lua +++ b/CoAClassColors.lua @@ -1,90 +1,66 @@ -- CoAClassColors.lua -- --- Augments _G.RAID_CLASS_COLORS with the 22 Conquest-of-Azeroth class --- file-tokens (10 vanilla-style + 21 Ascension custom + HERO) that --- stock Blizzard / Omen don't know about. +-- Forwards the live client's RAID_CLASS_COLORS palette into +-- _G.CUSTOM_CLASS_COLORS so Omen renders Conquest-of-Azeroth class +-- bars correctly when the !ClassColors addon is loaded. -- --- Why this fixes the threat-meter --- ------------------------------- --- Omen's bar-color path (Omen.lua:1629) does: --- dbBar.UseClassColors and (RAID_CLASS_COLORS[class] or ...) --- where `class` is the second return of UnitClass(unit) — i.e. --- ChrClasses.dbc `file_string`. For a Venomancer that is "PROPHET", --- a Templar "MONK", a Knight of Xoroth "FLESHWARDEN", and so on; none --- of those keys exist in stock RAID_CLASS_COLORS, so the lookup --- returns nil, the whole and/or chain collapses, and the bar --- silently falls back to the generic dbBar.BarColor. +-- Background +-- ---------- +-- The CoA Voljin client (and the Ascension classic+ client) ship +-- Interface/SharedXML/SharedConstants.lua with all 32 class +-- file_strings populated in _G.RAID_CLASS_COLORS — 10 vanilla + HERO + +-- 21 CoA customs (BARBARIAN, WITCHDOCTOR, DEMONHUNTER, FLESHWARDEN, +-- MONK = Templar, PROPHET = Venomancer, …). Omen.lua:1629 reads +-- RAID_CLASS_COLORS directly, so the unmodified addon already paints +-- CoA classes with the realm-canonical palette. -- --- We populate the table with sensible thematic defaults below. We --- only set keys that are missing, so the vanilla 10 (WARRIOR … --- DRUID + DEATHKNIGHT) keep their Blizzard / !ClassColors values. +-- The exception is the !ClassColors path. !ClassColors injects a +-- separate _G.CUSTOM_CLASS_COLORS table, populated from its own +-- (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 --- visually distinct on a dark threat bar. They can be retuned --- in-game via !ClassColors (Bartender4-style) without re-patching. +-- Strategy +-- -------- +-- 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 -if type(CC) ~= "table" then - CC = {} - _G.RAID_CLASS_COLORS = CC -end +if type(CC) ~= "table" then return 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) return string.format("ff%02x%02x%02x", r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5) end -for token, rgb in pairs(COA_COLORS) do - -- Only set if missing — !ClassColors and any user override wins. - if CC[token] == nil then - CC[token] = { - r = rgb[1], g = rgb[2], b = rgb[3], - colorStr = colorStr(rgb[1], rgb[2], rgb[3]), - } - end +local function unpackColor(c) + if type(c) ~= "table" then return end + if c.GetRGB then return c:GetRGB() end + return c.r, c.g, c.b end --- Ascension exposes CUSTOM_CLASS_COLORS only when the !ClassColors addon --- is loaded; if it is, fold our entries in there too so any addon that --- prefers CUSTOM_CLASS_COLORS (Omen does, see Omen.lua:914) still --- renders CoA classes correctly. Same nil-only policy. -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 +for token, src in pairs(CC) do + if CCC[token] == nil then + local r, g, b = unpackColor(src) + if r and g and b then CCC[token] = { - r = rgb[1], g = rgb[2], b = rgb[3], - colorStr = colorStr(rgb[1], rgb[2], rgb[3]), + r = r, g = g, b = b, + colorStr = colorStr(r, g, b), } end end