diff --git a/ShadowedUnitFrames/CoAClassColors.lua b/ShadowedUnitFrames/CoAClassColors.lua new file mode 100644 index 0000000..835da1d --- /dev/null +++ b/ShadowedUnitFrames/CoAClassColors.lua @@ -0,0 +1,87 @@ +-- 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 diff --git a/ShadowedUnitFrames/ShadowedUnitFrames.toc b/ShadowedUnitFrames/ShadowedUnitFrames.toc index fd62da5..16ef476 100644 --- a/ShadowedUnitFrames/ShadowedUnitFrames.toc +++ b/ShadowedUnitFrames/ShadowedUnitFrames.toc @@ -51,3 +51,5 @@ modules\incheal.lua modules\range.lua modules\empty.lua modules\druid.lua + +CoAClassColors.lua