class color cleanup

This commit is contained in:
Brues
2026-05-23 02:56:00 -05:00
parent 90fdd8cfc3
commit 1d27f7bed3
10 changed files with 40 additions and 85 deletions
+3 -13
View File
@@ -220,13 +220,8 @@ end
-- return: [table] string, r, g, b
function pfUI.api.GetUnitColor(unitstr)
local _, class = UnitClass(unitstr)
local r, g, b = .8, .8, .8
if RAID_CLASS_COLORS[class] then
r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
end
return pfUI.api.rgbhex(r,g,b), r, g, b
local classColor = RAID_CLASS_COLORS[class]
return classColor:GenerateHexColorMarkup(), classColor:GetRGB()
end
-- [ strvertical ]
@@ -1011,12 +1006,7 @@ function pfUI.api.rgbhex(r, g, b, a)
end
if _r and _g and _b and _a then
-- limit values to 0-1
_r = _r + 0 > 1 and 1 or _r + 0
_g = _g + 0 > 1 and 1 or _g + 0
_b = _b + 0 > 1 and 1 or _b + 0
_a = _a + 0 > 1 and 1 or _a + 0
return string.format("|c%02x%02x%02x%02x", _a*255, _r*255, _g*255, _b*255)
return CreateColor(_r, _g, _b, _a):GenerateHexColorMarkup()
end
return ""
+2 -4
View File
@@ -608,8 +608,7 @@ function pfUI.api.SetHighlight(frame, cr, cg, cb)
if not frame then return end
if not cr or not cg or not cb then
local _, class = UnitClass("player")
local color = RAID_CLASS_COLORS[class]
cr, cg, cb = color.r , color.g, color.b
cr, cg, cb = GetClassColor(class)
end
frame.cr, frame.cg, frame.cb = cr, cg, cb, ca
@@ -656,8 +655,7 @@ function pfUI.api.SkinButton(button, cr, cg, cb, icon, disableHighlight)
if not b then return end
if not cr or not cg or not cb then
local _, class = UnitClass("player")
local color = RAID_CLASS_COLORS[class]
cr, cg, cb = color.r , color.g, color.b
cr, cg, cb = GetClassColor(class)
end
pfUI.api.CreateBackdrop(b, nil, true)
b:SetNormalTexture("")
+16 -36
View File
@@ -1938,13 +1938,6 @@ function pfUI.uf:RefreshIndicators(unit)
end
end
local pfDebuffColors = {
["Magic"] = { 0.1, 0.7, 0.8, 1 },
["Poison"] = { 0.2, 0.7, 0.3, 1 },
["Curse"] = { 0.6, 0.2, 0.6, 1 },
["Disease"] = { 0.9, 0.7, 0.2, 1 }
}
function pfUI.uf:RefreshUnit(unit, component)
-- break early on misconfigured UF's
if not unit.label then return end
@@ -2086,11 +2079,8 @@ function pfUI.uf:RefreshUnit(unit, component)
unit.debuffs[i].texture:SetTexture(texture)
local r,g,b = DebuffTypeColor.none.r,DebuffTypeColor.none.g,DebuffTypeColor.none.b
if dtype and DebuffTypeColor[dtype] then
r,g,b = DebuffTypeColor[dtype].r,DebuffTypeColor[dtype].g,DebuffTypeColor[dtype].b
end
unit.debuffs[i].backdrop:SetBackdropBorderColor(r,g,b,1)
local dispelColor = C_UnitAuras.GetAuraDispelTypeColor(dtype or "")
unit.debuffs[i].backdrop:SetBackdropBorderColor(dispelColor:GetRGBA())
if texture then
unit.debuffs[i]:Show()
@@ -2177,16 +2167,17 @@ function pfUI.uf:RefreshUnit(unit, component)
indicator[debuff].tex:SetAllPoints(indicator[debuff])
if indicator.size ~= indicator[debuff].size or disptype ~= indicator[debuff].disp then
local dispelColor = C_UnitAuras.GetAuraDispelTypeColor(debuff)
if disptype == "4" then
indicator[debuff].tex:SetTexture(pfUI.media["img:"..debuff])
indicator[debuff].tex:SetVertexColor(unpack(pfDebuffColors[debuff]))
indicator[debuff].tex:SetVertexColor(dispelColor:GetRGBA())
indicator[debuff].tex:Show()
indicator[debuff]:ClearAllPoints()
indicator[debuff]:SetHeight(size)
indicator[debuff]:SetWidth(size)
indicator[debuff]:SetBackdrop(nil)
elseif disptype == "3" then
indicator[debuff].tex:SetTexture(unpack(pfDebuffColors[debuff]))
indicator[debuff].tex:SetTexture(dispelColor:GetRGBA())
indicator[debuff].tex:SetVertexColor(1,1,1,1)
indicator[debuff].tex:Show()
indicator[debuff]:ClearAllPoints()
@@ -2197,9 +2188,9 @@ function pfUI.uf:RefreshUnit(unit, component)
indicator[debuff].tex:Hide()
indicator[debuff]:SetAllPoints(unit.hp.bar)
indicator[debuff]:SetBackdrop(glow)
indicator[debuff]:SetBackdropBorderColor(unpack(pfDebuffColors[debuff]))
indicator[debuff]:SetBackdropBorderColor(dispelColor:GetRGBA())
elseif disptype == "1" then
indicator[debuff].tex:SetTexture(unpack(pfDebuffColors[debuff]))
indicator[debuff].tex:SetTexture(dispelColor:GetRGBA())
indicator[debuff].tex:SetVertexColor(1,1,1,1)
indicator[debuff].tex:Show()
indicator[debuff]:SetAllPoints(unit.hp.bar)
@@ -2415,9 +2406,7 @@ function pfUI.uf:RefreshUnit(unit, component)
custom_active = true
elseif custom == "0" then
if UnitIsPlayer(unitstr) then
local _, class = UnitClass(unitstr)
local color = RAID_CLASS_COLORS[class]
if color then r, g, b = color.r, color.g, color.b end
_, r, g, b = GetUnitColor(unitstr)
elseif unit.label == "pet" then
local happiness = GetPetHappiness()
if happiness == 1 then
@@ -3106,10 +3095,7 @@ function pfUI.uf.GetColor(self, preset)
if preset == "unit" and config["classcolor"] == "1" then
if UnitIsPlayer(unitstr) then
local _, class = UnitClass(unitstr)
if RAID_CLASS_COLORS[class] then
r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
end
_, r, g, b = GetUnitColor(unitstr)
elseif self.label == "pet" then
local happiness = GetPetHappiness()
if happiness == 1 then
@@ -3125,15 +3111,11 @@ function pfUI.uf.GetColor(self, preset)
end
elseif preset == "class" and config["classcolor"] == "1" then
local _, class = UnitClass(unitstr)
if RAID_CLASS_COLORS[class] then
r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
end
_, r, g, b = GetUnitColor(unitstr)
elseif preset == "reaction" and config["classcolor"] == "1" then
r = UnitReactionColor[UnitReaction(unitstr, "player")].r
g = UnitReactionColor[UnitReaction(unitstr, "player")].g
b = UnitReactionColor[UnitReaction(unitstr, "player")].b
local color = UnitReactionColor[UnitReaction(unitstr, "player")]
r, g, b = color.r, color.g, color.b
elseif preset == "health" and config["healthcolor"] == "1" then
-- O(1) Nampower lookup for health gradient color
@@ -3156,13 +3138,11 @@ function pfUI.uf.GetColor(self, preset)
end
elseif preset == "power" and config["powercolor"] == "1" then
r = ManaBarColor[UnitPowerType(unitstr)].r
g = ManaBarColor[UnitPowerType(unitstr)].g
b = ManaBarColor[UnitPowerType(unitstr)].b
local color = ManaBarColor[UnitPowerType(unitstr)]
r, g, b = color.r, color.g, color.b
elseif preset == "level" and config["levelcolor"] == "1" then
r = GetDifficultyColor(UnitLevel(unitstr)).r
g = GetDifficultyColor(UnitLevel(unitstr)).g
b = GetDifficultyColor(UnitLevel(unitstr)).b
local color = GetDifficultyColor(UnitLevel(unitstr))
r, g, b = color.r, color.g, color.b
end
if C.unitframes.pastel == "1" then
+1 -2
View File
@@ -1,7 +1,6 @@
pfUI:RegisterModule("actionbar", "vanilla", function ()
local _, class = UnitClass("player")
local color = RAID_CLASS_COLORS[class]
local cr, cg, cb = color.r , color.g, color.b
local _, cr, cg, cb = GetUnitColor('player')
local er, eg, eb, ea = GetStringColor(pfUI_config.appearance.border.color)
local backdrop_highlight = { edgeFile = pfUI.media["img:glow"], edgeSize = 8 }
+1 -1
View File
@@ -64,7 +64,7 @@ pfUI:RegisterModule("afkcam", "vanilla:tbc", function ()
local class = GetUnitData(arg2 or "")
local author, msg
if class and class ~= UNKNOWN then
local class_color = rgbhex(RAID_CLASS_COLORS[class])
local class_color = RAID_CLASS_COLORS[class]:GenerateHexColorMarkup()
author = string.format("%s%s|r",class_color,arg2)
else
author = arg2
+2 -12
View File
@@ -63,18 +63,8 @@ pfUI:RegisterModule("buff", "vanilla:tbc", function ()
buff.texture:SetTexture(aura.icon)
if buff.btype == "HARMFUL" then
local dtype = aura.dispelName
if dtype == "Magic" then
buff.backdrop:SetBackdropBorderColor(0,1,1,1)
elseif dtype == "Poison" then
buff.backdrop:SetBackdropBorderColor(0,1,0,1)
elseif dtype == "Curse" then
buff.backdrop:SetBackdropBorderColor(1,0,1,1)
elseif dtype == "Disease" then
buff.backdrop:SetBackdropBorderColor(1,1,0,1)
else
buff.backdrop:SetBackdropBorderColor(1,0,0,1)
end
local dispelColor = C_UnitAuras.GetAuraDispelTypeColor(aura.dispelName)
buff.backdrop:SetBackdropBorderColor(dispelColor:GetRGBA())
else
buff.backdrop:SetBackdropBorderColor(br,bg,bb,ba)
end
+6 -9
View File
@@ -758,20 +758,17 @@ pfUI:RegisterModule("chat", "vanilla:tbc", function ()
local real, _ = strsplit(":", name)
local color = unknowncolorhex
local match = false
local class
local guid = GetCurrentChatGUID()
if guid then
_, class = GetPlayerInfoByGUID(guid)
end
if not class then
_, class = C_PlayerCache.GetPlayerInfoByName(real)
end
local _, class = C_PlayerCache.GetPlayerInfoByName(real)
-- local guid = GetCurrentChatGUID()
-- if guid then
-- _, class = GetPlayerInfoByGUID(guid)
-- end
if not class then
class = GetUnitData(real)
end
if class then
if class ~= UNKNOWN then
color = rgbhex(RAID_CLASS_COLORS[class])
color = "|c" .. RAID_CLASS_COLORS[class].colorStr
match = true
end
elseif C.chat.text.whosearchunknown == "1" then
+2 -3
View File
@@ -34,9 +34,8 @@ pfUI:RegisterModule("mapcolors", function ()
local function GetTextureColor(frame)
if UnitExists(frame.unit) then
local _, class = UnitClass(frame.unit)
local color = RAID_CLASS_COLORS[class]
return color.r, color.g, color.b
local _, r, g, b = GetUnitColor(frame.unit)
return r, g, b
else
return .5, 1, .5
end
+6 -4
View File
@@ -1269,10 +1269,12 @@ end
local r, g, b, a = unpack(unitcolors[unittype])
if unittype == "ENEMY_PLAYER" and C.nameplates["enemyclassc"] == "1" and class and RAID_CLASS_COLORS[class] then
r, g, b, a = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1
elseif unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassc"] == "1" and class and RAID_CLASS_COLORS[class] then
r, g, b, a = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, 1
if class then
if unittype == "ENEMY_PLAYER" and C.nameplates["enemyclassc"] == "1" then
r, g, b, a = RAID_CLASS_COLORS[class]:GetRGBA()
elseif unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassc"] == "1" then
r, g, b, a = RAID_CLASS_COLORS[class]:GetRGBA()
end
end
if unitstr and UnitIsTapped(unitstr) and not UnitIsTappedByPlayer(unitstr) then
+1 -1
View File
@@ -533,7 +533,7 @@ pfUI:RegisterModule("thirdparty-vanilla", "vanilla", function()
hooksecurefunc("WIM_InitClassProps", function()
for class in pairs(RAID_CLASS_COLORS) do
local wimclass = _G[format("WIM_LOCALIZED_%s",class)]
local colorstr = rgbhex(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, RAID_CLASS_COLORS[class].a)
local colorstr = "|c" .. RAID_CLASS_COLORS[class].colorStr
_G.WIM_ClassColors[wimclass] = gsub(colorstr, "^|cff", "")
end
end)