WoWInterface SVN KuiNameplates

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/Kui_Nameplates_Auras
    from Rev 146 to Rev 155
    Reverse comparison

Rev 146 → Rev 155

auras.lua
3,17 → 3,14
local kui = LibStub('Kui-1.0')
local mod = addon:NewModule('Auras', 'AceEvent-3.0')
 
local currentFrame = nil
-- combat log events to listen to for fading auras
local auraEvents = {
-- ['SPELL_DISPEL'] = true,
['SPELL_AURA_REMOVED'] = true,
['SPELL_AURA_BROKEN'] = true,
['SPELL_AURA_BROKEN_SPELL'] = true,
}
 
--[[ TODO
 
Make work on mouseover
 
If only two containers are ever displayed, just make two containers and
move them around rather than making 1 container for every nameplate
 
]]
 
local function ArrangeButtons(self)
local pv, pc
self.visible = 0
81,7 → 78,7
end
 
if timeLeft <= 0 then
self:Hide()
self.time:SetText('0')
end
 
self.elapsed = .5
210,31 → 207,42
end
 
-------------------------------------------------------------- event handlers --
function mod:PLAYER_TARGET_CHANGED()
local frame = addon:GetNameplate(UnitGUID('target'), nil)
function mod:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
local castTime, event, _, guid, name, _, _, targetGUID, targetName = ...
if not guid then return end
if not auraEvents[event] then return end
if guid ~= UnitGUID('player') then return end
 
if currentFrame and (not frame or frame ~= currentFrame) then
-- hide auras on the previous target
currentFrame.auras:Hide()
end
--print(event..' from '..name..' on '..targetName)
 
if frame ~= currentFrame then
currentFrame = frame
end
-- fetch the subject's nameplate
local f = addon:GetNameplate(targetGUID, targetName)
if not f or not f.auras then return end
 
if frame then
-- scan auras on the new target
self:UNIT_AURA('UNIT_AURA', 'target')
--print('(frame for guid: '..targetGUID..')')
 
local spId = select(12, ...)
 
if f.auras.spellIds[spId] then
f.auras.spellIds[spId]:Hide()
end
end
 
function mod:PLAYER_TARGET_CHANGED()
self:UNIT_AURA('UNIT_AURA', 'target')
end
 
function mod:UPDATE_MOUSEOVER_UNIT()
self:UNIT_AURA('UNIT_AURA', 'mouseover')
end
 
function mod:UNIT_AURA(event, unit)
if unit ~= 'target' then return end
 
-- select the targeted nameplate
local frame = addon:GetNameplate(UnitGUID(unit), nil)
if not frame or not frame.auras then return end
if not frame or not frame.auras or frame.trivial then return end
 
--print('Scan auras on unit: '..unit)
 
local filter = 'PLAYER '
if UnitIsFriend(unit, 'player') then
filter = filter..'HELPFUL'
242,13 → 250,18
filter = filter..'HARMFUL'
end
 
-- hide currently displayed auras
local _,button
for _,button in pairs(frame.auras.spellIds) do
button:Hide()
end
 
for i = 0,40 do
-- TODO optimise
-- TODO find auras which are no longer present
local name, _, icon, count, _, duration, expirationTime, _, _, _, spellId = UnitAura('target', i, filter)
local name, _, icon, count, _, duration, expirationTime, _, _, _, spellId = UnitAura(unit, i, filter)
 
if name and
(not self.db.profile.display.useWhitelist or
(not self.db.profile.behav.useWhitelist or
whitelist[spellId]) and
(duration >= self.db.profile.display.lengthMin) and
(self.db.profile.display.lengthMax == -1 or
259,13 → 272,6
button:Show()
end
end
 
if frame ~= currentFrame then
if currentFrame then
currentFrame.auras:Hide()
end
currentFrame = frame
end
end
 
---------------------------------------------------- Post db change functions --
300,6 → 306,7
name = 'Timer threshold (s)',
desc = 'Timer text will be displayed on auras when their remaining length is less than or equal to this value. -1 to always display timer.',
type = 'range',
order = 10,
min = -1,
softMax = 180,
step = 1
308,6 → 315,7
name = 'Effect length minimum (s)',
desc = 'Auras with a total duration of less than this value will never be displayed. 0 to disable.',
type = 'range',
order = 20,
min = 0,
softMax = 60,
step = 1
316,14 → 324,27
name = 'Effect length maximum (s)',
desc = 'Auras with a total duration greater than this value will never be displayed. -1 to disable.',
type = 'range',
order = 30,
min = -1,
softMax= 1800,
step = 1
},
 
}
},
behav = {
name = 'Behaviour',
type = 'group',
inline = true,
disabled = function()
return not self.db.profile.enabled
end,
args = {
useWhitelist = {
name = 'Use whitelist',
desc = 'Only display spells which your class needs to keep track of for PVP or an effective DPS rotation. Most passive effects are excluded.',
type = 'toggle'
type = 'toggle',
order = 0,
},
}
}
338,6 → 359,8
timerThreshold = 20,
lengthMin = 0,
lengthMax = -1,
},
behav = {
useWhitelist = true,
}
}
357,6 → 380,8
 
self:RegisterEvent('UNIT_AURA')
self:RegisterEvent('PLAYER_TARGET_CHANGED')
self:RegisterEvent('UPDATE_MOUSEOVER_UNIT')
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
 
local _, frame
for _, frame in pairs(addon.frameList) do
369,6 → 394,8
function mod:OnDisable()
self:UnregisterEvent('UNIT_AURA')
self:UnregisterEvent('PLAYER_TARGET_CHANGED')
self:UnregisterEvent('UPDATE_MOUSEOVER_UNIT')
self:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
 
local _, frame
for _, frame in pairs(addon.frameList) do