fix import for TW and general issue with BuffsDebuffs

This commit is contained in:
Sumsebrum 2021-09-18 13:15:27 +02:00
parent 94efa7a112
commit 01f907f71c
2 changed files with 45 additions and 12 deletions

View File

@ -7,6 +7,7 @@ LibClassAuras.debuffs = {}
LibClassAuras.debuffToId = {} LibClassAuras.debuffToId = {}
LibClassAuras.buffs = {} LibClassAuras.buffs = {}
LibClassAuras.buffToId = {} LibClassAuras.buffToId = {}
LibClassAuras.altNames = {}
local function Spell(id, opts, class, spellTable, idTable) local function Spell(id, opts, class, spellTable, idTable)
if not opts or not class then if not opts or not class then
@ -26,9 +27,20 @@ local function Spell(id, opts, class, spellTable, idTable)
return return
end end
if opts.altName then if opts.altName then
idTable[opts.altName] = {id = id , class = class} for _,v in ipairs(id) do
LibClassAuras.altNames[v] = opts.altName
end
if idTable[opts.altName] then
tinsert(idTable[opts.altName], {id = id , class = class})
else
idTable[opts.altName] = {[1] = {id = id , class = class}}
end
else else
idTable[spellName] = {id = id , class = class} if idTable[spellName] then
tinsert(idTable[spellName], {id = id , class = class})
else
idTable[spellName] = {[1] = {id = id , class = class}}
end
end end
if type(id) == "table" then if type(id) == "table" then
@ -54,9 +66,11 @@ LibClassAuras.Buff = Buff
local function getClassDebuffs(class) local function getClassDebuffs(class)
local classSpells = {} local classSpells = {}
for k,v in pairs(LibClassAuras.debuffToId) do for name, spells in pairs(LibClassAuras.debuffToId) do
if v.class == class then for _, spellInfo in ipairs(spells) do
tinsert(classSpells, {name = k, id = v.id}) if spellInfo.class == class then
tinsert(classSpells, {name = name, id = spellInfo.id})
end
end end
end end
return classSpells return classSpells
@ -65,9 +79,11 @@ LibClassAuras.GetClassDebuffs = getClassDebuffs
local function getClassBuffs(class) local function getClassBuffs(class)
local classSpells = {} local classSpells = {}
for k,v in pairs(LibClassAuras.buffToId) do for name, spells in pairs(LibClassAuras.buffToId) do
if v.class == class then for _, spellInfo in ipairs(spells) do
tinsert(classSpells, {name = k, id = v.id}) if spellInfo.class == class then
tinsert(classSpells, {name = name, id = spellInfo.id})
end
end end
end end
return classSpells return classSpells
@ -82,4 +98,9 @@ local function getSpellNameToId(auraType)
end end
end end
LibClassAuras.GetSpellNameToId = getSpellNameToId LibClassAuras.GetSpellNameToId = getSpellNameToId
local function getAltName(spellID)
return LibClassAuras.altNames[spellID]
end
LibClassAuras.GetAltName = getAltName

View File

@ -138,7 +138,8 @@ function BuffsDebuffs:Test(unit)
BuffsDebuffs:AURA_FADE(unit, AURA_TYPE_DEBUFF) BuffsDebuffs:AURA_FADE(unit, AURA_TYPE_DEBUFF)
BuffsDebuffs:AURA_FADE(unit, AURA_TYPE_BUFF) BuffsDebuffs:AURA_FADE(unit, AURA_TYPE_BUFF)
--BuffsDebuffs:AURA_GAIN(unit, AURA_TYPE_BUFF, 1243, select(1, GetSpellInfo(1243)), select(3, GetSpellInfo(1243)), 10, GetTime() + 10, 1, "physical")
--self:AURA_GAIN(unit, AURA_TYPE_DEBUFF, 31117, select(1, GetSpellInfo(31117)), select(3, GetSpellInfo(31117)), 10, GetTime() + 10, 1, "physical")
local i = 1 local i = 1
for spellID, enabled in pairs(Gladdy.db.trackedDebuffs) do for spellID, enabled in pairs(Gladdy.db.trackedDebuffs) do
if i > 4 then if i > 4 then
@ -197,13 +198,24 @@ function BuffsDebuffs:AURA_GAIN(unit, auraType, spellID, spellName, texture, dur
return return
end end
local auraFrame = self.frames[unit] local auraFrame = self.frames[unit]
spellName = LibClassAuras.GetAltName(spellID) or spellName
local aura = Gladdy:GetImportantAuras()[spellName] and Gladdy.db.auraListDefault[tostring(Gladdy:GetImportantAuras()[spellName].spellID)].enabled local aura = Gladdy:GetImportantAuras()[spellName] and Gladdy.db.auraListDefault[tostring(Gladdy:GetImportantAuras()[spellName].spellID)].enabled
if aura and Gladdy.db.buffsShowAuraDebuffs then if aura and Gladdy.db.buffsShowAuraDebuffs then
aura = false aura = false
end end
local auraNames = LibClassAuras.GetSpellNameToId(auraType) local auraNames = LibClassAuras.GetSpellNameToId(auraType)
local spellId = auraNames[spellName] and auraNames[spellName].id[1] local spellId
if not aura and spellID and spellId and expirationTime and (Gladdy.db.trackedBuffs[tostring(spellId)] or Gladdy.db.trackedDebuffs[tostring(spellId)]) then local isTracked = false
if auraNames[spellName] then
for _, spellInfo in ipairs(auraNames[spellName]) do
spellId = spellInfo.id[1]
if (Gladdy.db.trackedBuffs[tostring(spellId)] or Gladdy.db.trackedDebuffs[tostring(spellId)]) then
isTracked = true
break
end
end
end
if not aura and spellID and expirationTime and isTracked then
local index local index
if auraType == AURA_TYPE_DEBUFF then if auraType == AURA_TYPE_DEBUFF then
auraFrame.numDebuffs = auraFrame.numDebuffs + 1 auraFrame.numDebuffs = auraFrame.numDebuffs + 1