diff --git a/api/api.lua b/api/api.lua index 71d2d097..64922594 100644 --- a/api/api.lua +++ b/api/api.lua @@ -34,6 +34,23 @@ function pfUI.api.UnitInRange(unit) end end +-- [ UnitHasBuff ] +-- Returns whether a unit has the given buff or not. +-- unit [string] A unit to query (string, unitID) +-- buff [string] The texture 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 + end + end + + return hasbuff +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 7ca73cb4..ba975f68 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -382,13 +382,51 @@ function pfUI.uf:UpdateConfig() end f.buffs[i]:SetScript("OnEnter", function() - if not this:GetParent().label then return end + local parent = this:GetParent() + if not parent.label then return end GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - if this:GetParent().label == "player" then + if parent.label == "player" then GameTooltip:SetPlayerBuff(GetPlayerBuff(id-1,"HELPFUL")) else - GameTooltip:SetUnitBuff(this:GetParent().label .. this:GetParent().id, id) + GameTooltip:SetUnitBuff(parent.label .. parent.id, id) + end + + if IsShiftKeyDown() then + local texture = parent.label == "player" and GetPlayerBuffTexture(GetPlayerBuff(id-1,"HELPFUL")) or UnitBuff(parent.label .. parent.id, id) + + 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 "") .. UnitName(unitstr) + first = nil + end + end + else + if not UnitHasBuff("player", texture) then + playerlist = playerlist .. ( not first and ", " or "") .. UnitName("player") + 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) + first = nil + end + end + end + + if strlen(playerlist) > 0 then + GameTooltip:AddLine(" ") + GameTooltip:AddLine(T["Unbuffed"] .. ":", .3, 1, .8) + GameTooltip:AddLine(playerlist,1,1,1,1) + GameTooltip:Show() + end end end) diff --git a/modules/buff.lua b/modules/buff.lua index 188df6e3..23c3c730 100644 --- a/modules/buff.lua +++ b/modules/buff.lua @@ -109,6 +109,43 @@ pfUI:RegisterModule("buff", function () GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") if this.mode == this.btype then GameTooltip:SetPlayerBuff(this.bid) + + if IsShiftKeyDown() then + local texture = GetPlayerBuffTexture(this.bid) + + 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 "") .. UnitName(unitstr) + first = nil + end + end + else + if not UnitHasBuff("player", texture) then + playerlist = playerlist .. ( not first and ", " or "") .. UnitName("player") + 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) + first = nil + end + end + end + + if strlen(playerlist) > 0 then + GameTooltip:AddLine(" ") + GameTooltip:AddLine(T["Unbuffed"] .. ":", .3, 1, .8) + GameTooltip:AddLine(playerlist,1,1,1,1) + GameTooltip:Show() + end + end elseif this.mode == "MAINHAND" then GameTooltip:SetInventoryItem("player", 16) elseif this.mode == "OFFHAND" then