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