Skip to content

Commit

Permalink
BugFix: Auras dispell Type management was broken (github issue #199)
Browse files Browse the repository at this point in the history
Feature: Added Relevant/Non-Relevant debuffs filter to debuffs groups.
  • Loading branch information
michaelnpsp committed Jan 23, 2024
1 parent db57d29 commit a65cb9c
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 53 deletions.
110 changes: 70 additions & 40 deletions Options/modules/statuses/StatusAuraDebuffs.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local L = Grid2Options.L

function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionParams)
local IsHidden = function () return status.dbx.useWhiteList end
self:MakeHeaderOptions( options, "Display" )
options.strictFiltering = {
type = "toggle",
Expand All @@ -13,7 +14,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
status.dbx.lazyFiltering = (not v) or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end,
hidden = IsHidden,
}
options.showDispelDebuffs = {
type = "toggle",
Expand All @@ -33,7 +34,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.showNonDispelDebuffs = {
type = "toggle",
Expand All @@ -49,9 +50,9 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterTyped = { type = "description", name = "", order = 83 }
options.filterTyped = { type = "description", name = "", order = 83, hidden = IsHidden }
options.showTypedDebuffs = {
type = "toggle",
name = L["Typed Debuffs"],
Expand All @@ -62,7 +63,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
status.dbx.filterTyped = (not v) or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.showUntypedDebuffs = {
type = "toggle",
Expand All @@ -78,14 +79,26 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterBoss = { type = "description", name = "", order = 84, hidden = IsHidden }
options.showBossDebuffs = {
type = "toggle",
name = L["Boss Debuffs"],
desc = L["Display debuffs direct casted by Bosses"],
order = 84.1,
get = function () return status.dbx.filterBossDebuffs~=true end,
set = function (_, v)
status.dbx.filterBossDebuffs = (not v) or nil
status:Refresh()
end,
hidden = IsHidden,
}
options.filterBoss = { type = "description", name = "", order = 84 }
options.showNonBossDebuffs = {
type = "toggle",
name = L["Non Boss Debuffs"],
desc = L["Display debuffs not casted by Bosses"],
order = 84.1,
order = 84.2,
get = function () return status.dbx.filterBossDebuffs~=false end,
set = function (_, v)
if v then
Expand All @@ -95,21 +108,9 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
}
options.showBossDebuffs = {
type = "toggle",
name = L["Boss Debuffs"],
desc = L["Display debuffs direct casted by Bosses"],
order = 84.2,
get = function () return status.dbx.filterBossDebuffs~=true end,
set = function (_, v)
status.dbx.filterBossDebuffs = (not v) or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterPerma = { type = "description", name = "", order = 85 }
options.filterPerma = { type = "description", name = "", order = 85, hidden = IsHidden }
options.showTempDebuffs = {
type = "toggle",
name = L["Temporary Debuffs"],
Expand All @@ -124,7 +125,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.showPermaDebuffs = {
type = "toggle",
Expand All @@ -136,9 +137,9 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
status.dbx.filterPermaDebuffs = (not v) and true or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterLong = { type = "description", name = "", order = 86 }
options.filterLong = { type = "description", name = "", order = 86, hidden = IsHidden }
options.showShortDebuffs = {
type = "toggle",
name = L["Short Duration"],
Expand All @@ -153,7 +154,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.showLongDebuffs = {
type = "toggle",
Expand All @@ -165,14 +166,26 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
status.dbx.filterLongDebuffs = (not v) and true or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterSelf = { type = "description", name = "", order = 87, hidden = IsHidden }
options.showSelfDebuffs = {
type = "toggle",
name = L["Self Casted"],
desc = L["Display self debuffs"],
order = 87.1,
get = function () return status.dbx.filterCaster~=true end,
set = function (_, v)
status.dbx.filterCaster = (not v) and true or nil
status:Refresh()
end,
hidden = IsHidden,
}
options.filterSelf = { type = "description", name = "", order = 87 }
options.showNonSelfDebuffs = {
type = "toggle",
name = L["Non Self Casted"],
desc = L["Display non self debuffs"],
order = 87.1,
order = 87.2,
get = function () return status.dbx.filterCaster~=false end,
set = function (_, v)
if v then
Expand All @@ -182,26 +195,43 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
end
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.showSelfDebuffs = {
options.filterRelevant = { type = "description", name = "", order = 88, hidden = IsHidden }
options.relevantDebuffs = {
type = "toggle",
name = L["Self Casted"],
desc = L["Display self debuffs"],
order = 87.2,
get = function () return status.dbx.filterCaster~=true end,
name = L["Relevant Debuffs"],
desc = L["Display debuffs marked as relevant by blizzard designers."],
order = 88.1,
get = function () return status.dbx.filterRelevant~=true end,
set = function (_, v)
status.dbx.filterCaster = (not v) and true or nil
status.dbx.filterRelevant = (not v) and true or nil
status:Refresh()
end,
hidden = function() return status.dbx.useWhiteList end
hidden = IsHidden,
}
options.filterList = { type = "description", name = "", order = 88 }
options.nonrelevantDebuffs = {
type = "toggle",
name = L["Non-Relevant Debuffs"],
desc = L["Display debuffs marked as non-relevant by blizzard designers."],
order = 88.2,
get = function () return status.dbx.filterRelevant~=false end,
set = function (_, v)
if v then
status.dbx.filterRelevant = nil
else
status.dbx.filterRelevant = false
end
status:Refresh()
end,
hidden = IsHidden,
}
options.filterList = { type = "description", name = "", order = 89, hidden = IsHidden }
options.useWhiteList = {
type = "toggle",
name = L["Whitelist"],
desc = L["Display only debuffs contained in a user defined list."],
order = 88.1,
order = 89.1,
get = function () return status.dbx.useWhiteList and status.dbx.auras~=nil end,
set = function (_, v)
status.dbx.filterDispelDebuffs = nil
Expand All @@ -226,7 +256,7 @@ function Grid2Options:MakeStatusDebuffsFilterOptions(status, options, optionPara
type = "toggle",
name = L["Blacklist"],
desc = L["Ignore debuffs contained in a user defined list. This condition is always strict."],
order = 88.2,
order = 89.2,
get = function () return (not status.dbx.useWhiteList) and status.dbx.auras~=nil end,
set = function (_, v)
if v then
Expand Down
12 changes: 7 additions & 5 deletions modules/StatusAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ do
local a, nam, tex, cnt, typ, dur, exp, cas, sid, bos, _
local GetAura = GetAuraDataByIndex and function(unit, index, filter) -- for retail
a = GetAuraDataByIndex(unit, index, filter)
if a then fill, nam, sid, cas = true, a.name, a.spellId, a.sourceUnit; return true; end
if a then fill, nam, typ, cas, sid = true, a.name, a.dispelName, a.sourceUnit, a.spellId; return true; end
end or function(unit, index, filter) -- for classic
nam, tex, cnt, typ, dur, exp, cas, _, _, sid, _, bos, _, _, _, val[1], val[2], val[3] = UnitAura(unit, index, filter)
if nam then if cnt==0 then cnt=1 end; return true end
Expand All @@ -51,7 +51,7 @@ do
for s in next, statuses do
local mine = s.isMine
if mine==false or mine==myUnits[cas] then
if fill then fill, tex, cnt, typ, dur, exp, bos, val[s.vId] = false, a.icon, max(a.applications,1), a.dispelName, a.duration, a.expirationTime, a.isBossAura, a.points[s.vId] end
if fill then fill, tex, cnt, dur, exp, bos, val[s.vId] = false, a.icon, max(a.applications,1), a.duration, a.expirationTime, a.isBossAura, a.points[s.vId] end
if s.UpdateState then
s:UpdateState(u, i, sid, nam, tex, cnt, dur, exp, typ)
elseif exp~=s.exp[u] or cnt~=s.cnt[u] or val[s.vId]~=s.val[u] then
Expand All @@ -64,15 +64,15 @@ do
end
local s = DebuffTypes[typ or 'Typeless']
if s and not s.seen and not (s.debuffFilter and s.debuffFilter[nam]) then
if fill then fill, tex, cnt, typ, dur, exp, bos = false, a.icon, max(a.applications,1), a.dispelName, a.duration, a.expirationTime, a.isBossAura end
if fill then fill, tex, cnt, dur, exp, bos = false, a.icon, max(a.applications,1), a.duration, a.expirationTime, a.isBossAura end
if exp~=s.exp[u] or cnt~=s.cnt[u] then
s.seen, s.idx[u], s.tex[u], s.cnt[u], s.dur[u], s.exp[u] = 1, i, tex, cnt, dur, exp
else
s.seen, s.idx[u] = -1, i
end
end
for s, update in next, DebuffGroups do
if fill then fill, tex, cnt, typ, dur, exp, bos = false, a.icon, max(a.applications,1), a.dispelName, a.duration, a.expirationTime, a.isBossAura end
if fill then fill, tex, cnt, dur, exp, bos = false, a.icon, max(a.applications,1), a.duration, a.expirationTime, a.isBossAura end
if (update or not s.seen) and s:UpdateState(u, sid, nam, cnt, dur, cas, bos, typ) then
s.seen, s.idx[u], s.tex[u], s.cnt[u], s.dur[u], s.exp[u], s.typ[u], s.tkr[u] = 1, i, tex, cnt, dur, exp, typ, 1
end
Expand All @@ -87,7 +87,7 @@ do
for s in next, statuses do
local mine = s.isMine
if (mine==false or mine==myUnits[cas]) and s.seen~=1 then
if fill then fill, tex, cnt, typ, dur, exp, bos, val[s.vId] = false, a.icon, max(a.applications,1), a.dispelName, a.duration, a.expirationTime, a.isBossAura, a.points[s.vId] end
if fill then fill, tex, cnt, dur, exp, bos, val[s.vId] = false, a.icon, max(a.applications,1), a.duration, a.expirationTime, a.isBossAura, a.points[s.vId] end
if s.UpdateState then
s:UpdateState(u, i, sid, nam, tex, cnt, dur, exp)
elseif exp~=s.exp[u] or s.cnt[u]~=cnt or val[s.vId]~=s.val[u] or s.spells then
Expand Down Expand Up @@ -458,11 +458,13 @@ do
RegisterTimeTrackerStatus(self, self.dbx.colorThresholdElapsed)
end
UpdateAllAuras()
if self.OnEnableAura then self:OnEnableAura() end
end
local function OnDisable(self)
UnregisterStatusAura(self, self.handlerType, self.dbx.subType)
UnregisterTimeTrackerStatus(self)
wipe(self.idx); wipe(self.exp); wipe(self.val)
if self.OnDisableAura then self:OnDisableAura() end
end
local function UpdateStateCombineStacks(s, u, i, sid, nam, tex, cnt, dur, exp, typ)
if s.seen then -- adding extra debuffs stacks
Expand Down
59 changes: 51 additions & 8 deletions modules/StatusAurasDebuffs.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- Group of Debuffs status
local Grid2 = Grid2
local wipe = wipe
local SpellGetVisibilityInfo = SpellGetVisibilityInfo
local UnitAura = Grid2.UnitAuraLite
local typeColors = Grid2.debuffTypeColors
local wipe = wipe

local emptyTable = {}
local textures = {}
Expand All @@ -16,40 +17,80 @@ local spells = {}
local code_standard = [[
local spells = Grid2.statuses["%s"].spells
local dispel = Grid2.debuffPlayerDispelTypes
local IsRelevantDebuff = Grid2.IsRelevantDebuff
return function(self, unit, sid, name, count, duration, caster, boss, typ)
return %s
end ]]

local code_stacks = [[
local spells = Grid2.statuses["%s"].spells
local dispel = Grid2.debuffPlayerDispelTypes
local IsRelevantDebuff = Grid2.IsRelevantDebuff
return function(self, unit, sid, name, count, duration, caster, boss, typ)
if not (%s) then return end
if not self.seen then self.currentName=name; return true; end
if name==self.currentName then self.cnt[unit] = self.cnt[unit] + count; end
end ]]

-- code to manage dbx.filterRelevant debuffs filter
local raidFilter = "RAID_OUTOFCOMBAT"
local raid_statuses = {}

function Grid2.IsRelevantDebuff(spellId, caster)
local hasCustom, alwaysShowMine, showForMySpec = SpellGetVisibilityInfo(spellId, raidFilter)
return not hasCustom or showForMySpec or (alwaysShowMine and (caster=="player" or caster=="pet" or caster=="vehicle"))
end

local function UpdateRaidStatuses(event)
local newFilter = (event=='PLAYER_REGEN_DISABLED') and "RAID_INCOMBAT" or "RAID_OUTOFCOMBAT"
if newFilter~=raidFilter then
raidFilter = newFilter
for status in next, raid_statuses do
status:UpdateAllUnits()
end
end
end

local function status_OnEnableAura(self)
if not next(raid_statuses) then
self:RegisterEvent("PLAYER_REGEN_ENABLED", UpdateRaidStatuses)
self:RegisterEvent("PLAYER_REGEN_DISABLED", UpdateRaidStatuses)
end
raid_statuses[self] = true
end

local function status_OnDisableAura(self)
raid_statuses[self] = nil
if not next(raid_statuses) then
self:UnregisterEvent("PLAYER_REGEN_ENABLED", UpdateRaidStatuses)
self:UnregisterEvent("PLAYER_REGEN_DISABLED", UpdateRaidStatuses)
end
end

-- Compile a filter function, the function is called from StatusAura.lua to filter auras
local function CompileUpdateStateFilter(self, lazy, useSpellId, code)
local dbx = self.dbx
local t = {}
if dbx.filterDispelDebuffs~=nil then
t[#t+1] = string.format( "%s dispel[typ]", dbx.filterDispelDebuffs and '' or 'not')
t[#t+1] = string.format("%s dispel[typ]", dbx.filterDispelDebuffs and '' or 'not')
end
if dbx.filterLongDebuffs~=nil then
t[#t+1] = string.format( "%s (duration>=300)", dbx.filterLongDebuffs and 'not' or '')
t[#t+1] = string.format("%s (duration>=300)", dbx.filterLongDebuffs and 'not' or '')
end
if dbx.filterPermaDebuffs~=nil then
t[#t+1] = string.format( "%s (duration==0)", dbx.filterPermaDebuffs and 'not' or '')
t[#t+1] = string.format("%s (duration==0)", dbx.filterPermaDebuffs and 'not' or '')
end
if dbx.filterBossDebuffs~=nil then
t[#t+1] = string.format( "%s boss", dbx.filterBossDebuffs and 'not' or '')
t[#t+1] = string.format("%s boss", dbx.filterBossDebuffs and 'not' or '')
end
if dbx.filterCaster~=nil then
t[#t+1] = string.format( "%s (caster=='player' or caster=='pet' or caster=='vehicle')", dbx.filterCaster and 'not' or '')
t[#t+1] = string.format("%s (caster=='player' or caster=='pet' or caster=='vehicle')", dbx.filterCaster and 'not' or '')
end
if dbx.filterTyped~=nil then
t[#t+1] = string.format( "%s typ", dbx.filterTyped and 'not' or '')
t[#t+1] = string.format( "%s typ", dbx.filterTyped and 'not' or '' )
end
if dbx.filterRelevant~=nil then
t[#t+1] = string.format( "%s IsRelevantDebuff(sid, caster)", dbx.filterRelevant and 'not' or '' )
end
local q -- special case for black/white lists because they are always strict (non lazy).
if dbx.useWhiteList then
Expand Down Expand Up @@ -129,6 +170,8 @@ local function status_Update(self, dbx)
self.CheckState = nil
self.GetIcons = status_GetIconsFilterStandard
end
self.OnEnableAura = dbx.filterRelevant~=nil and status_OnEnableAura or nil
self.OnDisableAura = dbx.filterRelevant~=nil and status_OnDisableAura or nil
end

-- Registration
Expand All @@ -141,7 +184,7 @@ do
if dbx.spellName then -- fix possible wrong data in old database
dbx.spellName = nil
end
local status = Grid2.statusPrototype:new(baseKey, false)
local status = Grid2.statusPrototype:new(baseKey)
status.OnUpdate = status_Update
return Grid2.CreateStatusAura(status, basekey, dbx, 'debuff', statusTypes)
end
Expand Down

0 comments on commit a65cb9c

Please sign in to comment.