Replacing table.wipe with Details:Destroy()

This commit is contained in:
Tercio Jose
2023-05-22 15:31:29 -03:00
parent fa0d1e1d08
commit 0cdfa2b900
40 changed files with 1205 additions and 1322 deletions
+2 -2
View File
@@ -133,8 +133,8 @@ function Details:CreateCallbackListeners()
end
current_encounter = false
wipe (current_table_dbm)
wipe (current_table_bigwigs)
Details:Destroy (current_table_dbm)
Details:Destroy (current_table_bigwigs)
end
end)
event_frame:RegisterEvent("ENCOUNTER_START")
+2 -2
View File
@@ -74,8 +74,8 @@ end
--start the proccess of updating the current dps and hps for each player
function Details.CurrentDps.StartCurrentDpsTracker()
Details.CurrentDps.CombatObject = Details:GetCurrentCombat()
wipe(Details.CurrentDps.Dps)
wipe(Details.CurrentDps.Hps)
Details:Destroy(Details.CurrentDps.Dps)
Details:Destroy(Details.CurrentDps.Hps)
currentDpsFrame:SetScript("OnUpdate", currentDpsFrame.OnUpdateFunc)
end
--stop what the function above started
+69 -68
View File
@@ -3,7 +3,7 @@ local Details = _G.Details
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local _
local addonName, Details222 = ...
local C_Timer
local C_Timer = C_Timer
local UnitName = UnitName
--On Details! Load load default keys into the main object
@@ -22,7 +22,7 @@ function Details222.LoadSavedVariables.CharacterData()
local currentCharacterData = _detalhes_database
--check if the player data exists, if not, load from default
if (not currentCharacterData) then
if (not currentCharacterData) then --NOT EXISTS
currentCharacterData = Details.CopyTable(defaultCharacterData)
--[[GLOBAL]] _detalhes_database = currentCharacterData
end
@@ -106,71 +106,91 @@ end
--load previous saved combat data
function Details222.LoadSavedVariables.CombatSegments()
local currentCharacterData = _G["_detalhes_database"] --no need to check if it exists, it's already checked
if (currentCharacterData == nil) then
currentCharacterData = {}
end
--if isn't nothing saved, build a new one and quit
if (not currentCharacterData.tabela_historico) then
--custom displays - if there's no saved custom display, they will be filled from the StartMeUp() when a new version is installed
if (_detalhes_global.custom) then
Details.custom = _detalhes_global.custom
Details.refresh:r_atributo_custom()
end
local bShouldClearAndExit = not currentCharacterData.tabela_historico
--check integrity of the sub table 'tabelas' and its first index 'current segment'
if (not bShouldClearAndExit) then
if (not currentCharacterData.tabela_historico.tabelas or not currentCharacterData.tabela_historico.tabelas[1]) then
bShouldClearAndExit = true
end
end
--check if is a major version upgrade (usualy API or low level changes)
if (not bShouldClearAndExit) then
bShouldClearAndExit = currentCharacterData.last_realversion and currentCharacterData.last_realversion < Details.realversion
end
--if can just clear all data and exit
if (bShouldClearAndExit) then
Details.tabela_historico = Details.historico:NovoHistorico()
Details.tabela_overall = Details.combate:NovaTabela()
Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall)
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdateContainerCombatentes()
if (currentCharacterData.tabela_pets) then
Details:Destroy(currentCharacterData.tabela_pets) --saved pet data
currentCharacterData.tabela_pets = nil
end
if (currentCharacterData.tabela_overall) then --saved overall data
Details:Destroy(currentCharacterData.tabela_overall)
currentCharacterData.tabela_overall = nil
end
if (currentCharacterData.tabela_historico) then
Details:Destroy(currentCharacterData.tabela_historico)
currentCharacterData.tabela_historico = nil
end
return
else
Details.tabela_historico = Details.CopyTable(currentCharacterData.tabela_historico)
Details.tabela_overall = Details.combate:NovaTabela()
Details.tabela_pets = Details.container_pets:NovoContainer()
if (currentCharacterData.tabela_pets) then
Details.tabela_pets.pets = Details.CopyTable(currentCharacterData.tabela_pets)
end
Details:UpdateContainerCombatentes()
--if the core revision was incremented, reset all combat data to avoid incompatible data
if (currentCharacterData.last_realversion and currentCharacterData.last_realversion < Details.realversion) then
--details was been hard upgraded
Details.tabela_historico = Details.historico:NovoHistorico()
Details.tabela_overall = Details.combate:NovaTabela()
Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall)
--pet owners cache saved on logout
do
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdateContainerCombatentes()
if (currentCharacterData.tabela_pets) then
--pet ownership table only exists if the player logoff inside a raid or dungeon
Details.tabela_pets.pets = Details.CopyTable(currentCharacterData.tabela_pets)
Details:Destroy(currentCharacterData.tabela_pets)
currentCharacterData.tabela_pets = nil
end
end
currentCharacterData.tabela_historico = nil
currentCharacterData.tabela_overall = nil
else
--check integrity
local combat = Details.tabela_historico.tabelas[1]
if (combat) then
if (not combat[1] or not combat[2] or not combat[3] or not combat[4]) then
--something went wrong in last logon, let's just reset and we are good to go
Details.tabela_historico = Details.historico:NovoHistorico()
Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall)
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdateContainerCombatentes()
--restore saved overall data
do
if (not Details.overall_clear_logout) then
if (currentCharacterData.tabela_overall) then
Details.tabela_overall = Details.CopyTable(currentCharacterData.tabela_overall)
Details:RestoreOverallMetatables()
end
else
Details.tabela_overall = Details.combate:NovaTabela()
end
end
if (not Details.overall_clear_logout) then
if (currentCharacterData.tabela_overall) then
Details.tabela_overall = currentCharacterData.tabela_overall
Details:RestoreOverallMetatables()
Details:Destroy(currentCharacterData.tabela_overall)
currentCharacterData.tabela_overall = nil
end
else
Details.tabela_overall = Details.combate:NovaTabela()
end
--re-build all indexes and metatables
Details:RestoreMetatables()
--get lastest combat the player participated
---@type combat
local firstSegment = Details.tabela_historico.tabelas[1]
if (firstSegment) then
Details.tabela_vigente = firstSegment
else
Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall)
--restore saved segments
do
Details.tabela_historico = Details.CopyTable(currentCharacterData.tabela_historico)
Details:Destroy(currentCharacterData.tabela_historico)
currentCharacterData.tabela_historico = nil
end
--get the first segment saved and use it as current segment
Details.tabela_vigente = Details.tabela_historico.tabelas[1]
--need refresh for all containers
for _, actorContainer in ipairs(Details.tabela_overall) do
actorContainer.need_refresh = true
@@ -179,19 +199,8 @@ function Details222.LoadSavedVariables.CombatSegments()
actorContainer.need_refresh = true
end
--erase combat data from the database
if (currentCharacterData.tabela_historico) then
Details:Destroy(currentCharacterData.tabela_historico)
end
if (currentCharacterData.tabela_pets) then
Details:Destroy(currentCharacterData.tabela_pets)
end
--double check for pet container
if (not Details.tabela_pets or not Details.tabela_pets.pets) then
Details.tabela_pets = Details.container_pets:NovoContainer()
end
Details:UpdateContainerCombatentes()
Details:RestoreMetatables()
end
end
@@ -348,14 +357,6 @@ function Details:LoadConfig()
--apply the profile
Details:ApplyProfile(current_profile_name, true)
--custom
Details.custom = _detalhes_global.custom
if (_detalhes_global.custom and _detalhes_global.custom[1] and _detalhes_global.custom[1].__index and _detalhes_global.custom[1].__index._InstanceLastCombatShown) then
C_Timer.After(5, function() print("|cFFFFAA00Details!|r error 0x8487, report on discord") end)
end
Details.refresh:r_atributo_custom()
end
--On Details! Load count logons, tutorials, etc
+1 -1
View File
@@ -809,7 +809,7 @@ function DetailsMythicPlusFrame.EventListener.OnDetailsEvent(contextObject, even
--reset spec cache if broadcaster requested
if (Details.streamer_config.reset_spec_cache) then
wipe (Details.cached_specs)
Details:Destroy (Details.cached_specs)
end
C_Timer.After(0.5, DetailsMythicPlusFrame.OnChallengeModeStart)
+5 -5
View File
@@ -80,11 +80,11 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
--0x8 misc
--0x10 no combat header
table.wipe(actorInformation)
table.wipe(actorInformationIndexes)
table.wipe(actorDamageInfo)
table.wipe(actorHealInfo)
table.wipe(actorUtilityInfo)
Details:Destroy(actorInformation)
Details:Destroy(actorInformationIndexes)
Details:Destroy(actorDamageInfo)
Details:Destroy(actorHealInfo)
Details:Destroy(actorUtilityInfo)
--reset the serial counter
entitySerialCounter = 0
+1 -1
View File
@@ -114,7 +114,7 @@ function Details:RefreshPlaterIntegration()
if (Plater and Details.plater.realtime_dps_enabled or Details.plater.realtime_dps_player_enabled or Details.plater.damage_taken_enabled) then
--wipe the cache
wipe (plater_integration_frame.DamageTaken)
Details:Destroy (plater_integration_frame.DamageTaken)
--read cleu events
plater_integration_frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
+3 -3
View File
@@ -144,7 +144,7 @@ function Details:ResetProfile (profile_name)
end
--reset the profile
table.wipe(profile.instances)
Details:Destroy(profile.instances)
--export first instance
local instance = Details:GetInstance(1)
@@ -529,7 +529,7 @@ function Details:SaveProfile (saveas)
--save skins
if (not Details.do_not_save_skins) then
table.wipe(profile.instances)
Details:Destroy(profile.instances)
for index, instance in ipairs(Details.tabela_instancias) do
local exported = instance:ExportSkin()
exported.__was_opened = instance:IsEnabled()
@@ -1668,7 +1668,7 @@ function Details:SaveProfileSpecial()
end
--save skins
table.wipe(profile.instances)
Details:Destroy(profile.instances)
if (Details.tabela_instancias) then
for index, instance in ipairs(Details.tabela_instancias) do
+77 -74
View File
@@ -1,14 +1,14 @@
--[[this file save the data when player leave the game]]
local _detalhes = _G.Details
local Details = _G.Details
local addonName, Details222 = ...
function _detalhes:WipeConfig()
function Details:WipeConfig()
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local wipeButton = CreateFrame("button", "DetailsResetConfigButton", UIParent, "BackdropTemplate")
wipeButton:SetSize(270, 40)
wipeButton:SetScript("OnClick", function() _detalhes.wipe_full_config = true; ReloadUI(); end)
wipeButton:SetScript("OnClick", function() Details.wipe_full_config = true; ReloadUI(); end)
wipeButton:SetPoint("center", UIParent, "center", 0, 0)
tinsert(UISpecialFrames, "DetailsResetConfigButton")
@@ -30,18 +30,17 @@ local is_exception = {
["nick_tag_cache"] = true
}
function _detalhes:SaveLocalInstanceConfig()
for index, instance in _detalhes:ListInstances() do
function Details:SaveLocalInstanceConfig()
for index, instance in Details:ListInstances() do
--check for the max size toggle, don't save it
if (instance.is_in_max_size) then
instance.is_in_max_size = false
instance:SetSize(instance.original_width, instance.original_height)
end
--save local instance data
local a1, a2 = instance:GetDisplay()
local t = {
pos = Details.CopyTable(instance:GetPosition()),
is_open = instance:IsEnabled(),
@@ -57,13 +56,13 @@ function _detalhes:SaveLocalInstanceConfig()
isLocked = instance.isLocked,
last_raid_plugin = instance.last_raid_plugin
}
if (t.isLocked == nil) then
t.isLocked = false
end
if (_detalhes.profile_save_pos) then
local cprofile = _detalhes:GetProfile()
if (Details.profile_save_pos) then
local cprofile = Details:GetProfile()
local skin = cprofile.instances [instance:GetId()]
if (skin) then
t.pos = Details.CopyTable(skin.__pos)
@@ -74,76 +73,80 @@ function _detalhes:SaveLocalInstanceConfig()
t.isLocked = skin.__locked
end
end
_detalhes.local_instances_config [index] = t
Details.local_instances_config [index] = t
end
end
function _detalhes:SaveConfig()
function Details:SaveConfig()
--save character instance settings, e.g. which attribute is selected, position, etc
Details:SaveLocalInstanceConfig()
--save instance configs localy
_detalhes:SaveLocalInstanceConfig()
--cleanup
_detalhes:PrepareTablesForSave()
Details:PrepareTablesForSave()
_detalhes_database.tabela_instancias = {} --_detalhes.tabela_instancias --[[instances now saves only inside the profile --]]
_detalhes_database.tabela_historico = _detalhes.tabela_historico
if (not _detalhes.overall_clear_logout) then
_detalhes_database.tabela_overall = _detalhes.tabela_overall
_detalhes_database.tabela_instancias = {} --Details.tabela_instancias --[[instances now saves only inside the profile --]]
_detalhes_database.tabela_historico = Details.tabela_historico
if (Details.overall_clear_logout) then
if (_detalhes_database.tabela_overall) then
Details:Destroy(_detalhes_database.tabela_overall)
_detalhes_database.tabela_overall = nil
end
local name, ttype, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()
if (ttype == "party" or ttype == "raid") then
--salvar container de pet
_detalhes_database.tabela_pets = _detalhes.tabela_pets.pets
end
xpcall(_detalhes.TimeDataCleanUpTemporary, _detalhes.saver_error_func)
--buffs
xpcall(_detalhes.Buffs.SaveBuffs, _detalhes.saver_error_func)
else
_detalhes_database.tabela_overall = Details.tabela_overall
--did it prepared the overall table for save?
end
local name, instanceType = GetInstanceInfo()
if (instanceType == "party" or instanceType == "raid") then
--save pet ownership information
_detalhes_database.tabela_pets = Details.tabela_pets.pets
end
--clear temporarly time data (charts)
xpcall(Details.TimeDataCleanUpTemporary, Details.saver_error_func)
--buffs - feature lost in time
xpcall(Details.Buffs.SaveBuffs, Details.saver_error_func)
--date
_detalhes.last_day = date ("%d")
--salva o container do personagem
for key, value in pairs(_detalhes.default_player_data) do
if (not is_exception [key]) then
_detalhes_database [key] = _detalhes [key]
end
end
--salva o container das globais
for key, value in pairs(_detalhes.default_global_data) do
if (key ~= "__profiles") then
_detalhes_global [key] = _detalhes [key]
end
end
Details.last_day = date("%d")
--solo e raid mode
if (_detalhes.SoloTables.Mode) then
_detalhes_database.SoloTablesSaved = {}
_detalhes_database.SoloTablesSaved.Mode = _detalhes.SoloTables.Mode
if (_detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode]) then
_detalhes_database.SoloTablesSaved.LastSelected = _detalhes.SoloTables.Plugins [_detalhes.SoloTables.Mode].real_name
end
--save character data (unique for each character)
for key in pairs(Details.default_player_data) do
if (not is_exception[key]) then
_detalhes_database[key] = Details[key]
end
_detalhes_database.RaidTablesSaved = nil
--salva switch tables
_detalhes_global.switchSaved.slots = _detalhes.switch.slots
_detalhes_global.switchSaved.table = _detalhes.switch.table
--last boss
_detalhes_database.last_encounter = _detalhes.last_encounter
--last versions
_detalhes_database.last_realversion = _detalhes.realversion --core number
_detalhes_database.last_version = _detalhes.userversion --version
_detalhes_global.got_first_run = true
end
--save shared data (shared among all characters)
for key in pairs(Details.default_global_data) do
if (key ~= "__profiles") then
_detalhes_global[key] = Details[key]
end
end
--plugin for solo mode (currently none exists)
if (Details.SoloTables.Mode) then
_detalhes_database.SoloTablesSaved = {}
_detalhes_database.SoloTablesSaved.Mode = Details.SoloTables.Mode
if (Details.SoloTables.Plugins[Details.SoloTables.Mode]) then
_detalhes_database.SoloTablesSaved.LastSelected = Details.SoloTables.Plugins[Details.SoloTables.Mode].real_name
end
end
_detalhes_database.RaidTablesSaved = nil
--save bookmark tables
_detalhes_global.switchSaved.slots = Details.switch.slots
_detalhes_global.switchSaved.table = Details.switch.table
--last boss (boss name)
_detalhes_database.last_encounter = Details.last_encounter
--save the details version of the last time the user logged out
_detalhes_database.last_realversion = Details.realversion --core number
_detalhes_database.last_version = Details.userversion --version
_detalhes_global.got_first_run = true
end
+2 -1
View File
@@ -1056,7 +1056,8 @@ local addonName, Details222 = ...
end
table.wipe(instance1.snap); table.wipe(instance2.snap)
Details:Destroy(instance1.snap)
Details:Destroy(instance2.snap)
instance1.snap [3] = 2; instance2.snap [1] = 1;
instance1.horizontalSnap = true; instance2.horizontalSnap = true
+204 -326
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -74,7 +74,7 @@
local texture = portraitPool.inUse[i]
releaseTextureForPortraitPool(texture)
end
table.wipe(portraitPool.npcIdToTexture)
Details:Destroy(portraitPool.npcIdToTexture)
end)
eventListener:RegisterEvent("COMBAT_ENCOUNTER_START", function()
+154 -154
View File
@@ -1,6 +1,6 @@
local _
local _detalhes = _G.Details
local Details = _G.Details
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local addonName, Details222 = ...
@@ -8,9 +8,9 @@
Details222.TimeCapture = {}
--mantain the enabled time captures
_detalhes.timeContainer = {}
_detalhes.timeContainer.Exec = {}
Details.timeContainer = {}
Details.timeContainer.Exec = {}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--local pointers
local ipairs = ipairs
@@ -28,121 +28,121 @@
local INDEX_VERSION = 5
local INDEX_ICON = 6
local INDEX_ENABLED = 7
local DEFAULT_USER_MATRIX = {max_value = 0, last_value = 0}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--register and unregister captures
function _detalhes:TimeDataUpdate (index_or_name, name, func, matrix, author, version, icon, is_enabled)
function Details:TimeDataUpdate (index_or_name, name, func, matrix, author, version, icon, is_enabled)
local this_capture
if (type(index_or_name) == "number") then
this_capture = _detalhes.savedTimeCaptures [index_or_name]
this_capture = Details.savedTimeCaptures [index_or_name]
else
for index, t in ipairs(_detalhes.savedTimeCaptures) do
for index, t in ipairs(Details.savedTimeCaptures) do
if (t [INDEX_NAME] == index_or_name) then
this_capture = t
end
end
end
if (not this_capture) then
return false
end
if (this_capture.do_not_save) then
return _detalhes:Msg("This capture belongs to a plugin and cannot be edited.")
return Details:Msg("This capture belongs to a plugin and cannot be edited.")
end
this_capture [INDEX_NAME] = name or this_capture [INDEX_NAME]
this_capture [INDEX_FUNCTION] = func or this_capture [INDEX_FUNCTION]
this_capture [INDEX_MATRIX] = matrix or this_capture [INDEX_MATRIX]
this_capture [INDEX_AUTHOR] = author or this_capture [INDEX_AUTHOR]
this_capture [INDEX_VERSION] = version or this_capture [INDEX_VERSION]
this_capture [INDEX_ICON] = icon or this_capture [INDEX_ICON]
if (is_enabled ~= nil) then
this_capture [INDEX_ENABLED] = is_enabled
else
this_capture [INDEX_ENABLED] = this_capture [INDEX_ENABLED]
end
if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then
DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh()
end
return true
end
--matrix = table containing {max_value = 0, last_value = 0}
function _detalhes:TimeDataRegister (name, func, matrix, author, version, icon, is_enabled, force_no_save)
function Details:TimeDataRegister (name, func, matrix, author, version, icon, is_enabled, force_no_save)
--check name
if (not name) then
return "Couldn't register the time capture, name was nil."
end
--check if the name already exists
for index, t in ipairs(_detalhes.savedTimeCaptures) do
for index, t in ipairs(Details.savedTimeCaptures) do
if (t [INDEX_NAME] == name) then
return "Couldn't register the time capture, name already registred."
end
end
--check function
if (not func) then
return "Couldn't register the time capture, invalid function."
end
local no_save = nil
--passed a function means that this isn't came from a user
--so the plugin register the capture every time it loads.
if (type(func) == "function") then
no_save = true
--this a custom capture from a user, so we register a default user table for matrix
elseif (type(func) == "string") then
matrix = DEFAULT_USER_MATRIX
end
if (not no_save and force_no_save) then
no_save = true
end
--check matrix
if (not matrix or type(matrix) ~= "table") then
return "Couldn't register the time capture, matrix was invalid."
end
author = author or "Unknown"
version = version or "v1.0"
icon = icon or [[Interface\InventoryItems\WoWUnknownItem01]]
tinsert(_detalhes.savedTimeCaptures, {name, func, matrix, author, version, icon, is_enabled, do_not_save = no_save})
tinsert(Details.savedTimeCaptures, {name, func, matrix, author, version, icon, is_enabled, do_not_save = no_save})
if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then
DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh()
end
return true
end
--unregister
function _detalhes:TimeDataUnregister (name)
function Details:TimeDataUnregister (name)
if (type(name) == "number") then
tremove(_detalhes.savedTimeCaptures, name)
tremove(Details.savedTimeCaptures, name)
if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then
DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh()
end
else
for index, t in ipairs(_detalhes.savedTimeCaptures) do
for index, t in ipairs(Details.savedTimeCaptures) do
if (t [INDEX_NAME] == name) then
tremove(_detalhes.savedTimeCaptures, index)
tremove(Details.savedTimeCaptures, index)
if (_G.DetailsOptionsWindow and _G.DetailsOptionsWindow:IsShown()) then
DetailsOptionsWindowTab17UserTimeCapturesFillPanel.MyObject:Refresh()
end
@@ -152,39 +152,39 @@
return false
end
end
--cleanup when logout
function _detalhes:TimeDataCleanUpTemporary()
local new_table = {}
for index, t in ipairs(_detalhes.savedTimeCaptures) do
function Details:TimeDataCleanUpTemporary()
local newData = {}
for index, t in ipairs(Details.savedTimeCaptures) do
if (not t.do_not_save) then
tinsert(new_table, t)
tinsert(newData, t)
end
end
_detalhes.savedTimeCaptures = new_table
Details.savedTimeCaptures = newData
end
local tick_time = 0
--starting a combat
function _detalhes:TimeDataCreateCombatTables()
function Details:TimeDataCreateCombatTables()
--create capture table
local data_captured = {}
--drop the last capture exec table without wiping
local exec = {}
_detalhes.timeContainer.Exec = exec
_detalhes:SendEvent("COMBAT_CHARTTABLES_CREATING")
Details.timeContainer.Exec = exec
Details:SendEvent("COMBAT_CHARTTABLES_CREATING")
--build the exec table
for index, t in ipairs(_detalhes.savedTimeCaptures) do
for index, t in ipairs(Details.savedTimeCaptures) do
if (t [INDEX_ENABLED]) then
local data = {}
data_captured [t [INDEX_NAME]] = data
if (type(t [INDEX_FUNCTION]) == "string") then
--user
local func, errortext = loadstring (t [INDEX_FUNCTION])
@@ -192,7 +192,7 @@
DetailsFramework:SetEnvironment(func)
tinsert(exec, { func = func, data = data, attributes = Details.CopyTable(t [INDEX_MATRIX]), is_user = true })
else
_detalhes:Msg("|cFFFF9900error compiling script for time data (charts)|r: ", errortext)
Details:Msg("|cFFFF9900error compiling script for time data (charts)|r: ", errortext)
end
else
--plugin
@@ -200,134 +200,134 @@
DetailsFramework:SetEnvironment(func)
tinsert(exec, { func = func, data = data, attributes = Details.CopyTable(t [INDEX_MATRIX]) })
end
end
end
_detalhes:SendEvent("COMBAT_CHARTTABLES_CREATED")
Details:SendEvent("COMBAT_CHARTTABLES_CREATED")
tick_time = 0
--return the capture table the to combat object
return data_captured
end
local exec_user_func = function(func, attributes, data, this_second)
local okey, result = _pcall (func, attributes)
if (not okey) then
_detalhes:Msg("|cFFFF9900error on chart script function|r:", result)
Details:Msg("|cFFFF9900error on chart script function|r:", result)
result = 0
end
local current = result - attributes.last_value
data [this_second] = current
if (current > attributes.max_value) then
attributes.max_value = current
data.max_value = current
end
attributes.last_value = result
end
function _detalhes:TimeDataTick()
function Details:TimeDataTick()
tick_time = tick_time + 1
for index, t in ipairs(_detalhes.timeContainer.Exec) do
for index, t in ipairs(Details.timeContainer.Exec) do
if (t.is_user) then
--by a user
exec_user_func (t.func, t.attributes, t.data, tick_time)
else
--by a plugin
t.func (t.attributes, t.data, tick_time)
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--broker dps stuff
local ToKFunctions = _detalhes.ToKFunctions
local ToKFunctions = Details.ToKFunctions
local broker_functions = {
-- raid dps [1]
function()
local combat = _detalhes.tabela_vigente
local combat = Details.tabela_vigente
local combatTime = combat:GetCombatTime()
if (not combatTime or combatTime == 0) then
return 0
else
return ToKFunctions [_detalhes.minimap.text_format] (_, combat.totals_grupo[1] / combatTime)
return ToKFunctions [Details.minimap.text_format] (_, combat.totals_grupo[1] / combatTime)
end
end,
-- raid hps [2]
function()
local combat = _detalhes.tabela_vigente
local combat = Details.tabela_vigente
local combatTime = combat:GetCombatTime()
if (not combatTime or combatTime == 0) then
return 0
else
return ToKFunctions [_detalhes.minimap.text_format] (_, combat.totals_grupo[2] / combatTime)
return ToKFunctions [Details.minimap.text_format] (_, combat.totals_grupo[2] / combatTime)
end
end
}
local get_combat_time = function()
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
local combat_time = Details.tabela_vigente:GetCombatTime()
local minutos, segundos = _math_floor(combat_time / 60), _math_floor(combat_time % 60)
if (segundos < 10) then
segundos = "0" .. segundos
end
return minutos .. "m " .. segundos .. "s"
end
local get_damage_position = function()
local damage_container = _detalhes.tabela_vigente [1]
local damage_container = Details.tabela_vigente [1]
damage_container:SortByKey ("total")
local pos = 1
for index, actor in ipairs(damage_container._ActorTable) do
if (actor.grupo) then
if (actor.nome == _detalhes.playername) then
if (actor.nome == Details.playername) then
return pos
end
pos = pos + 1
end
end
return 0
end
local get_heal_position = function()
local heal_container = _detalhes.tabela_vigente [2]
local heal_container = Details.tabela_vigente [2]
heal_container:SortByKey ("total")
local pos = 1
for index, actor in ipairs(heal_container._ActorTable) do
if (actor.grupo) then
if (actor.nome == _detalhes.playername) then
if (actor.nome == Details.playername) then
return pos
end
pos = pos + 1
end
end
return 0
end
local get_damage_diff = function()
local damage_container = _detalhes.tabela_vigente [1]
local damage_container = Details.tabela_vigente [1]
damage_container:SortByKey ("total")
local first
local first_index
for index, actor in ipairs(damage_container._ActorTable) do
@@ -339,7 +339,7 @@
end
if (first) then
if (first.nome == _detalhes.playername) then
if (first.nome == Details.playername) then
local second
local container = damage_container._ActorTable
for i = first_index+1, #container do
@@ -348,32 +348,32 @@
break
end
end
if (second) then
local diff = first.total - second.total
return "+" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff)
return "+" .. ToKFunctions [Details.minimap.text_format] (_, diff)
else
return "0"
end
else
local player = damage_container._NameIndexTable [_detalhes.playername]
local player = damage_container._NameIndexTable [Details.playername]
if (player) then
player = damage_container._ActorTable [player]
local diff = first.total - player.total
return "-" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff)
return "-" .. ToKFunctions [Details.minimap.text_format] (_, diff)
else
return ToKFunctions [_detalhes.minimap.text_format] (_, first.total)
return ToKFunctions [Details.minimap.text_format] (_, first.total)
end
end
else
return "0"
end
end
local get_heal_diff = function()
local heal_container = _detalhes.tabela_vigente [2]
local heal_container = Details.tabela_vigente [2]
heal_container:SortByKey ("total")
local first
local first_index
for index, actor in ipairs(heal_container._ActorTable) do
@@ -383,9 +383,9 @@
break
end
end
if (first) then
if (first.nome == _detalhes.playername) then
if (first.nome == Details.playername) then
local second
local container = heal_container._ActorTable
for i = first_index+1, #container do
@@ -394,42 +394,42 @@
break
end
end
if (second) then
local diff = first.total - second.total
return "+" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff)
return "+" .. ToKFunctions [Details.minimap.text_format] (_, diff)
else
return "0"
end
else
local player = heal_container._NameIndexTable [_detalhes.playername]
local player = heal_container._NameIndexTable [Details.playername]
if (player) then
player = heal_container._ActorTable [player]
local diff = first.total - player.total
return "-" .. ToKFunctions [_detalhes.minimap.text_format] (_, diff)
return "-" .. ToKFunctions [Details.minimap.text_format] (_, diff)
else
return ToKFunctions [_detalhes.minimap.text_format] (_, first.total)
return ToKFunctions [Details.minimap.text_format] (_, first.total)
end
end
else
return "0"
end
end
local get_player_dps = function()
local damage_player = _detalhes.tabela_vigente(1, _detalhes.playername)
local damage_player = Details.tabela_vigente(1, Details.playername)
if (damage_player) then
if (_detalhes.time_type == 1) then --activity time
if (Details.time_type == 1) then --activity time
local combat_time = damage_player:Tempo()
if (combat_time > 0) then
return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total / combat_time)
return ToKFunctions [Details.minimap.text_format] (_, damage_player.total / combat_time)
else
return 0
end
else --effective time
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
local combat_time = Details.tabela_vigente:GetCombatTime()
if (combat_time > 0) then
return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total / combat_time)
return ToKFunctions [Details.minimap.text_format] (_, damage_player.total / combat_time)
else
return 0
end
@@ -439,21 +439,21 @@
return 0
end
end
local get_player_hps = function()
local heal_player = _detalhes.tabela_vigente(2, _detalhes.playername)
local heal_player = Details.tabela_vigente(2, Details.playername)
if (heal_player) then
if (_detalhes.time_type == 1) then --activity time
if (Details.time_type == 1) then --activity time
local combat_time = heal_player:Tempo()
if (combat_time > 0) then
return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total / combat_time)
return ToKFunctions [Details.minimap.text_format] (_, heal_player.total / combat_time)
else
return 0
end
else --effective time
local combat_time = _detalhes.tabela_vigente:GetCombatTime()
local combat_time = Details.tabela_vigente:GetCombatTime()
if (combat_time > 0) then
return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total / combat_time)
return ToKFunctions [Details.minimap.text_format] (_, heal_player.total / combat_time)
else
return 0
end
@@ -463,49 +463,49 @@
return 0
end
end
local get_raid_dps = function()
local damage_raid = _detalhes.tabela_vigente and _detalhes.tabela_vigente.totals [1]
local damage_raid = Details.tabela_vigente and Details.tabela_vigente.totals [1]
if (damage_raid ) then
return ToKFunctions [_detalhes.minimap.text_format] (_, damage_raid / _detalhes.tabela_vigente:GetCombatTime())
return ToKFunctions [Details.minimap.text_format] (_, damage_raid / Details.tabela_vigente:GetCombatTime())
else
return 0
end
end
local get_raid_hps = function()
local healing_raid = _detalhes.tabela_vigente and _detalhes.tabela_vigente.totals [2]
local healing_raid = Details.tabela_vigente and Details.tabela_vigente.totals [2]
if (healing_raid ) then
return ToKFunctions [_detalhes.minimap.text_format] (_, healing_raid / _detalhes.tabela_vigente:GetCombatTime())
return ToKFunctions [Details.minimap.text_format] (_, healing_raid / Details.tabela_vigente:GetCombatTime())
else
return 0
end
end
end
local get_player_damage = function()
local damage_player = _detalhes.tabela_vigente(1, _detalhes.playername)
local damage_player = Details.tabela_vigente(1, Details.playername)
if (damage_player) then
return ToKFunctions [_detalhes.minimap.text_format] (_, damage_player.total)
return ToKFunctions [Details.minimap.text_format] (_, damage_player.total)
else
return 0
end
end
local get_player_heal = function()
local heal_player = _detalhes.tabela_vigente(2, _detalhes.playername)
local heal_player = Details.tabela_vigente(2, Details.playername)
if (heal_player) then
return ToKFunctions [_detalhes.minimap.text_format] (_, heal_player.total)
return ToKFunctions [Details.minimap.text_format] (_, heal_player.total)
else
return 0
end
end
local parse_broker_text = function()
local text = _detalhes.data_broker_text
local text = Details.data_broker_text
if (text == "") then
return
end
text = text:gsub("{dmg}", get_player_damage)
text = text:gsub("{rdps}", get_raid_dps)
text = text:gsub("{rhps}", get_raid_hps)
@@ -520,21 +520,21 @@
return text
end
function _detalhes:BrokerTick()
_detalhes.databroker.text = parse_broker_text()
function Details:BrokerTick()
Details.databroker.text = parse_broker_text()
end
function _detalhes:SetDataBrokerText (text)
function Details:SetDataBrokerText (text)
if (type(text) == "string") then
_detalhes.data_broker_text = text
_detalhes:BrokerTick()
Details.data_broker_text = text
Details:BrokerTick()
elseif (text == nil or (type(text) == "boolean" and not text)) then
_detalhes.data_broker_text = ""
_detalhes:BrokerTick()
Details.data_broker_text = ""
Details:BrokerTick()
end
end
------------------------------------------------------------------------------------------------------
@@ -605,7 +605,7 @@ function Details222.TimeCapture.StopAllUnitTimers()
end
Details222.TimeCapture.Stop(unitName)
end
wipe(Details222.TimeCapture.Timers)
Details:Destroy(Details222.TimeCapture.Timers)
end
--can be a manual stop or from the stop all unit frames (function above)