Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Feb 6, 2023
2 parents d46f179 + 220cd83 commit 3cdbe2f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 244 deletions.
292 changes: 55 additions & 237 deletions BigDebuffs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1263,27 +1263,19 @@ end

BigDebuffs.AttachedFrames = {}

local MAX_BUFFS = 3
local INCREASED_MAX_BUFFS = 6

function BigDebuffs:AddBigDebuffs(frame)
if not frame or not frame.displayedUnit or not UnitIsPlayer(frame.displayedUnit) then return end
local frameName = frame:GetName()
local buffPrefix = frameName .. "Buff"

if self.db.profile.raidFrames.increaseBuffs then
CompactUnitFrame_SetMaxBuffs(frame, 6)
MAX_BUFFS = 6
end

for i = 1, MAX_BUFFS do
local buffFrame = _G[buffPrefix .. i] or
CreateFrame("Button", buffPrefix .. i, frame, "CompactBuffTemplate")

-- set size
local size = frame:GetHeight() * self.db.profile.raidFrames.buffs * 0.01
buffFrame:SetSize(size, size)
local maxBuffs = self.db.profile.raidFrames.increaseBuffs and INCREASED_MAX_BUFFS or frame.maxBuffs

if i > 3 then
for i = 1, maxBuffs do
if i > frame.maxBuffs then
local buffFrame = _G[buffPrefix .. i] or
CreateFrame("Button", buffPrefix .. i, frame, "CompactBuffTemplate")
buffFrame:ClearAllPoints()
if math.fmod(i - 1, 3) == 0 then
buffFrame:SetPoint("BOTTOMRIGHT", _G[buffPrefix .. i - 3], "TOPRIGHT")
Expand Down Expand Up @@ -1514,206 +1506,33 @@ end
local CompactUnitFrame_UtilSetDebuff = CompactUnitFrame_UtilSetDebuff

if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
local Default_CompactUnitFrame_Util_IsPriorityDebuff = CompactUnitFrame_Util_IsPriorityDebuff
local function CompactUnitFrame_Util_IsPriorityDebuff(spellId)
return BigDebuffs:IsPriorityBigDebuff(spellId) or Default_CompactUnitFrame_Util_IsPriorityDebuff(spellId)
end

local function CompactUnitFrame_ParseAllAuras(frame, displayOnlyDispellableDebuffs, ignoreBuffs, ignoreDebuffs,
ignoreDispelDebuffs)
if frame.debuffs == nil then
frame.debuffs = TableUtil.CreatePriorityTable(AuraUtil.UnitFrameDebuffComparator,
TableUtil.Constants.AssociativePriorityTable);
frame.buffs = TableUtil.CreatePriorityTable(AuraUtil.DefaultAuraCompare,
TableUtil.Constants.AssociativePriorityTable);
frame.dispels = {};
for type, _ in pairs(AuraUtil.DispellableDebuffTypes) do
frame.dispels[type] = TableUtil.CreatePriorityTable(AuraUtil.DefaultAuraCompare,
TableUtil.Constants.AssociativePriorityTable);
end
else
frame.debuffs:Clear();
frame.buffs:Clear();
for type, _ in pairs(AuraUtil.DispellableDebuffTypes) do
frame.dispels[type]:Clear();
end
end

local batchCount = nil;
local usePackedAura = true;
local function HandleAura(aura)
local type = AuraUtil.ProcessAura(aura, displayOnlyDispellableDebuffs, ignoreBuffs, ignoreDebuffs,
ignoreDispelDebuffs);

if type == AuraUtil.AuraUpdateChangedType.Debuff then
frame.debuffs[aura.auraInstanceID] = aura;
elseif type == AuraUtil.AuraUpdateChangedType.Buff then
frame.buffs[aura.auraInstanceID] = aura;
elseif type == AuraUtil.AuraUpdateChangedType.Dispel then
frame.debuffs[aura.auraInstanceID] = aura;
frame.dispels[aura.dispelName][aura.auraInstanceID] = aura;
end
end

AuraUtil.ForEachAura(frame.displayedUnit, AuraUtil.CreateFilterString(AuraUtil.AuraFilters.Harmful), batchCount,
HandleAura, usePackedAura);
AuraUtil.ForEachAura(frame.displayedUnit, AuraUtil.CreateFilterString(AuraUtil.AuraFilters.Helpful), batchCount,
HandleAura, usePackedAura);
AuraUtil.ForEachAura(frame.displayedUnit,
AuraUtil.CreateFilterString(AuraUtil.AuraFilters.Harmful, AuraUtil.AuraFilters.Raid), batchCount, HandleAura
, usePackedAura);
end

