Files
florian.berthold 5d9749a920 fix: include CoA custom classes in portrait/totems/raid-grouping
portrait.lua: guard CLASS_ICON_TCOORDS[classToken] lookup. CoA custom
classes (Witchdoctor, Templar, …) have no entry in the vanilla
CLASS_ICON_TCOORDS table, so the old SetTexCoord call crashed with a
nil-index whenever a custom-class unit was shown. Cache the lookup
into a local and fall through to blank texture on miss.

totems.lua: file-level class gate registered the totem bar only for
SHAMAN (and a 1-slot DK guardian variant), locking out Witchdoctor and
any future CoA totem class. Probe MAX_TOTEMS > 1 / HasMultiCastActionBar
(Bartender's pattern) and register without a class filter when the
player has the multi-cast totem bar, so any CoA totem class picks it up.

units.lua: raid-header groupingOrder was the hardcoded 10-class vanilla
string, which dumped the 11 CoA custom classes into an unsorted tail
when GROUP BY CLASS was active. Build the order dynamically from
RAID_CLASS_COLORS (CoA populates this with all 21 classes via the
CUSTOM_CLASS_COLORS mechanism) at the call site.
2026-05-24 17:39:05 +02:00

101 lines
3.1 KiB
Lua

local Portrait = {}
ShadowUF:RegisterModule(Portrait, "portrait", ShadowUF.L["Portrait"])
-- If the camera isn't reset OnShow, it'll show the entire character instead of just the head, odd I know
local function resetCamera(self)
self:SetCamera(0)
end
local function resetGUID(self)
self.guid = nil
end
function Portrait:OnEnable(frame)
frame:RegisterUnitEvent("UNIT_PORTRAIT_UPDATE", self, "UpdateFunc")
frame:RegisterUnitEvent("UNIT_MODEL_CHANGED", self, "Update")
if( frame.unitRealType == "party" ) then
-- frame:RegisterNormalEvent("PARTY_MEMBER_ENABLE", self, "Update")
-- frame:RegisterNormalEvent("PARTY_MEMBER_DISABLE", self, "Update")
end
frame:RegisterUpdateFunc(self, "UpdateFunc")
end
function Portrait:OnDisable(frame)
frame:UnregisterAll(self)
end
function Portrait:OnPreLayoutApply(frame, config)
if( not frame.visibility.portrait ) then return end
if( config.portrait.type == "3D" ) then
if( not frame.portraitModel ) then
frame.portraitModel = CreateFrame("PlayerModel", nil, frame)
frame.portraitModel:SetScript("OnShow", resetCamera)
frame.portraitModel:SetScript("OnHide", resetGUID)
frame.portraitModel.parent = frame
end
frame.portrait = frame.portraitModel
frame.portrait:Show()
ShadowUF.Layout:ToggleVisibility(frame.portraitTexture, false)
else
frame.portraitTexture = frame.portraitTexture or frame:CreateTexture(nil, "ARTWORK")
frame.portrait = frame.portraitTexture
frame.portrait:Show()
ShadowUF.Layout:ToggleVisibility(frame.portraitModel, false)
end
end
function Portrait:UpdateFunc(frame)
-- Portrait models can't be updated unless the GUID changed or else you have the animation jumping around
if( ShadowUF.db.profile.units[frame.unitType].portrait.type == "3D" ) then
local guid = UnitGUID(frame.unitOwner)
if( frame.portrait.guid ~= guid ) then
self:Update(frame)
end
frame.portrait.guid = guid
else
self:Update(frame)
end
end
function Portrait:Update(frame, event)
local type = ShadowUF.db.profile.units[frame.unitType].portrait.type
-- Use class thingy
if( type == "class" ) then
local classToken = select(2, UnitClass(frame.unitOwner))
local coords = classToken and CLASS_ICON_TCOORDS[classToken]
if( coords ) then
frame.portrait:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
frame.portrait:SetTexCoord(coords[1], coords[2], coords[3], coords[4])
else
-- CoA custom classes (Witchdoctor/Templar/…) have no CLASS_ICON_TCOORDS entry; blank instead of crash
frame.portrait:SetTexture("")
end
-- Use 2D character image
elseif( type == "2D" ) then
frame.portrait:SetTexCoord(0.10, 0.90, 0.10, 0.90)
SetPortraitTexture(frame.portrait, frame.unitOwner)
-- Using 3D portrait, but the players not in range so swap to 2D
elseif( not UnitIsVisible(frame.unitOwner) or not UnitIsConnected(frame.unitOwner) ) then
frame.portrait:SetModelScale(4.25)
frame.portrait:SetPosition(0, 0, -1.5)
frame.portrait:SetModel("Interface\\Buttons\\talktomequestionmark.mdx")
-- Use animated 3D portrait
else
frame.portrait:SetUnit(frame.unitOwner)
frame.portrait:SetCamera(0)
frame.portrait:Show()
end
end