Files
coa-altoholic/Altoholic/CoAClassColors.lua
T
florian.berthold 0565051302
release / release (push) Successful in 5s
coa.10: CoA reputation factions (data-driven) + custom-class icons + all-professions Skills
- Reputation view rebuilt data-driven from each char's scanned factions grouped
  by in-game category; CoA custom factions (and future ones) appear automatically.
  Old hardcoded tree kept only as an icon lookup.
- CoA custom-class icons (classes 12-32) render from bundled atlas
  Altoholic/images/coa-classes.blp (texcoords from coa-details) instead of the
  Warrior glue-icon fallback in ShowClassIcons.
- Skills tab shows ALL known professions (dynamic list incl Woodcutting/Woodworking),
  not 2 fixed slots; DataStore_Skills scans on PLAYER_ENTERING_WORLD/SKILL_LINES_CHANGED
  (fixes 'no profession data' that only scanned on ghost-release).
2026-05-29 15:55:25 +02:00

118 lines
5.1 KiB
Lua

-- CoAClassColors.lua
--
-- Mirrors the live client's RAID_CLASS_COLORS palette into
-- Altoholic.ClassInfo so the guild/character/profession panes render
-- the 21 Conquest-of-Azeroth custom classes (plus HERO) instead of
-- defaulting to WHITE via the `or WHITE` fallback at
-- Altoholic.lua:581.
--
-- Background
-- ----------
-- Altoholic ships a hardcoded ChatColor table keyed by the 10 vanilla
-- englishClass tokens (Altoholic.lua:23-32). On the CoA Voljin/PTR
-- realm, UnitClass / GetGuildRosterInfo return tokens like BARBARIAN,
-- WITCHDOCTOR, CHRONOMANCER, … which fall through the table.
--
-- The realm-authoritative palette is shipped by the client itself in
-- _G.RAID_CLASS_COLORS (Interface/SharedXML/SharedConstants.lua inside
-- patch-B.MPQ — 10 vanilla + HERO + 21 CoA = 32 entries on Voljin).
-- Other Exiles addon ports follow the same mirror pattern
-- (coa-omen/CoAClassColors.lua → CUSTOM_CLASS_COLORS,
-- coa-shadowedunitframes/.../CoAClassColors.lua → SUF profile,
-- coa-kui-nameplates/.../CoAClassColors.lua → !ClassColors).
--
-- Source of truth: db.exil.es /coa/dev for the full palette;
-- _G.RAID_CLASS_COLORS at FrameXML load time for the running client.
local Alto = _G.Altoholic
local AC = Alto and Alto.ClassInfo
if type(AC) ~= "table" then return end
local source = _G.RAID_CLASS_COLORS
if type(source) ~= "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
for token, color in pairs(source) do
if AC[token] == nil then
local r, g, b = unpackColor(color)
if r and g and b then
AC[token] = string.format("|cFF%02X%02X%02X",
r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5)
end
end
end
-- Class ICONS
-- -----------
-- WoW's _G.CLASS_ICON_TCOORDS only carries texcoords for the playable
-- classes the *client* shipped with — on the CoA Voljin client that is
-- the vanilla 10 + DEATHKNIGHT only. The 21 CoA custom classes
-- (BARBARIAN, WITCHDOCTOR, CHRONOMANCER, …) have no entry, so any draw
-- site that does `CLASS_ICON_TCOORDS[class]` falls back to a wrong or
-- blank icon (Altoholic.lua:ShowClassIcons hit this).
--
-- The realm-authoritative class-icon atlas is the 512x512 (8x8 grid of
-- 64px cells) BLP that the CoA Details! fork bundles and renders for
-- all 32 classes. We ship a copy of that atlas as
-- Interface\AddOns\Altoholic\images\coa-classes.blp and reproduce its
-- per-token texcoords below (source: Details/functions/profiles.lua
-- class_coords). Keyed by the UPPERCASE englishClass token — the same
-- key DataStore stores (DataStore_Characters: UnitClass()'s 2nd return)
-- and CLASS_ICON_TCOORDS uses, so it is a drop-in for both.
--
-- Includes the vanilla 10 + DK too, so a single lookup covers every
-- CoA-playable class uniformly out of one texture.
local COA_CLASS_ICON_TEXTURE = [[Interface\AddOns\Altoholic\images\coa-classes]]
-- left, right, top, bottom (verbatim from the CoA Details atlas)
local COA_CLASS_ICON_TCOORDS = {
WITCHHUNTER = { 0.875, 1, 0.375, 0.5 },
WITCHDOCTOR = { 0.75, 0.875, 0.375, 0.5 },
WILDWALKER = { 0.625, 0.75, 0.375, 0.5 },
WARRIOR = { 0.5, 0.625, 0.375, 0.5 },
WARLOCK = { 0.375, 0.5, 0.375, 0.5 },
TINKER = { 0.25, 0.375, 0.375, 0.5 },
SUNCLERIC = { 0.125, 0.25, 0.375, 0.5 },
STORMBRINGER = { 0, 0.125, 0.375, 0.5 },
STARCALLER = { 0.875, 1, 0.25, 0.375 },
SPIRITMAGE = { 0.75, 0.875, 0.25, 0.375 },
SONOFARUGAL = { 0.625, 0.75, 0.25, 0.375 },
SHAMAN = { 0.5, 0.625, 0.25, 0.375 },
ROGUE = { 0.375, 0.5, 0.25, 0.375 },
REAPER = { 0.25, 0.375, 0.25, 0.375 },
RANGER = { 0.125, 0.25, 0.25, 0.375 },
PYROMANCER = { 0, 0.125, 0.25, 0.375 },
PROPHET = { 0.875, 1, 0.125, 0.25 },
PRIEST = { 0.75, 0.875, 0.125, 0.25 },
PALADIN = { 0.625, 0.75, 0.125, 0.25 },
NECROMANCER = { 0.5, 0.625, 0.125, 0.25 },
MONK = { 0.375, 0.5, 0.125, 0.25 },
MAGE = { 0.25, 0.375, 0.125, 0.25 },
HUNTER = { 0.125, 0.25, 0.125, 0.25 },
HERO = { 0, 0.125, 0.125, 0.25 },
GUARDIAN = { 0.875, 1, 0, 0.125 },
FLESHWARDEN = { 0.75, 0.875, 0, 0.125 },
DRUID = { 0.625, 0.75, 0, 0.125 },
DEMONHUNTER = { 0.5, 0.625, 0, 0.125 },
DEATHKNIGHT = { 0.375, 0.5, 0, 0.125 },
CULTIST = { 0.25, 0.375, 0, 0.125 },
CHRONOMANCER = { 0.125, 0.25, 0, 0.125 },
BARBARIAN = { 0, 0.125, 0, 0.125 },
}
-- Returns texture, left, right, top, bottom for a CoA-playable class
-- token, or nil if the token is unknown (caller should fall back to the
-- stock CLASS_ICON_TCOORDS path). Tolerant of a nil/missing token.
function Alto:GetCoAClassIcon(token)
if type(token) ~= "string" then return end
local tc = COA_CLASS_ICON_TCOORDS[token]
if not tc then return end
return COA_CLASS_ICON_TEXTURE, tc[1], tc[2], tc[3], tc[4]
end