From 1fd7895ca7c2bfe6fc1b99b47841e71a54368025 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 28 May 2026 13:06:00 -0500 Subject: [PATCH] move away from RAID_CLASS_COLORS dependency --- api/api.lua | 2 +- api/ui-widgets.lua | 6 ++--- modules/afkcam.lua | 2 +- modules/chat.lua | 5 ++-- modules/loot.lua | 18 +++++--------- modules/mapcolors.lua | 2 +- modules/nameplates.lua | 6 ++--- modules/panel.lua | 4 ++-- modules/socialmod.lua | 6 ++--- modules/thirdparty-vanilla.lua | 4 ++-- modules/tooltip.lua | 4 ++-- pfUI.lua | 44 ++++++++++++++++------------------ skins/blizzard/options-new.lua | 2 +- 13 files changed, 49 insertions(+), 56 deletions(-) diff --git a/api/api.lua b/api/api.lua index 31193ab3..1c950205 100644 --- a/api/api.lua +++ b/api/api.lua @@ -227,7 +227,7 @@ end -- return: [table] string, r, g, b function pfUI.api.GetUnitColor(unitstr) local _, class = UnitClass(unitstr) - local classColor = RAID_CLASS_COLORS[class] + local classColor = PFUI_CLASS_COLORS[class] return classColor:GenerateHexColorMarkup(), classColor:GetRGB() end diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index 1aea1b77..4d695613 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -139,7 +139,7 @@ end do -- dropdown local _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] local function ListEntryOnShow() if this.parent.id == this.id then @@ -734,7 +734,7 @@ function pfUI.api.SkinRotateButton(button) pfUI.api.CreateBackdrop(button) local _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] local cr, cg, cb = color.r , color.g, color.b button:SetWidth(button:GetWidth() - 18) @@ -939,7 +939,7 @@ function pfUI.api.SkinDropDown(frame, cr, cg, cb, useSmall) if not cr or not cg or not cb then local _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] cr, cg, cb = color.r , color.g, color.b end diff --git a/modules/afkcam.lua b/modules/afkcam.lua index 8eae6d1b..63a9904d 100644 --- a/modules/afkcam.lua +++ b/modules/afkcam.lua @@ -64,7 +64,7 @@ pfUI:RegisterModule("afkcam", function () local class = GetUnitData(arg2 or "") local author, msg if class and class ~= UNKNOWN then - local class_color = RAID_CLASS_COLORS[class]:GenerateHexColorMarkup() + local class_color = PFUI_CLASS_COLORS[class]:GenerateHexColorMarkup() author = string.format("%s%s|r",class_color,arg2) else author = arg2 diff --git a/modules/chat.lua b/modules/chat.lua index 93970bda..eacac777 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -430,7 +430,8 @@ pfUI:RegisterModule("chat", function () end local _, class = UnitClass("player") - _G["ChatFrame" .. i .. "TabText"]:SetTextColor((RAID_CLASS_COLORS[class].r + .3) * .5, (RAID_CLASS_COLORS[class].g + .3) * .5, (RAID_CLASS_COLORS[class].b + .3) * .5, 1) + local classColor = PFUI_CLASS_COLORS[class] + _G["ChatFrame" .. i .. "TabText"]:SetTextColor((classColor.r + .3) * .5, (classColor.g + .3) * .5, (classColor.b + .3) * .5, 1) _G["ChatFrame" .. i .. "TabText"]:SetFont(panelfont,panelfont_size, "OUTLINE") if _G["ChatFrame" .. i].isDocked or _G["ChatFrame" .. i]:IsVisible() then @@ -766,7 +767,7 @@ pfUI:RegisterModule("chat", function () end if class then if class ~= UNKNOWN then - color = "|c" .. RAID_CLASS_COLORS[class].colorStr + color = "|c" .. PFUI_CLASS_COLORS[class].colorStr match = true end elseif C.chat.text.whosearchunknown == "1" then diff --git a/modules/loot.lua b/modules/loot.lua index 962478ad..0f417a00 100644 --- a/modules/loot.lua +++ b/modules/loot.lua @@ -267,10 +267,8 @@ pfUI:RegisterModule("loot", function () info = wipe(info) info.text = lclass info.textR, info.textG, info.textB = .7,.7,.7 - if class and RAID_CLASS_COLORS[class] then - info.textR = RAID_CLASS_COLORS[class].r - info.textG = RAID_CLASS_COLORS[class].g - info.textB = RAID_CLASS_COLORS[class].b + if class and PFUI_CLASS_COLORS[class] then + info.textR, info.textG, info.textB = PFUI_CLASS_COLORS[class]:GetRGB() end info.textHeight = 12 info.hasArrow = 1 @@ -290,10 +288,8 @@ pfUI:RegisterModule("loot", function () info = wipe(info) info.text = candidate info.textR, info.textG, info.textB = .7,.7,.7 - if UIDROPDOWNMENU_MENU_VALUE and RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE] then - info.textR = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].r - info.textG = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].g - info.textB = RAID_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE].b + if UIDROPDOWNMENU_MENU_VALUE and PFUI_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE] then + info.textR, info.textG, info.textB = PFUI_CLASS_COLORS[UIDROPDOWNMENU_MENU_VALUE]:GetRGB() end info.textHeight = 12 info.value = name_to_index[candidate] @@ -314,10 +310,8 @@ pfUI:RegisterModule("loot", function () local unit = GroupInfoByName(candidate,"party") info.text = candidate info.textR, info.textG, info.textB = .7,.7,.7 - if unit.class and RAID_CLASS_COLORS[unit.class] then - info.textR = RAID_CLASS_COLORS[unit.class].r - info.textG = RAID_CLASS_COLORS[unit.class].g - info.textB = RAID_CLASS_COLORS[unit.class].b + if unit.class and PFUI_CLASS_COLORS[unit.class] then + info.textR, info.textG, info.textB = PFUI_CLASS_COLORS[unit.class]:GetRGB() end info.textHeight = 12 info.value = i diff --git a/modules/mapcolors.lua b/modules/mapcolors.lua index edf64c08..41ae099d 100644 --- a/modules/mapcolors.lua +++ b/modules/mapcolors.lua @@ -86,7 +86,7 @@ pfUI:RegisterModule("mapcolors", function () local function ColorizeName(frame) local _, class = UnitClass(frame.unit) - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] frame.name = frame.name or UnitName(frame.unit) frame.name = '|c'..color.colorStr..frame.name..'|r' end diff --git a/modules/nameplates.lua b/modules/nameplates.lua index c4e8d425..17412d4b 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -1215,9 +1215,9 @@ end if class then if unittype == "ENEMY_PLAYER" and C.nameplates["enemyclassc"] == "1" then - r, g, b, a = RAID_CLASS_COLORS[class]:GetRGBA() + r, g, b, a = PFUI_CLASS_COLORS[class]:GetRGBA() elseif unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassc"] == "1" then - r, g, b, a = RAID_CLASS_COLORS[class]:GetRGBA() + r, g, b, a = PFUI_CLASS_COLORS[class]:GetRGBA() end end @@ -1239,7 +1239,7 @@ end plate.cache.r, plate.cache.g, plate.cache.b = r, g, b end - if r + g + b ~= plate.cache.namecolor and unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassnamec"] == "1" and class and RAID_CLASS_COLORS[class] then + if r + g + b ~= plate.cache.namecolor and unittype == "FRIENDLY_PLAYER" and C.nameplates["friendclassnamec"] == "1" and class and PFUI_CLASS_COLORS[class] then plate.name:SetTextColor(r, g, b, a) plate.cache.namecolor = r + g + b end diff --git a/modules/panel.lua b/modules/panel.lua index e34769c6..2eb85d85 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -315,7 +315,7 @@ pfUI:RegisterModule("panel", function() GameTooltip:AddLine("|cff555555" .. T["Friends Online"]) init = true end - local ccolor = RAID_CLASS_COLORS[L["class"][friend_class]] or { 1, 1, 1 } + local ccolor = PFUI_CLASS_COLORS[L["class"][friend_class]] or { 1, 1, 1 } local lcolor = GetDifficultyColor(tonumber(friend_level)) or { 1, 1, 1 } local zcolor = friend_area == playerzone and "|cff33ffcc" or "|cffcccccc" GameTooltip:AddDoubleLine(rgbhex(ccolor) .. friend_name .. rgbhex(lcolor) .. " [" .. friend_level .. "]", zcolor .. friend_area) @@ -375,7 +375,7 @@ pfUI:RegisterModule("panel", function() init = true end - local ccolor = RAID_CLASS_COLORS[L["class"][class]] or { 1, 1, 1 } + local ccolor = PFUI_CLASS_COLORS[L["class"][class]] or { 1, 1, 1 } local lcolor = GetDifficultyColor(tonumber(level)) or { 1, 1, 1 } local level = "|cff555555" .. "[" .. rgbhex(lcolor) .. level .. "|cff555555]" local raid = raidparty[name] and "|cff555555[|cff33ffccG|cff555555]|r" or "" diff --git a/modules/socialmod.lua b/modules/socialmod.lua index 63ae410c..4cf14cf3 100644 --- a/modules/socialmod.lua +++ b/modules/socialmod.lua @@ -19,7 +19,7 @@ pfUI:RegisterModule("socialmod", function () if name then if class then - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] local classicon = _G["GuildFrameButton"..i].classicon local coords = CLASS_ICON_TCOORDS[class] @@ -86,7 +86,7 @@ pfUI:RegisterModule("socialmod", function () if connected then if not class or class == _G.UNKNOWN then break end - local ccolor = RAID_CLASS_COLORS[L["class"][class]] or { 1, 1, 1 } + local ccolor = PFUI_CLASS_COLORS[L["class"][class]] or { 1, 1, 1 } local lcolor = GetDifficultyColor(tonumber(level)) or { 1, 1, 1 } zone = ( zone == playerzone and "|cffffffff" or "|cffcccccc" ) .. zone .. "|r" @@ -172,7 +172,7 @@ pfUI:RegisterModule("socialmod", function () if class then local classicon = _G["WhoFrameButton"..i].classicon local coords = CLASS_ICON_TCOORDS[class] - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] -- do we have classicons? (skin enabled?) if classicon then diff --git a/modules/thirdparty-vanilla.lua b/modules/thirdparty-vanilla.lua index 549c9a48..b4e47b84 100644 --- a/modules/thirdparty-vanilla.lua +++ b/modules/thirdparty-vanilla.lua @@ -531,9 +531,9 @@ pfUI:RegisterModule("thirdparty-vanilla", function() -- replace wim class colors with pfUI ones hooksecurefunc("WIM_InitClassProps", function() - for class in pairs(RAID_CLASS_COLORS) do + for class in pairs(PFUI_CLASS_COLORS) do local wimclass = _G[format("WIM_LOCALIZED_%s",class)] - local colorstr = "|c" .. RAID_CLASS_COLORS[class].colorStr + local colorstr = "|c" .. PFUI_CLASS_COLORS[class].colorStr _G.WIM_ClassColors[wimclass] = gsub(colorstr, "^|cff", "") end end) diff --git a/modules/tooltip.lua b/modules/tooltip.lua index b867c89a..251fd8ff 100644 --- a/modules/tooltip.lua +++ b/modules/tooltip.lua @@ -200,7 +200,7 @@ pfUI:RegisterModule("tooltip", function () if name then if UnitIsPlayer(unit) and class then - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] GameTooltipStatusBar:SetStatusBarColor_orig(color:GetRGB()) GameTooltip:SetBackdropBorderColor(color:GetRGB()) GameTooltipTextLeft1:SetText("|c" .. color.colorStr .. name) @@ -229,7 +229,7 @@ pfUI:RegisterModule("tooltip", function () local _, targetClass = UnitClass(unit .. "target") local targetReaction = UnitReaction("player",unit .. "target") if UnitIsPlayer(unit .. "target") and targetClass then - local color = RAID_CLASS_COLORS[targetClass] + local color = PFUI_CLASS_COLORS[targetClass] GameTooltip:AddLine(target, color.r, color.g, color.b) elseif targetReaction then local color = UnitReactionColor[targetReaction] diff --git a/pfUI.lua b/pfUI.lua index c0b07cfe..58a18009 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -37,8 +37,7 @@ if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then alertFrame:RegisterEvent("PLAYER_LOGIN") alertFrame:SetScript("OnEvent", function() StaticPopupDialogs["PFUI_CLASSICAPI_REQUIRED"] = { - text = "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI\n v1.2.0 or newer.\n\n" - .. "All |cff33ffccpf|cffffffffUI|r modules have been disabled.\nInstall ClassicAPI from:", + text = "This fork of |cff33ffccpf|cffffffffUI|r requires ClassicAPI\n v1.2.0 or newer.\n\nAll |cff33ffccpf|cffffffffUI|r modules have been disabled.\nInstall ClassicAPI from:", button1 = OKAY, hasEditBox = 1, editBoxWidth = 280, @@ -58,8 +57,7 @@ if not CLASSIC_API_VERSION or CLASSIC_API_VERSION < PFUI_CLASSIC_API_MIN then StaticPopup_Show("PFUI_CLASSICAPI_REQUIRED") if DEFAULT_CHAT_FRAME then DEFAULT_CHAT_FRAME:AddMessage( - "This fork of pfUI requires ClassicAPI v1.2.0+. Get it at " - .. "https://github.com/brues-code/ClassicAPI", + "This fork of pfUI requires ClassicAPI v1.2.0+. Get it at https://github.com/brues-code/ClassicAPI", 1, 0.3, 0.3 ) end @@ -129,23 +127,26 @@ pfUI.client = client or 11200 -- setup pfUI namespace setmetatable(pfUI.env, {__index = getfenv(0)}) -function pfUI:UpdateColors() - -- update table to get unknown colors and blue shamans for vanilla - RAID_CLASS_COLORS = { - ["WARRIOR"] = { r = 0.78, g = 0.61, b = 0.43, colorStr = "ffc79c6e" }, - ["MAGE"] = { r = 0.41, g = 0.8, b = 0.94, colorStr = "ff69ccf0" }, - ["ROGUE"] = { r = 1, g = 0.96, b = 0.41, colorStr = "fffff569" }, - ["DRUID"] = { r = 1, g = 0.49, b = 0.04, colorStr = "ffff7d0a" }, - ["HUNTER"] = { r = 0.67, g = 0.83, b = 0.45, colorStr = "ffabd473" }, - ["SHAMAN"] = { r = 0.14, g = 0.35, b = 1.0, colorStr = "ff0070de" }, - ["PRIEST"] = { r = 1, g = 1, b = 1, colorStr = "ffffffff" }, - ["WARLOCK"] = { r = 0.58, g = 0.51, b = 0.79, colorStr = "ff9482c9" }, - ["PALADIN"] = { r = 0.96, g = 0.55, b = 0.73, colorStr = "fff58cba" }, - } +PFUI_CLASS_COLORS = setmetatable({ + WARRIOR = { r = 0.78, g = 0.61, b = 0.43 }, + MAGE = { r = 0.25, g = 0.78, b = 0.92 }, + ROGUE = { r = 1, g = 0.96, b = 0.41 }, + DRUID = { r = 1, g = 0.49, b = 0.04 }, + HUNTER = { r = 0.67, g = 0.83, b = 0.45 }, + SHAMAN = { r = 0, g = 0.44, b = 0.87 }, + PRIEST = { r = 1, g = 1, b = 1 }, + WARLOCK = { r = 0.53, g = 0.53, b = 0.93 }, + PALADIN = { r = 0.96, g = 0.55, b = 0.73 }, +}, { __index = function(t,k) + local unknownColor = CreateColor(0.6, 0.6, 0.6, 1) + unknownColor.colorStr = unknownColor:GenerateHexColor() + return unknownColor +end}) - RAID_CLASS_COLORS = setmetatable(RAID_CLASS_COLORS, { __index = function(tab,key) - return { r = 0.6, g = 0.6, b = 0.6, colorStr = "ff999999" } - end}) +for _, classColor in pairs(PFUI_CLASS_COLORS) do + Mixin(classColor, ColorMixin) + classColor.a = 1 + classColor.colorStr = classColor:GenerateHexColor() end function pfUI:UpdateFonts() @@ -381,9 +382,6 @@ end pfUI:SetScript("OnEvent", function() if pfUI.disabled then return end - -- enforce color updates on each event - pfUI:UpdateColors() - -- make sure to initialize and set our fonts -- each time an addon got loaded but only -- when the config is already accessible diff --git a/skins/blizzard/options-new.lua b/skins/blizzard/options-new.lua index d6672184..6cacba80 100644 --- a/skins/blizzard/options-new.lua +++ b/skins/blizzard/options-new.lua @@ -106,7 +106,7 @@ pfUI:RegisterSkin("Options - New", function () btn:SetBackdropColor(br, bg, bb, 0.75) btn:SetBackdropBorderColor(er, eg, eb, 1) local _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] + local color = PFUI_CLASS_COLORS[class] SetHighlight(btn, color.r, color.g, color.b) btn:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE") HookScript(btn, "OnMouseDown", function()