hooksecurefunc("CompactUnitFrame_UpdateAuras", function(frame, unitAuraUpdateInfo)
if (not BigDebuffs.db.profile.raidFrames.enabled) then return end
if (not frame) or frame:IsForbidden() then return end

if (not UnitIsPlayer(frame.displayedUnit)) then return end
BigDebuffs:ShowBigDebuffs(frame)

local displayOnlyDispellableDebuffs = frame.optionTable.displayOnlyDispellableDebuffs;
local ignoreBuffs = not frame.buffFrames or not frame.optionTable.displayBuffs or frame.maxBuffs == 0;
local ignoreDebuffs = not frame.debuffFrames or not frame.optionTable.displayDebuffs or frame.maxDebuffs == 0;
local ignoreDispelDebuffs = ignoreDebuffs or not frame.dispelDebuffFrames or
not frame.optionTable.displayDispelDebuffs or frame.maxDispelDebuffs == 0;

local debuffsChanged = false;
local buffsChanged = false;
local dispelsChanged = false;

if unitAuraUpdateInfo == nil or unitAuraUpdateInfo.isFullUpdate or frame.debuffs == nil then
CompactUnitFrame_ParseAllAuras(frame, displayOnlyDispellableDebuffs, ignoreBuffs, ignoreDebuffs,
ignoreDispelDebuffs);
debuffsChanged = true;
buffsChanged = true;
dispelsChanged = true;
else
if unitAuraUpdateInfo.addedAuras ~= nil then
for _, aura in ipairs(unitAuraUpdateInfo.addedAuras) do
local type = AuraUtil.ProcessAura(aura, displayOnlyDispellableDebuffs, ignoreBuffs, ignoreDebuffs,
ignoreDispelDebuffs);
if type == AuraUtil.AuraUpdateChangedType.Debuff then
frame.debuffs[aura.auraInstanceID] = aura;
debuffsChanged = true;
elseif type == AuraUtil.AuraUpdateChangedType.Buff then
frame.buffs[aura.auraInstanceID] = aura;
buffsChanged = true;
elseif type == AuraUtil.AuraUpdateChangedType.Dispel then
frame.debuffs[aura.auraInstanceID] = aura;
debuffsChanged = true;
frame.dispels[aura.dispelName][aura.auraInstanceID] = aura;
dispelsChanged = true;
end
end
end

if unitAuraUpdateInfo.updatedAuraInstanceIDs ~= nil then
for _, auraInstanceID in ipairs(unitAuraUpdateInfo.updatedAuraInstanceIDs) do
if frame.debuffs[auraInstanceID] ~= nil then
local newAura = C_UnitAuras.GetAuraDataByAuraInstanceID(frame.displayedUnit, auraInstanceID);
local oldDebuffType = frame.debuffs[auraInstanceID].debuffType;
if newAura ~= nil then
newAura.debuffType = oldDebuffType;
end
frame.debuffs[auraInstanceID] = newAura;
debuffsChanged = true;

for _, tbl in pairs(frame.dispels) do
if tbl[auraInstanceID] ~= nil then
tbl[auraInstanceID] = C_UnitAuras.GetAuraDataByAuraInstanceID(frame.displayedUnit,
auraInstanceID);
dispelsChanged = true;
break;
end
end
elseif frame.buffs[auraInstanceID] ~= nil then
local newAura = C_UnitAuras.GetAuraDataByAuraInstanceID(frame.displayedUnit, auraInstanceID);
if newAura ~= nil then
newAura.isBuff = true;
end
frame.buffs[auraInstanceID] = newAura;
buffsChanged = true;
end
end
end

if unitAuraUpdateInfo.removedAuraInstanceIDs ~= nil then
for _, auraInstanceID in ipairs(unitAuraUpdateInfo.removedAuraInstanceIDs) do
if frame.debuffs[auraInstanceID] ~= nil then
frame.debuffs[auraInstanceID] = nil;
debuffsChanged = true;

for _, tbl in pairs(frame.dispels) do
if tbl[auraInstanceID] ~= nil then
tbl[auraInstanceID] = nil;
dispelsChanged = true;
break;
end
end
elseif frame.buffs[auraInstanceID] ~= nil then
frame.buffs[auraInstanceID] = nil;
buffsChanged = true;
end
end
-- add extra buffs
local frameNum = 1
local maxBuffs = BigDebuffs.db.profile.raidFrames.increaseBuffs and INCREASED_MAX_BUFFS or frame.maxBuffs
frame.buffs:Iterate(function(auraInstanceID, aura)
if frameNum > maxBuffs then
return true
end
end

if debuffsChanged then
local frameNum = 1;
local maxDebuffs = frame.maxDebuffs;
frame.debuffs:Iterate(function(auraInstanceID, aura)
if frameNum > maxDebuffs then
return true;
end
local debuffFrame = frame.debuffFrames[frameNum];
CompactUnitFrame_UtilSetDebuff(debuffFrame, aura);
frameNum = frameNum + 1;

if aura.isBossAura then
-- Boss auras are about twice as big as normal debuffs, so we may need to display fewer buffs
local bossDebuffScale = (debuffFrame.baseSize + BOSS_DEBUFF_SIZE_INCREASE) / debuffFrame.baseSize;
maxDebuffs = maxDebuffs - (bossDebuffScale - 1);
end

return false;
end);

CompactUnitFrame_HideAllDebuffs(frame, frameNum);
end
local buffFrame = frame.buffFrames[frameNum]

if buffsChanged then
local frameNum = 1;
local maxBuffs = frame.maxBuffs;
frame.buffs:Iterate(function(auraInstanceID, aura)
if frameNum > maxBuffs then
return true;
end
local buffFrame = frame.buffFrames[frameNum];
CompactUnitFrame_UtilSetBuff(buffFrame, aura);
frameNum = frameNum + 1;

return false;
end);
-- set size
local size = frame:GetHeight() * BigDebuffs.db.profile.raidFrames.buffs * 0.01
buffFrame:SetSize(size, size)

CompactUnitFrame_HideAllBuffs(frame, frameNum);
end

if dispelsChanged then
local frameNum = 1;
local maxDispelDebuffs = frame.maxDispelDebuffs;
for _, auraTbl in pairs(frame.dispels) do
if frameNum > maxDispelDebuffs then
break;
end
if auraTbl:Size() ~= 0 then
local dispellDebuffFrame = frame.dispelDebuffFrames[frameNum];
CompactUnitFrame_UtilSetDispelDebuff(dispellDebuffFrame, auraTbl:GetTop());
frameNum = frameNum + 1;
end
-- we only need to set extra buffs
if frameNum > frame.maxBuffs then
CompactUnitFrame_UtilSetBuff(buffFrame, aura)
end
frameNum = frameNum + 1

CompactUnitFrame_HideAllDispelDebuffs(frame, frameNum);
end

BigDebuffs:ShowBigDebuffs(frame)
return false
end)
end)
else
CompactUnitFrame_UtilSetDebuff = function(debuffFrame, unit, index, filter, isBossAura, isBossBuff, ...)
Expand Down Expand Up @@ -1944,7 +1763,7 @@ else
return
end

