Skip to content

Commit

Permalink
update for Dragonflight Alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorovon committed Sep 3, 2022
1 parent 3433fe5 commit 1e33a58
Show file tree
Hide file tree
Showing 5 changed files with 1,781 additions and 480 deletions.
4 changes: 2 additions & 2 deletions HiddenAuraLogger/HiddenAuraLogger.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 90200
## Interface: 100000
## Title: HiddenAuraLogger
## Author: Dorovon
## Version: 1.1.1
## Version: 2.0.0
## SavedVariables: HiddenAuraLoggerDB

spell_lists.lua
Expand Down
57 changes: 30 additions & 27 deletions HiddenAuraLogger/aura_display.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,18 @@ local function update_icon_dynamic(f)
end
end

local function update_icon(f, spell_id)
local function update_icon(f, instance_id)
f.dynamic = {}
local d = f.dynamic
local size = db.config.icon_size

d.new = GetTime()
f:SetSize(size, size)
f.spell_id = spell_id
f.instance_id = instance_id
f.texture:SetDesaturated(false)

values = addon_table.active_auras[spell_id]
if not values then
values = {}
end

local name, icon, count, dispelType, duration, expirationTime = unpack(values)
local aura_table = addon_table.active_auras[instance_id]
local name, icon, count, duration, expirationTime = aura_table.name, aura_table.icon, aura_table.applications, aura_table.duration, aura_table.expirationTime
if not icon then
icon = "Interface/Icons/INV_Misc_QuestionMark"
end
Expand Down Expand Up @@ -189,19 +185,24 @@ local icon_pool = CreateObjectPool(create_function, reset_function)
local icon_frames = {}

