/
NEEDTOKNOW.BARMENU_SHOW_SPARK = "Spark"; |
NEEDTOKNOW.BARMENU_SHOW_MYPIP = "Indicator If Mine"; |
NEEDTOKNOW.BARMENU_SHOW_TEXT_USER = "Override Aura Name..."; |
NEEDTOKNOW.BARMENU_SHOW_TTN1 = "First Tooltip Number"; |
NEEDTOKNOW.BARMENU_SHOW_TTN2 = "Second Tooltip Number"; |
NEEDTOKNOW.BARMENU_SHOW_TTN3 = "Third Tooltip Number"; |
NEEDTOKNOW.UIPANEL_SUBTEXT1 = "These options allow you to customize NeedToKnow's timer bar groups."; |
{ VariableName = "show_time", MenuText = NEEDTOKNOW.BARMENU_SHOW_TIME }, |
{ VariableName = "show_spark", MenuText = NEEDTOKNOW.BARMENU_SHOW_SPARK }, |
{ VariableName = "show_mypip", MenuText = NEEDTOKNOW.BARMENU_SHOW_MYPIP }, |
{ VariableName = "show_ttn1", MenuText = NEEDTOKNOW.BARMENU_SHOW_TTN1 }, |
{ VariableName = "show_ttn2", MenuText = NEEDTOKNOW.BARMENU_SHOW_TTN2 }, |
{ VariableName = "show_ttn3", MenuText = NEEDTOKNOW.BARMENU_SHOW_TTN3 }, |
{ VariableName = "show_text_user", MenuText = NEEDTOKNOW.BARMENU_SHOW_TEXT_USER, Type = "Dialog", DialogText = "CHOOSE_OVERRIDE_TEXT", Checked = function(settings) return "" ~= settings.show_text_user end }, |
}, |
BlinkSettings = { |
duration = 0, |
expirationTime = 0, |
}, |
total = 0 |
total = 0, |
total_ttn = { 0, 0, 0 } |
} |
NeedToKnow.scratch.buff_stacks = |
{ |
duration = 0, |
expirationTime = 0, |
}, |
total = 0 |
total = 0, |
total_ttn = { 0, 0, 0 } |
} |
NeedToKnow.scratch.bar_entry = |
{ |
show_icon = false, |
show_mypip = false, |
show_all_stacks = false, |
show_ttn1 = false, |
show_ttn2 = false, |
show_ttn3 = false, |
show_text_user = "", |
blink_enabled = false, |
blink_ooc = true, |
show_mypip = "sPp", |
show_all_stacks = "All", |
show_text_user = "sUr", |
show_ttn1 = "sN1", |
show_ttn2 = "sN2", |
show_ttn3 = "sN3", |
blink_enabled = "BOn", |
blink_ooc = "BOC", |
blink_boss = "BBs", |
Ext = "bDetectExtends", |
sTx = "show_text", |
sCt = "show_count", |
sN1 = "show_ttn1", |
sN2 = "show_ttn2", |
sN3 = "show_ttn3", |
sTm = "show_time", |
sSp = "show_spark", |
sIc = "show_icon", |
end |
end |
function NeedToKnow.GetNameAndServer(unit) |
local name, server = UnitName(unit) |
if name and server then |
return name |
end |
function NeedToKnow.RefreshRaidMemberNames() |
NeedToKnow.raid_members = {} |
-- AuraCheck calls on this to compute the "text" of the bar |
-- It is separated out like this in part to be hooked by other addons |
function NeedToKnow.ComputeBarText(buffName, count, extended) |
function NeedToKnow.ComputeBarText(buffName, count, extended, buff_stacks, bar) |
local text |
if ( count > 1 ) then |
text = buffName.." ["..count.."]" |
else |
text = buffName |
end |
if ( bar.settings.show_ttn1 and buff_stacks.total_ttn[1] > 0 ) then |
text = text .. " ("..buff_stacks.total_ttn[1]..")" |
end |
if ( bar.settings.show_ttn2 and buff_stacks.total_ttn[2] > 0 ) then |
text = text .. " ("..buff_stacks.total_ttn[2]..")" |
end |
if ( bar.settings.show_ttn3 and buff_stacks.total_ttn[3] > 0 ) then |
text = text .. " ("..buff_stacks.total_ttn[3]..")" |
end |
if ( extended and extended > 1 ) then |
text = text .. string.format(" + %.0fs", extended) |
end |
end |
end |
function NeedToKnow.ConfigureVisibleBar(bar, count, extended) |
function NeedToKnow.ConfigureVisibleBar(bar, count, extended, buff_stacks) |
local text = "" |
if ( bar.settings.show_icon and bar.iconPath and bar.icon ) then |
bar.icon:SetTexture(bar.iconPath) |
txt = txt .. "* " |
end |
local n = "" |
if ( bar.settings.show_text ) then |
local n = bar.buffName |
n = bar.buffName |
if "" ~= bar.settings.show_text_user then |
local idx=bar.idxName |
if idx > #bar.spell_names then idx = #bar.spell_names end |
n = bar.spell_names[idx] |
end |
local c = count |
if not bar.settings.show_count then |
c = 1 |
end |
txt = txt .. NeedToKnow.ComputeBarText(n, c, extended) |
end |
local c = count |
if not bar.settings.show_count then |
c = 1 |
end |
local to_append = NeedToKnow.ComputeBarText(n, c, extended, buff_stacks, bar) |
if to_append and to_append ~= "" then |
txt = txt .. to_append |
end |
if ( bar.settings.append_cd |
and (bar.settings.BuffOrDebuff == "CASTCD" |
or bar.settings.BuffOrDebuff == "BUFFCD" |
end |
data.expiration = GetTime() + data.expiration/1000 |
if oldname ~= data.name then |
local _ |
_,_,data.icon = GetSpellInfo(data.name) |
if nil == data.icon then |
_,_,data.icon = GetSpellInfo(data.name .. " Weapon") |
end |
local function AddInstanceToStacks(all_stacks, bar_entry, duration, name, count, expirationTime, iconPath, caster) |
local function AddInstanceToStacks(all_stacks, bar_entry, duration, name, count, expirationTime, iconPath, caster, tt1, tt2, tt3) |
if duration then |
if (not count or count < 1) then count = 1 end |
if ( 0 == all_stacks.total or all_stacks.min.expirationTime > expirationTime ) then |
all_stacks.max.expirationTime = expirationTime |
end |
all_stacks.total = all_stacks.total + count |
if ( tt1 ) then |
all_stacks.total_ttn[1] = all_stacks.total_ttn[1] + tt1 |
if ( tt2 ) then |
all_stacks.total_ttn[2] = all_stacks.total_ttn[2] + tt2 |
end |
if ( tt3 ) then |
all_stacks.total_ttn[3] = all_stacks.total_ttn[3] + tt3 |
end |
end |
end |
end |
end |
function NeedToKnow.ResetScratchStacks(buff_stacks) |
buff_stacks.total = 0; |
buff_stacks.total_ttn[1] = 0; |
buff_stacks.total_ttn[2] = 0; |
buff_stacks.total_ttn[3] = 0; |
end |
-- Bar_AuraCheck helper for watching "internal cooldowns", which is like a spell |
-- cooldown for spells cast automatically (procs). The "reset on buff" logic |
-- is still handled by |
function NeedToKnow.AuraCheck_BUFFCD(bar, bar_entry, all_stacks) |
local buff_stacks = NeedToKnow.scratch.buff_stacks |
buff_stacks.total = 0 |
NeedToKnow.ResetScratchStacks(buff_stacks); |
NeedToKnow.AuraCheck_Single(bar, bar_entry, buff_stacks) |
local tNow = GetTime() |
if ( buff_stacks.total > 0 ) then |
end |
end |
local function UnitAuraWrapper(a,b,c,d) |
local |
name, |
_, -- rank, |
icon, |
count, |
_, -- type, |
dur, |
expiry, |
caster, |
_, -- uao.steal, |
_, -- uao.cons -- Should consolidate |
id, |
_, -- uao.canCast -- The player's class/spec can cast this spell |
_, -- A boss applied this |
v1, |
v2, |
v3, |
bEnd -- Just indicates the end of the variable number of return results |
= UnitAura(a,b,c,d) |
if name then |
-- There is a boolean at the end of the list whos purpose is unknown |
-- It can be either true or false, so we must test against nil explicitly |
-- Between the boss boolean and this end boolean will be 0-3 integers |
if nil == bEnd then |
-- some or all tooltip values are missing |
if nil == v3 then |
if nil == v2 then |
v1 = nil |
end |
v2 = nil |
end |
v3 = nil |
end |
return name, icon, count, dur, expiry, caster, id, v1, v2, v3, bEnd |
end |
end |
-- Bar_AuraCheck helper that looks for the first instance of a buff |
-- Uses the UnitAura filters exclusively if it can |
local barID = bar_entry.id |
local j = 1 |
while true do |
local buffName, _, iconPath, count, _, duration, expirationTime, caster, _, _, spellID |
= UnitAura(bar.unit, j, filter) |
local buffName, iconPath, count, duration, expirationTime, caster, spellID, tt1, tt2, tt3 |
= UnitAuraWrapper(bar.unit, j, filter) |
if (not buffName) then |
break |
end |
count, -- count |
expirationTime, -- expiration time |
iconPath, -- icon path |
caster ) -- caster |
caster, -- caster |
tt1, tt2, tt3 ) -- extra status values, like vengeance armor or healing bo |
return; |
end |
j=j+1 |
end |
else |
local buffName, _ , iconPath, count, _, duration, expirationTime, caster |
= UnitAura(bar.unit, bar_entry.name, nil, filter) |
local buffName, iconPath, count, duration, expirationTime, caster, _, tt1, tt2, tt3 |
= UnitAuraWrapper(bar.unit, bar_entry.name, nil, filter) |
AddInstanceToStacks( all_stacks, bar_entry, |
duration, -- duration |
buffName, -- name |
count, -- count |
expirationTime, -- expiration time |
iconPath, -- icon path |
caster ) -- caster |
caster, -- caster |
tt1, tt2, tt3 ) -- extra status values, like vengeance armor or healing bo |
end |
end |
local filter = settings.BuffOrDebuff |
while true do |
local buffName, _, iconPath, count, _, duration, expirationTime, caster, _, _, spellID |
= UnitAura(bar.unit, j, filter) |
local buffName, iconPath, count, duration, expirationTime, caster, spellID, tt1, tt2, tt3 |
= UnitAuraWrapper(bar.unit, j, filter) |
if (not buffName) then |
break |
end |
count, |
expirationTime, |
iconPath, |
caster ) |
caster, |
tt1, tt2, tt3 ) |
end |
j = j+1 |
-- Determine if the bar should be showing anything |
local all_stacks |
local idxName, duration, buffName, count, expirationTime, iconPath, caster |
if ( bUnitExists ) then |
if ( bUnitExists ) then |
all_stacks = NeedToKnow.scratch.all_stacks |
all_stacks.total = 0 |
NeedToKnow.ResetScratchStacks(all_stacks); |
-- Call the helper function for each of the spells in the list |
for idx, entry in ipairs(bar.spells) do |
local maxStart = 0 |
local tNow = GetTime() |
local buff_stacks = NeedToKnow.scratch.buff_stacks |
buff_stacks.total = 0 |
NeedToKnow.ResetScratchStacks(buff_stacks); |
-- Keep track of when the reset auras were last applied to the player |
for idx, resetSpell in ipairs(bar.reset_spells) do |
-- Note this relies on BUFFCD setting the target to player, and that the onlyMine will work either way |
-- Mark the bar as not blinking before calling ConfigureVisibleBar, |
-- since it calls OnUpdate which checks bar.blink |
bar.blink=false |
NeedToKnow.ConfigureVisibleBar(bar, count, extended) |
NeedToKnow.ConfigureVisibleBar(bar, count, extended, all_stacks) |
bar:Show() |
else |
if (settings.bDetectExtends and bar.buffName) then |