Skip to content

Commit

Permalink
prepare win:spell for SPELL_EXTRA_ATTACKS
Browse files Browse the repository at this point in the history
+ better table pool
+ update SpecializedLibBars-1.0.lua for better and smoother animated bars
+ windows are only movable from their background frame if ALT is held
  • Loading branch information
bkader committed Nov 9, 2022
1 parent 2c03a4b commit 893e6d1
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 223 deletions.
20 changes: 12 additions & 8 deletions Skada/Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -718,22 +718,26 @@ do

d.id = spell -- locked!

local spellid, school, petname = spell_split(spell)
local spellid, school, suffix = spell_split(spell)
d.spellid = spellid
d.spellschool = school

local abs_id = abs(spellid)
d.label = spellnames[abs_id]
d.icon = spellicons[abs_id]

-- hots and dots?
if spellid < 0 and is_hot ~= false then
d.label = format("%s%s", d.label, is_hot and L["HoT"] or L["DoT"])
-- for SPELL_EXTRA_ATTACKS
if tonumber(suffix) then
d.label = format("%s (%s)", spellnames[abs(suffix)], spellnames[abs_id])
else
d.label = spellnames[abs_id]
if suffix then -- has a suffix?
d.label = format("%s (%s)", d.label, suffix)
end
end

-- petname
if petname then
d.label = format("%s (%s)", d.label, petname)
-- hots and dots?
if spellid < 0 and is_hot ~= false then
d.label = format("%s (%s)", d.label, is_hot and L["HoT"] or L["DoT"])
end
end
return d
Expand Down
47 changes: 20 additions & 27 deletions Skada/Core/Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local _

local UnitClass, GetPlayerInfoByGUID = UnitClass, GetPlayerInfoByGUID
local GetClassFromGUID = Skada.GetClassFromGUID
local new, del = Private.newTable, Private.delTable
local tablePool, new, del = Skada.tablePool, Private.newTable, Private.delTable
local clear, copy = Private.clearTable, Private.tCopy
local L, callbacks = Skada.Locale, Skada.callbacks
local userName = Skada.userName
Expand Down Expand Up @@ -39,11 +39,7 @@ do
local tconcat = table.concat

local function module_table(...)
local args = new()
for i = 1, select("#", ...) do
args[i] = select(i, ...)
end

local args = tablePool.acquire(...)
if #args >= 2 then
-- name must always be first
local name = tremove(args, 1)
Expand Down Expand Up @@ -493,15 +489,10 @@ do
heal = random(250, 1500)
end

