089454f937
SUF stores class colors in a private ShadowUF.db.profile.classColors table seeded only with the vanilla 10 in defaultlayout.lua. On the Voljin/CoA client _G.RAID_CLASS_COLORS is populated by FrameXML with 22 additional tokens (HERO + 21 CoA customs), but those never reach SUF, so a guildmate's CoA-class health bar falls through to the percent gradient. New file post-hooks ShadowUF:OnInitialize, ProfileReset and ProfilesChanged to copy any RAID_CLASS_COLORS entry the active profile is missing into profile.classColors. Idempotent — only fills nil keys, so user customisations and SUF's stock vanilla-10 values win. Source of truth is the live client's table, populated in patch-B.MPQ → SharedXML/SharedConstants.lua, so the addon stays in sync with whatever palette the realm ships without a hardcoded copy.
88 lines
3.0 KiB
Lua
88 lines
3.0 KiB
Lua
-- CoAClassColors.lua
|
|
--
|
|
-- Mirrors the live client's RAID_CLASS_COLORS into ShadowUF's private
|
|
-- profile.classColors table on init.
|
|
--
|
|
-- Why this is needed
|
|
-- ------------------
|
|
-- SUF stores its own classColors map (defaultlayout.lua:109) and looks
|
|
-- up colors via `ShadowUF.db.profile.classColors[class]` at e.g.
|
|
-- health.lua:149, tags.lua:246, empty.lua:53. Stock SUF only seeds
|
|
-- this table with the vanilla 10 (WARRIOR..DRUID + DEATHKNIGHT) plus
|
|
-- PET / VEHICLE.
|
|
--
|
|
-- The Conquest of Azeroth client (Voljin realm) ships
|
|
-- 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, …). Other addons (Omen,
|
|
-- Details, DBM, …) read RAID_CLASS_COLORS directly so they pick the
|
|
-- realm-canonical palette automatically. SUF doesn't, so a guildmate's
|
|
-- CoA-class health bar falls through `colors[class] == nil` and the
|
|
-- bar reverts to the percent gradient.
|
|
--
|
|
-- Strategy
|
|
-- --------
|
|
-- After SUF's OnInitialize finishes (db.profile.classColors exists,
|
|
-- AceDB has resolved the active profile), copy any RAID_CLASS_COLORS
|
|
-- entry the profile is missing. We never overwrite — user's
|
|
-- in-profile customisations win, and the vanilla 10 keep SUF's stock
|
|
-- (slightly tweaked) values from defaultlayout.lua. The dance covers
|
|
-- profile changes / resets too so the entries don't disappear when
|
|
-- the user switches profiles.
|
|
--
|
|
-- Source of truth: whatever the live client populates in
|
|
-- _G.RAID_CLASS_COLORS at FrameXML load time (Voljin/PTR realm:
|
|
-- patch-B.MPQ → SharedXML/SharedConstants.lua, ~32 entries).
|
|
|
|
local ShadowUF = _G.ShadowUF
|
|
if type(ShadowUF) ~= "table" then return 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
|
|
|
|
local function mirrorIntoProfile()
|
|
local profile = ShadowUF.db and ShadowUF.db.profile
|
|
local target = profile and profile.classColors
|
|
if type(target) ~= "table" then return end
|
|
|
|
local source = _G.RAID_CLASS_COLORS
|
|
if type(source) ~= "table" then return end
|
|
|
|
for token, color in pairs(source) do
|
|
if target[token] == nil then
|
|
local r, g, b = unpackColor(color)
|
|
if r and g and b then
|
|
target[token] = { r = r, g = g, b = b }
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local origInit = ShadowUF.OnInitialize
|
|
function ShadowUF:OnInitialize(...)
|
|
local rv
|
|
if origInit then rv = origInit(self, ...) end
|
|
mirrorIntoProfile()
|
|
return rv
|
|
end
|
|
|
|
local origReset = ShadowUF.ProfileReset
|
|
function ShadowUF:ProfileReset(...)
|
|
local rv
|
|
if origReset then rv = origReset(self, ...) end
|
|
mirrorIntoProfile()
|
|
return rv
|
|
end
|
|
|
|
local origChanged = ShadowUF.ProfilesChanged
|
|
function ShadowUF:ProfilesChanged(...)
|
|
local rv
|
|
if origChanged then rv = origChanged(self, ...) end
|
|
mirrorIntoProfile()
|
|
return rv
|
|
end
|