Files
coa-omen/CoAClassColors.lua
T
florian.berthold 7b318475e8 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.
2026-05-08 22:48:50 +02:00

68 lines
2.5 KiB
Lua

-- CoAClassColors.lua
--
-- 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.
--
-- 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.
--
-- 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.
--
-- 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 return end
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
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
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 = r, g = g, b = b,
colorStr = colorStr(r, g, b),
}
end
end
end