local maxBuffs = BigDebuffs.db.profile.raidFrames.increaseBuffs and MAX_BUFFS or frame.maxBuffs
local maxBuffs = BigDebuffs.db.profile.raidFrames.increaseBuffs and INCREASED_MAX_BUFFS or frame.maxBuffs

local index = 1;
local frameNum = 1;
Expand Down Expand Up @@ -2011,8 +1830,7 @@ if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
local size = self:GetDebuffSize(aura.spellId, isDispellable)
if size and not friendlySmokeBomb then
tinsert(debuffs, { aura, size, self:GetDebuffPriority(aura.spellId) })
elseif self.db.profile.raidFrames.redirectBliz or
(self.db.profile.raidFrames.anchor == "INNER" and not self.db.profile.raidFrames.hideBliz) then
elseif self.db.profile.raidFrames.redirectBliz then
if not frame.optionTable.displayOnlyDispellableDebuffs or isDispellable then
tinsert(debuffs, { aura, self.db.profile.raidFrames.default, 0 })
end
Expand Down Expand Up @@ -2041,40 +1859,40 @@ if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
end
end

-- moved it outsdie of the check if there are any debuffs to always function as otherwise it casues a weird feeling that some buffs are appearing all of a sudden
if #debuffs < 1 then return end

-- sort by priority > size > duration > index
table.sort(debuffs, function(a, b)
if a[3] == b[3] then
if a[2] == b[2] then
return a[1].spellId > b[1].spellId
end
return a[2] > b[2]
end
return a[3] > b[3]
end)

local index = 1

if self.db.profile.raidFrames.hideBliz or
self.db.profile.raidFrames.anchor == "INNER" or
self.db.profile.raidFrames.redirectBliz then
self.db.profile.raidFrames.anchor == "INNER" or
self.db.profile.raidFrames.redirectBliz then
CompactUnitFrame_HideAllDebuffs(frame)
end

if #debuffs > 0 then
-- sort by priority > size > duration > index
table.sort(debuffs, function(a, b)
if a[3] == b[3] then
if a[2] == b[2] then
return a[1].spellId > b[1].spellId
end
return a[2] > b[2]
end
return a[3] > b[3]
end)
local index = 1

