From be00feaf85f157706b2cddc8e08bb19452155b6a Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 17 Apr 2018 19:40:43 +0200 Subject: [PATCH] buff: use class colors on unbuffed units --- api/api.lua | 15 +++++++++++++++ api/unitframes.lua | 6 +++--- modules/buff.lua | 6 +++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/api/api.lua b/api/api.lua index 64922594..974685ae 100644 --- a/api/api.lua +++ b/api/api.lua @@ -51,6 +51,21 @@ function pfUI.api.UnitHasBuff(unit, buff) return hasbuff end +-- [[ GetUnitColor ]] +-- Returns an escape string for the unit aswell as the RGB values +-- unit [string] the unitstring +-- 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 string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255), r, g, b +end + -- [ strvertical ] -- Creates vertical text using linebreaks. Multibyte char friendly. -- 'str' [string] String to columnize. diff --git a/api/unitframes.lua b/api/unitframes.lua index 71311d73..25f46b54 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -402,20 +402,20 @@ function pfUI.uf:UpdateConfig() for i=1,40 do local unitstr = "raid" .. i if not UnitHasBuff(unitstr, texture) and UnitName(unitstr) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName(unitstr) + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName(unitstr) .. "|r" first = nil end end else if not UnitHasBuff("player", texture) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName("player") + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName("player") .. "|r" first = nil end for i=1,4 do local unitstr = "party" .. i if not UnitHasBuff(unitstr, texture) and UnitName(unitstr) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName(unitstr) + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName(unitstr) .. "|r" first = nil end end diff --git a/modules/buff.lua b/modules/buff.lua index 23c3c730..e393c969 100644 --- a/modules/buff.lua +++ b/modules/buff.lua @@ -120,20 +120,20 @@ pfUI:RegisterModule("buff", function () for i=1,40 do local unitstr = "raid" .. i if not UnitHasBuff(unitstr, texture) and UnitName(unitstr) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName(unitstr) + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName(unitstr) .. "|r" first = nil end end else if not UnitHasBuff("player", texture) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName("player") + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName("player") .. "|r" first = nil end for i=1,4 do local unitstr = "party" .. i if not UnitHasBuff(unitstr, texture) and UnitName(unitstr) then - playerlist = playerlist .. ( not first and ", " or "") .. UnitName(unitstr) + playerlist = playerlist .. ( not first and ", " or "") .. GetUnitColor(unitstr) .. UnitName(unitstr) .. "|r" first = nil end end