function addon_table.display_frame:update()
-- TODO: This only needs to one once per frame after all auras have been added.
auras = {}
for spell_id, icon in pairs(icon_frames) do
auras[#auras + 1] = spell_id
-- TODO: This only needs to run once per frame after all auras have been added.
local auras = {}
for instance_id, icon in pairs(icon_frames) do
auras[#auras + 1] = instance_id
end
sort(auras)
sort(auras, function(a, b)
if icon_frames[a].spell_id == icon_frames[b].spell_id then
return a < b
end
return icon_frames[a].spell_id < icon_frames[b].spell_id
end)
local prev, prev_row
local row = 0
local icon_height = db.config.icon_size
local icons_per_row = db.config.icons_per_row
local row_pad, col_pad = db.config.row_padding, db.config.col_padding
for i, spell_id in ipairs(auras) do
local icon = icon_frames[spell_id]
for i, instance_id in ipairs(auras) do
local icon = icon_frames[instance_id]
if i % icons_per_row == 1 then
row = row + 1
end
Expand All @@ -216,40 +217,42 @@ function addon_table.display_frame:update()
end
end

function addon_table.display_frame:update_aura(spell_id)
function addon_table.display_frame:update_aura(instance_id)
if not self:IsShown() then
return
end

local icon = icon_frames[spell_id]
if addon_table.active_auras[spell_id] then
local icon = icon_frames[instance_id]
if addon_table.active_auras[instance_id] then
local should_update = false
if not icon then
icon = icon_pool:Acquire()
icon_frames[spell_id] = icon
icon_frames[instance_id] = icon
icon.spell_id = addon_table.active_auras[instance_id].spellId
self:update()
end
icon:update(spell_id)
icon:update(instance_id)
elseif icon then
-- The aura is not active and the icon needs to be removed.
icon:expire()
end
end

function addon_table.display_frame:remove_aura(spell_id)
function addon_table.display_frame:remove_aura(instance_id)
if not self:IsShown() then
return
end

local icon = icon_frames[spell_id]
local icon = icon_frames[instance_id]
if icon then
addon_table.display_frame:remove_icon(icon)
end
end

function addon_table.display_frame:remove_icon(f)
if f then
if f.spell_id then
icon_frames[f.spell_id] = nil
if f.instance_id then
icon_frames[f.instance_id] = nil
end
icon_pool:Release(f)
self:update()
Expand All @@ -261,11 +264,11 @@ function addon_table.display_frame.update_config()
db = HiddenAuraLoggerDB
end

addon_table.display_frame:SetPoint("BOTTOMLEFT", db.config.x_offset, db.config.y_offset)
addon_table.display_frame:SetPoint("TOPLEFT", db.config.x_offset, db.config.y_offset)

if addon_table.active_auras then
for spell_id, _ in pairs(addon_table.active_auras) do
addon_table.display_frame:update_aura(spell_id)
for instance_id, _ in pairs(addon_table.active_auras) do
addon_table.display_frame:update_aura(instance_id)
end
addon_table.display_frame:update()
end
Expand Down
92 changes: 69 additions & 23 deletions HiddenAuraLogger/log_display.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
local addon_name, addon_table = ...
local db

local key_order = {
timestamp = 0,
event = 1,
spellId = 2,
name = 3,
}

local function dict_to_string(t)
local function compare_keys(a, b)
if key_order[a] and key_order[b] then
return key_order[a] < key_order[b]
elseif key_order[a] then
return true
elseif key_order[b] then
return false
else
return a < b
end
end

local function value_string(key, value)
if type(value) == "table" then
local str = ""
for k, v in pairs(value) do
if str ~= "" then
str = str .. "; "
end
str = str .. value_string(key .. "[" .. k .. "]" , v)
end
return str
else
return tostring(key) .. "=" .. tostring(value)
end
end

local str = ""
local keys = {}
for k, _ in pairs(t) do
keys[#keys + 1] = k
end
sort(keys, compare_keys)

for _, k in ipairs(keys) do
local v = value_string(k, t[k])
if v ~= "" then
if str ~= "" then
str = str .. "; "
end
str = str .. v
end
end

return str
end

local function get_cursor_pos()
local x, y = GetCursorPosition()
local scale = UIParent:GetEffectiveScale()
Expand Down Expand Up @@ -169,9 +224,9 @@ local function get_log_text(log)
end

text = text .. "\n# Hidden Aura Events\n"
text = text .. "timestamp; event; name; icon; count; dispelType; duration; expirationTime; source; isStealable; nameplateShowPersonal; spellId; canApplyAura; isBossDebuff; castByPlayer; nameplateShowAll; timeMod; ...\n"
-- text = text .. "timestamp; event; spellId; name; icon; count; dispelType; duration; expirationTime; source; isStealable; nameplateShowPersonal; spellId; canApplyAura; isBossDebuff; castByPlayer; nameplateShowAll; timeMod; ...\n"
for _, event in ipairs(log.events) do
text = text .. event .. "\n"
text = text .. dict_to_string(event) .. "\n"
end

return text
Expand Down Expand Up @@ -523,32 +578,23 @@ local function log_timestamp(log)
return text
end

local function split_log_entry(entry)
local values = {}
for s, d in string.gmatch(entry, " ?([^;]+)") do
values[#values + 1] = s
end
return values
end

local function get_log_line(index, entry, start_time)
local text = entry
local values = split_log_entry(entry)
local timestamp = values[1]
local event = values[2]
local timestamp = entry.timestamp
local event = entry.event
local name, spell_id
local stack, remaining_duration = "", ""

if event == "HIDDEN_AURA_REMOVED" then
name = values[3]
spell_id = values[4]
elseif event:sub(1, 12) == "HIDDEN_AURA_" then
name = values[3]
spell_id = values[12]
stack = tonumber(values[5])
local expire_time = tonumber(values[8])
name = entry.name
spell_id = entry.spellId
elseif event == "HIDDEN_AURA_APPLIED" then
name = entry.name or ""
spell_id = entry.spellId or 0
stack = entry.applications or 0
local expire_time = entry.expirationTime
if expire_time > 0 then
local d = expire_time - start_time - tonumber(timestamp)
local d = expire_time - start_time - timestamp
local h = floor(d / 3600)
local m = floor(d / 60 % 60)
local s = floor(d % 60)
Expand All @@ -561,14 +607,14 @@ local function get_log_line(index, entry, start_time)
end
end
else
return {index=index, text=entry}
return {index=index, text=dict_to_string(entry)}
end

if stack == 0 then
stack = ""
end

return {index=index, text={timestamp, event, name, spell_id, stack, remaining_duration}, spell_id=spell_id}
return {index=index, text={format('%.2f', timestamp), event, name, spell_id, stack, remaining_duration}, spell_id=spell_id}
end

function lf:select_log(index)
Expand Down
Loading

0 comments on commit 1e33a58

Please sign in to comment.