for i = 1, #debuffs do -- math.min maybe?
if index <= self.db.profile.raidFrames.maxDebuffs then
if not frame.BigDebuffs[index] then break end
local frameHeight = frame:GetHeight()
frame.BigDebuffs[index].baseSize = frameHeight * debuffs[i][2] * 0.01
local debuffFrame = frame.BigDebuffs[index];
debuffFrame.spellId = debuffs[i][1].spellId;
if not debuffFrame.maxHeight then
debuffFrame.maxHeight = frameHeight;
end
CompactUnitFrame_UtilSetDebuff(debuffFrame, debuffs[i][1])
frame.BigDebuffs[index].cooldown:SetSwipeColor(0, 0, 0, 0.7)
index = index + 1
for i = 1, #debuffs do -- math.min maybe?
if index <= self.db.profile.raidFrames.maxDebuffs then
if not frame.BigDebuffs[index] then break end
local frameHeight = frame:GetHeight()
frame.BigDebuffs[index].baseSize = frameHeight * debuffs[i][2] * 0.01
local debuffFrame = frame.BigDebuffs[index];
debuffFrame.spellId = debuffs[i][1].spellId;
if not debuffFrame.maxHeight then
debuffFrame.maxHeight = frameHeight;
end
CompactUnitFrame_UtilSetDebuff(debuffFrame, debuffs[i][1])
frame.BigDebuffs[index].cooldown:SetSwipeColor(0, 0, 0, 0.7)
index = index + 1
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions BigDebuffs_Mainline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ addon.Spells = {
[207289] = { type = BUFF_OFFENSIVE }, -- Unholy Assault
[212552] = { type = BUFF_SPEED_BOOST }, -- Wraith Walk
[219809] = { type = BUFF_DEFENSIVE }, -- Tombstone
[223929] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Necrotic Wound
[356528] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Necrotic Wound
[343294] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Soul Reaper
[377048] = { type = CROWD_CONTROL }, -- Absolute Zero
-- [91807] = { type = ROOT }, -- Shambling Rush (defined as Interrupt)
Expand Down Expand Up @@ -296,7 +296,7 @@ addon.Spells = {
[198065] = { type = BUFF_DEFENSIVE }, -- Prismatic Cloak (PvP Talent)
[205025] = { type = BUFF_OFFENSIVE }, -- Presence of Mind
[228600] = { type = ROOT }, -- Glacial Spike Root
[198121] = { type = ROOT }, -- Frostbite (Frost PvP Talent)
[378760] = { type = ROOT }, -- Frostbite
[130] = { type = BUFF_OTHER }, -- Slow Fall
[383874] = { type = BUFF_OFFENSIVE }, -- Hyperthermia
[228358] = { type = DEBUFF_OFFENSIVE }, -- Winter's Chill
Expand All @@ -315,7 +315,7 @@ addon.Spells = {
[116841] = { type = BUFF_SPEED_BOOST }, -- Tiger's Lust
[116849] = { type = BUFF_DEFENSIVE }, -- Life Cocoon
[119381] = { type = CROWD_CONTROL }, -- Leg Sweep
[324382] = { type = CROWD_CONTROL }, -- Clash
[324382] = { type = ROOT }, -- Clash
[122278] = { type = BUFF_DEFENSIVE }, -- Dampen Harm
[125174] = { type = BUFF_DEFENSIVE }, -- Touch of Karma (Buff)
[122470] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Touch of Karma (Debuff)
Expand Down Expand Up @@ -536,7 +536,7 @@ addon.Spells = {
[356738] = { type = ROOT }, -- Earth Unleashed
[285515] = { type = ROOT }, -- Surge of Power (Root)
[356824] = { type = DEBUFF_OFFENSIVE }, -- Water Unleashed
[188389] = { type = DEBUFF_OFFENSIVE, nounitframes = true, nonameplates = true }, -- Flame Shock
[188389] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Flame Shock

-- Warlock

Expand Down Expand Up @@ -572,9 +572,9 @@ addon.Spells = {
[200548] = { type = DEBUFF_OFFENSIVE, parent = 80240 }, -- Bane of Havoc (Destro PvP Talent)
[213688] = { type = CROWD_CONTROL }, -- Fel Cleave - Fel Lord stun (Demo PvP Talent)
[387633] = { type = BUFF_SPEED_BOOST }, -- Demonic Momentum (Soulburn)
[1714] = { type = DEBUFF_OFFENSIVE, nounitframes = true, nonameplates = true }, -- Curse of Tongues
[1714] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Curse of Tongues
[199954] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Bane of Fragility
[702] = { type = DEBUFF_OFFENSIVE, nounitframes = true, nonameplates = true }, -- Curse of Weakness
[702] = { type = DEBUFF_OFFENSIVE, nounitFrames = true, nonameplates = true }, -- Curse of Weakness

-- Warrior

Expand Down
Loading

0 comments on commit 3cdbe2f

Please sign in to comment.