UnitAUra cleanup

This commit is contained in:
Brues
2026-05-18 23:42:51 -05:00
parent b9343ec601
commit 82743b0f9a
3 changed files with 45 additions and 95 deletions
+26 -9
View File
@@ -181,20 +181,37 @@ function pfUI.api.RunOOC(func)
end
-- [ UnitHasBuff ]
-- Returns whether a unit has the given buff or not.
-- Returns whether a unit has the named buff or not.
-- unit [string] A unit to query (string, unitID)
-- buff [string] The texture of the buff.
-- name [string] The localized name of the buff.
-- return: [bool] true if unit has buff otherwise "nil"
function pfUI.api.UnitHasBuff(unit, buff)
local hasbuff = nil
for i=1,32 do
if UnitBuff(unit, i) == buff then
hasbuff = true
break
function pfUI.api.UnitHasBuff(unit, name)
for _, aura in ipairs(C_UnitAuras.GetUnitAuras(unit, "HELPFUL")) do
if aura.name == name then return true end
end
return nil
end
-- [ GetUnbuffedRoster ]
-- Returns a comma-joined, colored list of group members missing the named aura.
-- name [string] the localized aura name to check for
-- return: [string] comma-joined list, empty string if everyone has it
function pfUI.api.GetUnbuffedRoster(name)
local missing = {}
local function check(unit)
if UnitName(unit) and not pfUI.api.UnitHasBuff(unit, name) then
table.insert(missing, GetUnitColor(unit) .. UnitName(unit) .. "|r")
end
end
return hasbuff
if UnitInRaid("player") then
for i=1,40 do check("raid"..i) end
else
check("player")
for i=1,4 do check("party"..i) end
end
return table.concat(missing, ", ")
end
-- [[ GetUnitColor ]]
+4 -36
View File
@@ -99,45 +99,13 @@ local function BuffOnEnter()
local parent = this:GetParent()
if not parent.label then return end
local unit = parent.label .. parent.id
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
if parent.label == "player" then
GameTooltip:SetPlayerBuff(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL"))
else
GameTooltip:SetUnitBuff(parent.label .. parent.id, this.id)
end
GameTooltip:SetUnitAura(unit, this.id, "HELPFUL")
if IsShiftKeyDown() then
local texture = parent.label == "player" and GetPlayerBuffTexture(GetPlayerBuff(PLAYER_BUFF_START_ID+this.id,"HELPFUL")) or UnitBuff(parent.label .. parent.id, this.id)
-- slot is empty, nothing to compare against
if not texture then return end
local playerlist = ""
local first = true
if UnitInRaid("player") then
for i=1,40 do
local unitstr = "raid" .. i
if not UnitHasBuff(unitstr, texture) and UnitName(unitstr) then
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 "") .. GetUnitColor("player") .. 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 "") .. GetUnitColor(unitstr) .. UnitName(unitstr) .. "|r"
first = nil
end
end
end
local aura = C_UnitAuras.GetAuraDataByIndex(unit, this.id, "HELPFUL")
local playerlist = aura and GetUnbuffedRoster(aura.name) or ""
if strlen(playerlist) > 0 then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(T["Unbuffed"] .. ":", .3, 1, .8)