diff --git a/Options/modules/statuses/StatusAuraDebuffs.lua b/Options/modules/statuses/StatusAuraDebuffs.lua index 6ac1aaec..db181229 100644 --- a/Options/modules/statuses/StatusAuraDebuffs.lua +++ b/Options/modules/statuses/StatusAuraDebuffs.lua @@ -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", @@ -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", @@ -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", @@ -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"], @@ -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", @@ -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 @@ -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"], @@ -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", @@ -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"], @@ -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", @@ -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 @@ -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 @@ -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 diff --git a/modules/StatusAuras.lua b/modules/StatusAuras.lua index d9d44240..35070c7a 100644 --- a/modules/StatusAuras.lua +++ b/modules/StatusAuras.lua @@ -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 @@ -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 @@ -64,7 +64,7 @@ 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 @@ -72,7 +72,7 @@ do 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 @@ -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 @@ -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 diff --git a/modules/StatusAurasDebuffs.lua b/modules/StatusAurasDebuffs.lua index 01dd3473..e2395346 100644 --- a/modules/StatusAurasDebuffs.lua +++ b/modules/StatusAurasDebuffs.lua @@ -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 = {} @@ -16,6 +17,7 @@ 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 ]] @@ -23,33 +25,72 @@ 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 @@ -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 @@ -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