local actor = new()
actor.id = name
actor.name = name
actor.class = class
actor.role = role
actor.spec = spec
actor.damage = damage
actor.heal = heal
actor.absorb = absorb
local actor = tablePool.acquireHash(
"id", name, "name", name, "class", class, "role", role, "spec", spec,
"damage", damage, "heal", heal, "absorb", absorb
)
fakeSet.actors[#fakeSet.actors + 1] = actor

fakeSet.damage = fakeSet.damage + damage
Expand All @@ -524,18 +515,18 @@ do
if actor.role == "HEALER" then
damage = coef * random(0, 1500)
if actor.spec == 256 then
heal = coef * random(500, 8000)
absorb = coef * random(7500, 13000)
heal = coef * random(500, 1500)
absorb = coef * random(2500, 20000)
else
heal = coef * random(8000, 21000)
heal = coef * random(2500, 15000)
absorb = coef * random(0, 150)
end
elseif actor.role == "TANK" then
damage = coef * random(5000, 14000)
damage = coef * random(1000, 10000)
heal = coef * random(500, 1500)
absorb = coef * random(1000, 1500)
else
damage = coef * random(16000, 31000)
damage = coef * random(8000, 18000)
heal = coef * random(150, 1500)
end

Expand Down Expand Up @@ -1528,11 +1519,10 @@ do
local function create_extra_attack(args)
if ext_attacks[args.srcName] then return end

ext_attacks[args.srcName] = new()
ext_attacks[args.srcName].proc_id = args.spellid
ext_attacks[args.srcName].proc_name = args.spellname
ext_attacks[args.srcName].proc_amount = args.amount
ext_attacks[args.srcName].proc_time = GetTime()
ext_attacks[args.srcName] = tablePool.acquireHash(
"proc_id", args.spellid, "proc_name", args.spellname,
"proc_amount", args.amount, "proc_time", GetTime()
)
end

local function check_extra_attack(args)
Expand All @@ -1552,8 +1542,10 @@ do
return
end

local spellid = args.spellid -- to generate spellstring
args.spellid = ext_attacks[args.srcName].proc_id
args.spellname = format("%s (%s)", ext_attacks[args.srcName].spellname, ext_attacks[args.srcName].proc_name)
args.spellstring = format("%s.%s.%s", args.spellid, args.spellschool, spellid)

ext_attacks[args.srcName].proc_amount = ext_attacks[args.srcName].proc_amount - 1
if ext_attacks[args.srcName].proc_amount == 0 then
Expand Down Expand Up @@ -1610,13 +1602,14 @@ do
args.amount = 0
end

if args.spellid and args.spellschool then
if args.spellid and args.spellschool and not args.spellstring then
args.spellstring = format((args.is_dot or args.is_hot) and "-%s.%s" or "%s.%s", args.spellid, args.spellschool)
if self:InGroup(args.srcFlags) or self:InGroup(args.dstFlags) then
callbacks:Fire("Skada_SpellString", args, args.spellid, args.spellstring)
end
end
if args.extraspellid and args.extraschool then

if args.extraspellid and args.extraschool and not args.extrastring then
args.extrastring = format("%s.%s", args.extraspellid, args.extraschool)
if self:InGroup(args.srcFlags) or self:InGroup(args.dstFlags) then
callbacks:Fire("Skada_SpellString", args, args.extraspellid, args.extrastring)
Expand Down
61 changes: 49 additions & 12 deletions Skada/Core/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,12 @@ end
-- creates a table pool

function Private.table_pool()
local pool = {tables = {}, new = true, del = true, clear = true}
local tables = Private.WeakTable(pool.tables)
local pool = {tables = Private.WeakTable()}

-- reuses or creates a table
pool.new = function()
local t = next(tables)
if t then tables[t] = nil end
local t = next(pool.tables)
if t then pool.tables[t] = nil end
return t or {}
end

Expand All @@ -148,7 +147,7 @@ function Private.table_pool()
t[""] = true
t[""] = nil
setmetatable(t, nil)
tables[t] = true
pool.tables[t] = true

return nil
end
Expand All @@ -163,17 +162,56 @@ function Private.table_pool()
return t
end

-- creates a table a fills it with args passed
pool.acquire = function(...)
local t, n = pool.new(), select("#", ...)
for i = 1, n do t[i] = select(i, ...) end
return t
end

-- creates a table and fills it with key-value args
pool.acquireHash = function(...)
local t, n = pool.new(), select("#", ...)
for i = 1, n, 2 do
local k, v = select(i, ...)
t[k] = v
end
return t
end

-- populates the given table with args passed
pool.populate = function(t, ...)
if type(t) == "table" then
for i = 1, select("#", ...) do
t[#t + 1] = select(i, ...)
end
end
return t
end

-- populates the given table with key-value args
pool.populateHash = function(t, ...)
if type(t) == "table" then
for i = 1, select("#", ...), 2 do
local k, v = select(i, ...)
t[k] = v
end
end
return t
end

return pool
end

-- create addon's default table pool
do
local _pool = Private.table_pool()
new = _pool.new
del = _pool.del
Private.newTable = _pool.new
Private.delTable = _pool.del
Private.clearTable = _pool.clear
local tablePool = Private.table_pool()
ns.tablePool = tablePool

new, del = tablePool.new, tablePool.del
Private.newTable = tablePool.new
Private.delTable = tablePool.del
Private.clearTable = tablePool.clear
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -1216,7 +1254,6 @@ do
[3026] = [[Interface\ICONS\spell_shadow_soulgem]], --> Use Soulstone
[54755] = [[Interface\ICONS\inv_glyph_majordruid]], --> Glyph of Rejuvenation
[56160] = [[Interface\ICONS\inv_glyph_majorpriest]], --> Glyph of Power Word: Shield
[57842] = [[Interface\ICONS\ability_warrior_focusedrage]], --> Killing Spree Off-Hand
[61607] = [[Interface\ICONS\ability_hunter_rapidkilling]] --> Mark of Blood
}

Expand Down
Loading

0 comments on commit 893e6d1

Please sign in to comment.