nameplates: read friendly name colours from the class table

The class-colour write sourced r, g, b from the health bar rather than
from PFUI_CLASS_COLORS[class], which the condition tested for but never
read. So "class colours on friendly names" only produced a class colour
when friendclassc - a bar option - happened to be on as well; otherwise
the name took the generic friendly colour. In every case it also
inherited the tapped-grey and barcombatstate overrides meant for the bar,
neither of which belongs on the name.

The name now reads the class table directly.

The discarded "and PFUI_CLASS_COLORS[class]" term was dead weight: the
table carries an __index metamethod returning a grey ColorMixin for any
missing key, so it was always truthy and merely allocated a throwaway
table per evaluation. "and class" is the real guard. One behaviour change
falls out - a friendly player of an unrecognised class now takes that
grey fallback rather than the bar colour, which is what the option means.

(cherry picked from commit f880dc3528db2ba0d0936b00a4dff8deec48e6d2)
(cherry picked from commit 111d70004d4fb172f168aa48a4cb6177a7f0d393)
This commit is contained in:
roby-brok
2026-08-21 10:43:34 +01:00
committed by Brues
parent a7ad1f073f
commit a3cfd711fe
+11 -4
View File
@@ -1267,7 +1267,7 @@ nameplates:RegisterEvent("PLAYER_GUILD_UPDATE")
-- either could suppress the other -- and since nameplate.cache survives
-- pool reuse, a recycled plate could keep the previous unit's name colour.
local ownname = unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassnamec"] == "1"
and class and PFUI_CLASS_COLORS[class] and true or nil
and class and true or nil
if plate.cache.ownname ~= ownname then
plate.cache.ownname = ownname
@@ -1276,9 +1276,16 @@ nameplates:RegisterEvent("PLAYER_GUILD_UPDATE")
plate.cache.ownnamecolor = nil
end
if ownname and r + g + b ~= plate.cache.ownnamecolor then
plate.cache.ownnamecolor = r + g + b
plate.name:SetTextColor(r, g, b, a)
-- read the class colour directly rather than reusing the bar's r,g,b: the
-- bar only carries a class colour when friendclassc happens to be on, and
-- it also picks up the tapped-grey and barcombatstate overrides, neither of
-- which belongs on the name.
if ownname then
local cr, cg, cb, ca = PFUI_CLASS_COLORS[class]:GetRGBA()
if cr + cg + cb ~= plate.cache.ownnamecolor then
plate.cache.ownnamecolor = cr + cg + cb
plate.name:SetTextColor(cr, cg, cb, ca)
end
end
if target and C.nameplates.cpdisplay == "1" then