From 6ccb64863e9380895c927cf6c09b988b92b7424a Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 27 Jun 2023 19:01:44 -0300 Subject: [PATCH] Code changes, see commit description Combat Objects which has been discarded due to any reason will have the boolean member: __destroyed set to true. With this change, 3rd party code can see if the data cached is up to date or obsolete. - Removed several deprecated code from March 2023 and earlier. - Large amount of code cleanup and refactoring, some functions got renamed, they are listed below: * TravarTempos renamed to LockActivityTime. * ClearTempTables renamed to ClearCacheTables. * SpellIsDot renamed to SetAsDotSpell. * FlagCurrentCombat remamed to FlagNewCombat_PVPState. * UpdateContainerCombatentes renamed to UpdatePetCache. * segmentClass:AddCombat(combatObject) renamed to Details222.Combat.AddCombat(combatToBeAdded) - CurrentCombat.verifica_combate timer is now obsolete. - Details.last_closed_combat is now obsolete. - Details.EstaEmCombate is now obsolete. - Details.options is now obsolete. - Added: Details:RemoveSegmentByCombatObject(combatObject) - Spec Guess Timers are now stored within Details222.GuessSpecSchedules.Schedules, all timers are killed at the end of the combat or at a data reset. - Initial time to send startup signal reduced from 5 to 4 seconds. - Fixed some division by zero on ptr 10.1.5. - Fixed DETAILS_STARTED event not triggering in some cases due to 'event not registered'. --- boot.lua | 9 +- classes/class_combat.lua | 65 ++-- classes/class_damage.lua | 25 +- classes/class_instance.lua | 13 +- classes/class_spelldamage.lua | 2 +- classes/class_utility.lua | 2 +- classes/container_actors.lua | 13 +- classes/container_pets.lua | 208 +++++----- classes/container_segments.lua | 333 ++++++++++++---- core/control.lua | 191 ++++----- core/meta.lua | 2 +- core/parser.lua | 82 +--- core/util.lua | 364 ++++++++++-------- .../breakdown_spells_spellframes.lua | 7 +- .../window_playerbreakdown_auras.lua | 209 +++++----- frames/window_options2.lua | 27 +- frames/window_options2_sections.lua | 54 +-- functions/boss.lua | 148 +++---- functions/events.lua | 5 +- functions/loaddata.lua | 4 +- functions/playerclass.lua | 6 + functions/spellcache.lua | 6 +- startup.lua | 4 +- 23 files changed, 971 insertions(+), 808 deletions(-) diff --git a/boot.lua b/boot.lua index 28be4bbe..854758b8 100644 --- a/boot.lua +++ b/boot.lua @@ -84,7 +84,10 @@ Details222.Pets = {} --auto run code Details222.AutoRunCode = {} + --options panel + Details222.OptionsPanel = {} Details222.Instances = {} + Details222.Combat = {} Details222.MythicPlus = {} Details222.EJCache = {} Details222.Segments = {} @@ -98,7 +101,9 @@ Details222.PlayerStats = {} Details222.LoadSavedVariables = {} Details222.SaveVariables = {} - + Details222.GuessSpecSchedules = { + Schedules = {}, + } Details222.TimeMachine = {} Details222.Date = { @@ -1087,7 +1092,7 @@ do _detalhes.tabela_overall = _detalhes.combate:NovaTabela() _detalhes.tabela_vigente = _detalhes.combate:NovaTabela (_, _detalhes.tabela_overall) _detalhes.tabela_pets = _detalhes.container_pets:NovoContainer() - _detalhes:UpdateContainerCombatentes() + _detalhes:UpdatePetCache() _detalhes_database.tabela_overall = nil _detalhes_database.tabela_historico = nil diff --git a/classes/class_combat.lua b/classes/class_combat.lua index 4c7f85b7..bf82f214 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -408,7 +408,7 @@ ---copy deaths from combat2 into combat1 ---if bMythicPlus is true it'll check if the death has mythic plus death time and use it instead of the normal death time - ---@param combat1 combat + ---@param combat1 combat ---@param combat2 combat ---@param bMythicPlus boolean function classCombat.CopyDeathsFrom(combat1, combat2, bMythicPlus) @@ -720,43 +720,52 @@ end ---@return table function classCombat:CreateLastEventsTable(playerName) local lastEventsTable = {} + for i = 1, Details.deadlog_events do - lastEventsTable [i] = {} + lastEventsTable[i] = {} end + lastEventsTable.n = 1 self.player_last_events[playerName] = lastEventsTable return lastEventsTable end - --trava o tempo dos jogadores ap�s o t�rmino do combate. - function classCombat:TravarTempos() - if (self [1]) then - for _, jogador in ipairs(self [1]._ActorTable) do --damage - if (jogador:GetOrChangeActivityStatus()) then -- retorna se ele esta com o dps ativo - Details222.TimeMachine.StopTime(jogador) - jogador:GetOrChangeActivityStatus(false) --lock the actor timer - else - if (jogador.start_time == 0) then - jogador.start_time = _tempo - end - if (not jogador.end_time) then - jogador.end_time = _tempo - end + ---pass through all actors and check if the activity time is unlocked, if it is, lock it + ---@param self combat + function classCombat:LockActivityTime() + ---@cast self combat + ---@type actorcontainer + local containerDamage = self:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + ---@type actorcontainer + local containerHeal = self:GetContainer(DETAILS_ATTRIBUTE_HEAL) + + for _, actorObject in containerDamage:ListActors() do + if (actorObject:GetOrChangeActivityStatus()) then --check if the timer is unlocked + Details222.TimeMachine.StopTime(actorObject) + actorObject:GetOrChangeActivityStatus(false) --lock the actor timer + else + if (actorObject.start_time == 0) then + actorObject.start_time = _tempo + end + if (not actorObject.end_time) then + actorObject.end_time = _tempo end end end - if (self [2]) then - for _, jogador in ipairs(self [2]._ActorTable) do --healing - if (jogador:GetOrChangeActivityStatus()) then -- retorna se ele esta com o dps ativo - Details222.TimeMachine.StopTime(jogador) - jogador:GetOrChangeActivityStatus(false) --lock the actor timer - else - if (jogador.start_time == 0) then - jogador.start_time = _tempo - end - if (not jogador.end_time) then - jogador.end_time = _tempo - end + + for _, actorObject in containerHeal:ListActors() do + --check if the timer is unlocked + if (actorObject:GetOrChangeActivityStatus()) then + --lock the actor timer + Details222.TimeMachine.StopTime(actorObject) + --remove the actor from the time machine + actorObject:GetOrChangeActivityStatus(false) + else + if (actorObject.start_time == 0) then + actorObject.start_time = _tempo + end + if (not actorObject.end_time) then + actorObject.end_time = _tempo end end end diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 4972e546..74fcb39d 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -373,18 +373,18 @@ function Details:GetSpellLink(spellid) --[[exported]] end end -function Details:GameTooltipSetSpellByID(spellid) --[[exported]] - if (spellid == 1) then +function Details:GameTooltipSetSpellByID(spellId) --[[exported]] + if (spellId == 1) then GameTooltip:SetSpellByID(6603) - elseif (spellid == 2) then + elseif (spellId == 2) then GameTooltip:SetSpellByID(75) - elseif (spellid > 10) then - GameTooltip:SetSpellByID(spellid) + elseif (spellId > 10) then + GameTooltip:SetSpellByID(spellId) else - GameTooltip:SetSpellByID(spellid) + GameTooltip:SetSpellByID(spellId) end end @@ -6201,10 +6201,11 @@ function damageClass:MontaTooltipAlvos (thisLine, index, instancia) --~deprecate return true end ---controla se o dps do jogador esta travado ou destravado +--controls the activity time of the actor function damageClass:GetOrChangeActivityStatus(activityStatus) if (activityStatus == nil) then - return self.dps_started --retorna se o dps esta aberto ou fechado para este jogador + --if no value passed, return the current activity status + return self.dps_started elseif (activityStatus) then self.dps_started = true @@ -6219,14 +6220,16 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --core functions - --limpa as tabelas tempor�rias ao ResetAllCombatData - function damageClass:ClearTempTables() + --clear cache tables when resetting data + function damageClass:ClearCacheTables() for i = #ntable, 1, -1 do ntable [i] = nil end + for i = #vtable, 1, -1 do vtable [i] = nil end + for i = #bs_table, 1, -1 do bs_table [i] = nil end @@ -6234,9 +6237,11 @@ end if (bs_tooltip_table) then Details:Destroy(bs_tooltip_table) end + if (frags_tooltip_table) then Details:Destroy(frags_tooltip_table) end + Details:Destroy(bs_index_table) Details:Destroy(tooltip_temp_table) Details:Destroy(tooltip_void_zone_temp) diff --git a/classes/class_instance.lua b/classes/class_instance.lua index 9a52862d..83f44d7a 100644 --- a/classes/class_instance.lua +++ b/classes/class_instance.lua @@ -2525,17 +2525,22 @@ function Details:UpdateCombatObjectInUse(instance) end end -function Details:AtualizaSegmentos_AfterCombat (instancia, historico) +function Details:AtualizaSegmentos_AfterCombat(instancia) if (instancia.freezed) then - return --se esta congelada n�o tem o que fazer + return end local segmento = instancia.segmento + ---@type combat[] + local segmentsTable = Details:GetCombatSegments() + local _fadeType, _fadeSpeed = _unpack(Details.row_fade_in) + --todo: translate comments here + if (segmento == Details.segments_amount) then --significa que o index [5] passou a ser [6] com a entrada da nova tabela - instancia.showing = historico.tabelas [Details.segments_amount] --ent�o ele volta a pegar o index [5] que antes era o index [4] + instancia.showing = segmentsTable[Details.segments_amount] --ent�o ele volta a pegar o index [5] que antes era o index [4] --print("==> Changing the Segment now! - classe_instancia.lua 1942") Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras") instancia.showing[instancia.atributo].need_refresh = true @@ -2545,7 +2550,7 @@ function Details:AtualizaSegmentos_AfterCombat (instancia, historico) Details:AtualizarJanela (instancia) elseif (segmento < Details.segments_amount and segmento > 0) then - instancia.showing = historico.tabelas [segmento] + instancia.showing = segmentsTable[segmento] --print("==> Changing the Segment now! - classe_instancia.lua 1952") Details.FadeHandler.Fader(instancia, _fadeType, _fadeSpeed, "barras") --"in", nil diff --git a/classes/class_spelldamage.lua b/classes/class_spelldamage.lua index c83e0295..a2c019cb 100644 --- a/classes/class_spelldamage.lua +++ b/classes/class_spelldamage.lua @@ -63,7 +63,7 @@ function classDamageSpellTable:NovaTabela(spellId, link, token) } if (token == "SPELL_PERIODIC_DAMAGE") then - Details:SpellIsDot(spellId) + Details:SetAsDotSpell(spellId) end return spellTable diff --git a/classes/class_utility.lua b/classes/class_utility.lua index 03ce3813..b349be4c 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -1336,7 +1336,7 @@ function _detalhes:CatchRaidDebuffUptime (in_or_out) -- "DEBUFF_UPTIME_IN" if (in_or_out == "DEBUFF_UPTIME_OUT") then local combat = _detalhes.tabela_vigente - local misc_container = combat [4]._ActorTable + local misc_container = combat [4]._ActorTable --error attempt to index a new value for _, actor in ipairs(misc_container) do if (actor.debuff_uptime) then diff --git a/classes/container_actors.lua b/classes/container_actors.lua index 6365a247..1478caa2 100644 --- a/classes/container_actors.lua +++ b/classes/container_actors.lua @@ -198,7 +198,7 @@ end if (actorObject) then return actorObject.nome, playerGUID, actorObject.flag_original end - + local guidCache = Details:GetParserPlayerCache() --cache exists until the next combat starts local ownerName = guidCache[playerGUID] if (ownerName) then @@ -227,7 +227,7 @@ end if (actorObject) then return actorObject.nome, playerGUID, actorObject.flag_original end - + local guidCache = Details:GetParserPlayerCache() --cache exists until the next combat starts local ownerName = guidCache[playerGUID] if (ownerName) then @@ -277,7 +277,7 @@ end --Details:Msg("(debug) pet found (2)", petName, "owner:", ownerName) return ownerName, GUID, 0x514 end - + if(Details.zone_type == 'arena') then --Attempt to find enemy pet owner for enemyName, enemyToken in pairs(Details.arena_enemies) do if(UnitGUID(enemyToken) == ownerGUID) then @@ -305,7 +305,7 @@ end ownerName = actorName ownerFlags = 0x514 else - + if (CONST_CLIENT_LANGUAGE == "ruRU") then --If russian client, then test for declensions in the string of text. for playerName, _ in pairs(Details.tabela_vigente.raid_roster) do local pName = playerName @@ -455,7 +455,8 @@ end end if (not specId and Details.track_specs) then - Details:ScheduleTimer("GuessSpec", 3, {actorObject, nil, 1}) + local newTimer = Details:ScheduleTimer("GuessSpec", 3, {actorObject, nil, 1}) + Details222.GuessSpecSchedules.Schedules[#Details222.GuessSpecSchedules.Schedules+1] = newTimer end local _, engClass = UnitClass(actorName or "") @@ -870,7 +871,7 @@ end end end - function Details:UpdateContainerCombatentes() + function Details:UpdatePetCache() container_pets = Details.tabela_pets.pets Details:UpdatePetsOnParser() end diff --git a/classes/container_pets.lua b/classes/container_pets.lua index d55cb2cc..eb2891a8 100644 --- a/classes/container_pets.lua +++ b/classes/container_pets.lua @@ -1,97 +1,96 @@ -local _detalhes = _G.Details -local gump = _detalhes.gump -local container_pets = _detalhes.container_pets + +local Details = _G.Details +local container_pets = Details.container_pets local _ local addonName, Details222 = ... --- api locals local UnitGUID = _G.UnitGUID -local _UnitName = _G.UnitName -local _GetUnitName = _G.GetUnitName +local UnitName = _G.UnitName +local GetUnitName = _G.GetUnitName local IsInRaid = _G.IsInRaid local IsInGroup = _G.IsInGroup local GetNumGroupMembers = _G.GetNumGroupMembers - --- lua locals local setmetatable = setmetatable -local _bit_band = bit.band --lua local +local bitBand = bit.band --lua local local pairs = pairs --details locals -local is_ignored = _detalhes.pets_ignored +local bIsIgnored = Details.pets_ignored function container_pets:NovoContainer() - local esta_tabela = {} - setmetatable(esta_tabela, _detalhes.container_pets) - esta_tabela.pets = {} --armazena a pool -> uma dictionary com o [serial do pet] -> nome do dono - esta_tabela._ActorTable = {} --armazena os 15 ultimos pets do jogador -> [jogador nome] -> {nil, nil, nil, ...} - return esta_tabela + local newPetContainer = {} + setmetatable(newPetContainer, Details.container_pets) + + ---@type petinfo + local newPetCacheTable = {} + newPetContainer.pets = newPetCacheTable + + newPetContainer._ActorTable = {} + return newPetContainer end local OBJECT_TYPE_PET = 0x00001000 -local EM_GRUPO = 0x00000007 -local PET_EM_GRUPO = 0x00001007 - -function container_pets:PegaDono (pet_serial, pet_nome, pet_flags) +local OBJECT_IN_GROUP = 0x00000007 +function container_pets:PegaDono(petGUID, petName, petFlags) --sair se o pet estiver na ignore - if (is_ignored [pet_serial]) then + if (bIsIgnored[petGUID]) then return end --buscar pelo pet no container de pets - local busca = self.pets [pet_serial] + local busca = self.pets[petGUID] if (busca) then --in merging operations, make sure to not add the owner name a second time in the name - + --check if the pet name already has the owner name in, if not, add it - if (not pet_nome:find("<")) then + if (not petName:find("<")) then --get the owner name local ownerName = busca[1] --add the owner name to the pet name - pet_nome = pet_nome .. " <".. ownerName ..">" + petName = petName .. " <".. ownerName ..">" end - + --return busca[6] or pet_nome, busca[1], busca[2], busca[3] --busca[6] poderia estar causando problemas - return pet_nome, busca[1], busca[2], busca[3] --[1] dono nome [2] dono serial [3] dono flag + return petName, busca[1], busca[2], busca[3] --[1] dono nome[2] dono serial[3] dono flag end - + --buscar pelo pet na raide local dono_nome, dono_serial, dono_flags - + if (IsInRaid()) then - for i = 1, GetNumGroupMembers() do - if (pet_serial == UnitGUID("raidpet"..i)) then + for i = 1, GetNumGroupMembers() do + if (petGUID == UnitGUID("raidpet"..i)) then dono_serial = UnitGUID("raid"..i) dono_flags = 0x00000417 --emulate sourceflag flag - - local nome, realm = _UnitName ("raid"..i) + + local nome, realm = UnitName("raid"..i) if (realm and realm ~= "") then nome = nome.."-"..realm end dono_nome = nome end end - + elseif (IsInGroup()) then - for i = 1, GetNumGroupMembers()-1 do - if (pet_serial == UnitGUID("partypet"..i)) then + for i = 1, GetNumGroupMembers()-1 do + if (petGUID == UnitGUID("partypet"..i)) then dono_serial = UnitGUID("party"..i) dono_flags = 0x00000417 --emulate sourceflag flag - - local nome, realm = _UnitName ("party"..i) + + local nome, realm = UnitName("party"..i) if (realm and realm ~= "") then nome = nome.."-"..realm end - + dono_nome = nome end end end - + if (not dono_nome) then - if (pet_serial == UnitGUID("pet")) then - dono_nome = _GetUnitName ("player") + if (petGUID == UnitGUID("pet")) then + dono_nome = GetUnitName("player") dono_serial = UnitGUID("player") if (IsInGroup() or IsInRaid()) then dono_flags = 0x00000417 --emulate sourceflag flag @@ -100,152 +99,153 @@ function container_pets:PegaDono (pet_serial, pet_nome, pet_flags) end end end - + if (dono_nome) then - self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, true, pet_nome, pet_serial} --adicionada a flag emulada - - if (not pet_nome:find("<")) then - pet_nome = pet_nome .. " <".. dono_nome ..">" + self.pets[petGUID] = {dono_nome, dono_serial, dono_flags, Details._tempo, true, petName, petGUID} --adicionada a flag emulada + + if (not petName:find("<")) then + petName = petName .. " <".. dono_nome ..">" end - - return pet_nome, dono_nome, dono_serial, dono_flags + + return petName, dono_nome, dono_serial, dono_flags else - - if (pet_flags and _bit_band (pet_flags, OBJECT_TYPE_PET) ~= 0) then --� um pet - if (not _detalhes.pets_no_owner [pet_serial] and _bit_band (pet_flags, EM_GRUPO) ~= 0) then - _detalhes.pets_no_owner [pet_serial] = {pet_nome, pet_flags} - _detalhes:Msg("couldn't find the owner of the pet:", pet_nome) + + if (petFlags and bitBand(petFlags, OBJECT_TYPE_PET) ~= 0) then --� um pet + if (not Details.pets_no_owner[petGUID] and bitBand(petFlags, OBJECT_IN_GROUP) ~= 0) then + Details.pets_no_owner[petGUID] = {petName, petFlags} + Details:Msg("couldn't find the owner of the pet:", petName) end else - is_ignored [pet_serial] = true + bIsIgnored[petGUID] = true end end return end -function container_pets:Unpet (...) +function container_pets:Unpet(...) local unitid = ... local owner_serial = UnitGUID(unitid) - + if (owner_serial) then --tira o pet existente da tabela de pets e do cache do core - local existing_pet_serial = _detalhes.pets_players [owner_serial] + local existing_pet_serial = Details.pets_players[owner_serial] if (existing_pet_serial) then - _detalhes.parser:RevomeActorFromCache (existing_pet_serial) - container_pets:Remover (existing_pet_serial) - _detalhes.pets_players [owner_serial] = nil + Details.parser:RevomeActorFromCache(existing_pet_serial) + container_pets:Remover(existing_pet_serial) + Details.pets_players[owner_serial] = nil end --verifica se h� um pet novo deste jogador local pet_serial = UnitGUID(unitid .. "pet") if (pet_serial) then - if (not _detalhes.tabela_pets.pets [pet_serial]) then - local nome, realm = _UnitName (unitid) + if (not Details.tabela_pets.pets[pet_serial]) then + local nome, realm = UnitName(unitid) if (realm and realm ~= "") then nome = nome.."-"..realm end - _detalhes.tabela_pets:Adicionar (pet_serial, _UnitName (unitid .. "pet"), 0x1114, owner_serial, nome, 0x514) + Details.tabela_pets:Adicionar(pet_serial, UnitName(unitid .. "pet"), 0x1114, owner_serial, nome, 0x514) end - _detalhes.parser:RevomeActorFromCache (pet_serial) - container_pets:PlayerPet (owner_serial, pet_serial) + Details.parser:RevomeActorFromCache(pet_serial) + container_pets:PlayerPet(owner_serial, pet_serial) end end end -function container_pets:PlayerPet (player_serial, pet_serial) - _detalhes.pets_players [player_serial] = pet_serial +function container_pets:PlayerPet(player_serial, pet_serial) + Details.pets_players[player_serial] = pet_serial end function container_pets:BuscarPets() if (IsInRaid()) then - for i = 1, GetNumGroupMembers(), 1 do + for i = 1, GetNumGroupMembers(), 1 do local pet_serial = UnitGUID("raidpet"..i) if (pet_serial) then - if (not _detalhes.tabela_pets.pets [pet_serial]) then - local nome, realm = _UnitName ("raid"..i) + if (not Details.tabela_pets.pets[pet_serial]) then + local nome, realm = UnitName("raid"..i) if (realm and realm ~= "") then nome = nome.."-"..realm end local owner_serial = UnitGUID("raid"..i) - _detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("raidpet"..i), 0x1114, owner_serial, nome, 0x514) - _detalhes.parser:RevomeActorFromCache (pet_serial) - container_pets:PlayerPet (owner_serial, pet_serial) + Details.tabela_pets:Adicionar(pet_serial, UnitName("raidpet"..i), 0x1114, owner_serial, nome, 0x514) + Details.parser:RevomeActorFromCache(pet_serial) + container_pets:PlayerPet(owner_serial, pet_serial) end end end - + elseif (IsInGroup()) then - for i = 1, GetNumGroupMembers()-1, 1 do + for i = 1, GetNumGroupMembers()-1, 1 do local pet_serial = UnitGUID("partypet"..i) if (pet_serial) then - if (not _detalhes.tabela_pets.pets [pet_serial]) then - local nome, realm = _UnitName ("party"..i) + if (not Details.tabela_pets.pets[pet_serial]) then + local nome, realm = UnitName("party"..i) if (realm and realm ~= "") then nome = nome.."-"..realm end - _detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("partypet"..i), 0x1114, UnitGUID("party"..i), nome, 0x514) + Details.tabela_pets:Adicionar(pet_serial, UnitName("partypet"..i), 0x1114, UnitGUID("party"..i), nome, 0x514) end end end - + local pet_serial = UnitGUID("pet") if (pet_serial) then - if (not _detalhes.tabela_pets.pets [pet_serial]) then - _detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("pet"), 0x1114, UnitGUID("player"), _detalhes.playername, 0x514) + if (not Details.tabela_pets.pets[pet_serial]) then + Details.tabela_pets:Adicionar(pet_serial, UnitName("pet"), 0x1114, UnitGUID("player"), Details.playername, 0x514) end end - + else local pet_serial = UnitGUID("pet") if (pet_serial) then - if (not _detalhes.tabela_pets.pets [pet_serial]) then - _detalhes.tabela_pets:Adicionar (pet_serial, _UnitName ("pet"), 0x1114, UnitGUID("player"), _detalhes.playername, 0x514) + if (not Details.tabela_pets.pets[pet_serial]) then + Details.tabela_pets:Adicionar(pet_serial, UnitName("pet"), 0x1114, UnitGUID("player"), Details.playername, 0x514) end end end end -function container_pets:Remover (pet_serial) - if (_detalhes.tabela_pets.pets [pet_serial]) then - Details:Destroy(_detalhes.tabela_pets.pets [pet_serial]) +function container_pets:Remover(pet_serial) + if (Details.tabela_pets.pets[pet_serial]) then + Details:Destroy(Details.tabela_pets.pets[pet_serial]) end - _detalhes.tabela_pets.pets [pet_serial] = nil + Details.tabela_pets.pets[pet_serial] = nil end -function container_pets:Adicionar (pet_serial, pet_nome, pet_flags, dono_serial, dono_nome, dono_flags) - if (pet_flags and _bit_band (pet_flags, OBJECT_TYPE_PET) ~= 0 and _bit_band (pet_flags, EM_GRUPO) ~= 0) then - self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, true, pet_nome, pet_serial} +function container_pets:Adicionar(pet_serial, pet_nome, pet_flags, dono_serial, dono_nome, dono_flags) + if (pet_flags and bitBand(pet_flags, OBJECT_TYPE_PET) ~= 0 and bitBand(pet_flags, OBJECT_IN_GROUP) ~= 0) then + self.pets[pet_serial] = {dono_nome, dono_serial, dono_flags, Details._tempo, true, pet_nome, pet_serial} else - self.pets [pet_serial] = {dono_nome, dono_serial, dono_flags, _detalhes._tempo, false, pet_nome, pet_serial} + self.pets[pet_serial] = {dono_nome, dono_serial, dono_flags, Details._tempo, false, pet_nome, pet_serial} end end -function _detalhes:WipePets() - return Details:Destroy(_detalhes.tabela_pets.pets) +function Details:WipePets() + return Details:Destroy(Details.tabela_pets.pets) end -function _detalhes:PetContainerCleanup() +function Details222.Pets.PetContainerCleanup() --erase old pet table by creating a new one local newPetTable = {} + --minimum of 90 minutes to clean a pet from the pet table data - for PetSerial, PetTable in pairs(_detalhes.tabela_pets.pets) do - if ( (PetTable[4] + 5400 > _detalhes._tempo + 1) or (PetTable[5] and PetTable[4] + 43200 > _detalhes._tempo) ) then - newPetTable [PetSerial] = PetTable + for petGUID, petTable in pairs(Details.tabela_pets.pets) do + if ((petTable[4] + 5400 > Details._tempo + 1) or (petTable[5] and petTable[4] + 43200 > Details._tempo)) then + newPetTable[petGUID] = petTable end end - _detalhes.tabela_pets.pets = newPetTable - _detalhes:UpdateContainerCombatentes() - + + Details.tabela_pets.pets = newPetTable + Details:UpdatePetCache() end local have_schedule = false -function _detalhes:UpdatePets() +function Details:UpdatePets() have_schedule = false return container_pets:BuscarPets() end -function _detalhes:SchedulePetUpdate(seconds) +function Details:SchedulePetUpdate(seconds) if (have_schedule) then return end @@ -255,7 +255,7 @@ function _detalhes:SchedulePetUpdate(seconds) Details.Schedules.NewTimer(seconds or 5, Details.UpdatePets, Details) end -function _detalhes.refresh:r_container_pets (container) +function Details.refresh:r_container_pets(container) setmetatable(container, container_pets) end diff --git a/classes/container_segments.lua b/classes/container_segments.lua index 1bac781a..561b94ca 100644 --- a/classes/container_segments.lua +++ b/classes/container_segments.lua @@ -6,6 +6,7 @@ local addonName, Details222 = ... local combatClass = Details.combate local segmentClass = Details.historico local bitBand = bit.band +local wipe = table.wipe ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --API @@ -67,6 +68,22 @@ function Details:RemoveSegment(segmentIndex) return segmentRemoved ~= nil, segmentRemoved end +---remove a combat from the segments list by it's combat object +---@param combatObject any +---@return boolean, combat|nil +function Details:RemoveSegmentByCombatObject(combatObject) + if (combatObject) then + local segmentsTable = Details:GetCombatSegments() + for i = 1, #segmentsTable do + if (segmentsTable[i] == combatObject) then + local combatObjectRemoved = table.remove(segmentsTable, i) + return true, combatObjectRemoved + end + end + end + return false +end + --returns a private table containing all stored segments function Details:GetCombatSegments() return Details.tabela_historico.tabelas @@ -75,6 +92,16 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --internal +function Details222.GuessSpecSchedules.ClearSchedules() + for i = 1, #Details222.GuessSpecSchedules.Schedules do + local schedule = Details222.GuessSpecSchedules.Schedules[i] + if (schedule) then + Details:CancelTimer(schedule) + end + end + wipe(Details222.GuessSpecSchedules.Schedules) +end + function segmentClass:CreateNewSegmentDatabase() local newSegmentDatabase = {tabelas = {}} setmetatable(newSegmentDatabase, segmentClass) @@ -186,15 +213,6 @@ function Details:CanAddCombatToOverall(combatObject) return false end - --already scheduled to add - if (Details.schedule_add_to_overall) then --deprecated - for _, combat in ipairs(Details.schedule_add_to_overall) do - if (combat == combatObject) then - return false - end - end - end - --special cases local mythicInfo = combatObject.is_mythic_dungeon if (mythicInfo) then @@ -250,9 +268,193 @@ function Details:CanAddCombatToOverall(combatObject) return false end +---count boss tries and set the value in the combat object +---@param combatToBeAdded combat +local setBossTryCounter = function(combatToBeAdded, segmentsTable, amountSegmentsInUse) + ---@type string + local bossName = combatToBeAdded.is_boss and combatToBeAdded.is_boss.name + + if (bossName) then + local tryNumber = Details.encounter_counter[bossName] + if (not tryNumber) then + ---@type combat + local previousCombatObject + + for i = 1, amountSegmentsInUse do + previousCombatObject = segmentsTable[i] + if (previousCombatObject and previousCombatObject.is_boss and previousCombatObject.is_boss.name and previousCombatObject.is_boss.try_number and previousCombatObject.is_boss.name == bossName and not previousCombatObject.is_boss.killed) then + tryNumber = previousCombatObject.is_boss.try_number + 1 + break + end + end + + if (not tryNumber) then + tryNumber = 1 + end + else + tryNumber = Details.encounter_counter[bossName] + 1 + end + + Details.encounter_counter[bossName] = tryNumber + combatToBeAdded.is_boss.try_number = tryNumber + end +end + +---add the combat to the segment table, check adding to overall +---@param combatToBeAdded combat +function Details222.Combat.AddCombat(combatToBeAdded) + ---@type number how many segments the user wants to store + local maxSegmentsAllowed = Details.segments_amount + + ---@type combat[] + local segmentsTable = Details:GetCombatSegments() + + ---@type number amount of segments currently stored + local amountSegmentsInUse = #segmentsTable + + ---@debug check if there's a destroyed segment within the segment container + if (amountSegmentsInUse > 0) then + for i = 1, amountSegmentsInUse do + local thisCombatObject = segmentsTable[i] + if (thisCombatObject.__destroyed) then + Details:Msg("(debug) container_segments line: 329 (__destroyed combat in segments container)") + end + end + end + ---@end-debug + + ---@type boolean + local bSegmentDestroyed = false + + --check all instances for freeze state + if (amountSegmentsInUse < maxSegmentsAllowed) then + --if there's no segment stored, then this as the first segment + if (amountSegmentsInUse == 0) then + Details:InstanciaCallFunction(Details.CheckFreeze, amountSegmentsInUse + 1, combatToBeAdded) + else + ---@type combat + local oldestCombatObject = segmentsTable[amountSegmentsInUse] + Details:InstanciaCallFunction(Details.CheckFreeze, amountSegmentsInUse + 1, oldestCombatObject) + end + end + + setBossTryCounter(combatToBeAdded, segmentsTable, amountSegmentsInUse) + + --shutdown actors from the previous combat from the time machine + ---@type combat + local previousCombatObject = segmentsTable[1] + if (previousCombatObject) then + ---@type actorcontainer + local containerDamage = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + ---@type actorcontainer + local containerHeal = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL) + + for _, actorObject in containerDamage:ListActors() do + ---@cast actorObject actor + --clear last events table (death logs) + actorObject.last_events_table = nil + --remove from the time machine + Details222.TimeMachine.RemoveActor(actorObject) + end + + for _, actorObject in containerHeal:ListActors() do + ---@cast actorObject actor + --clear last events table (death logs) + actorObject.last_events_table = nil + --remove from the time machine + Details222.TimeMachine.RemoveActor(actorObject) + end + end + + ---@type boolean user choise to remove trash combats or nor + local bAutoRemoveTrashCombats = Details.trash_auto_remove + if (bAutoRemoveTrashCombats) then + ---@type combat + local combatToCheckForTrash = segmentsTable[2] + + if (combatToCheckForTrash) then + local bIsFromMythicDungeon = combatToCheckForTrash.is_mythic_dungeon_segment + if (not bIsFromMythicDungeon) then + local bCombatIsTrash = combatToCheckForTrash.is_trash and not combatToCheckForTrash.is_boss + local bCombatIsWorldTrash = combatToCheckForTrash.is_world_trash_combat + + if (bCombatIsTrash or bCombatIsWorldTrash) then + ---@type boolean, combat|nil + local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegmentByCombatObject(combatToCheckForTrash) + if (bSegmentRemoved and combatObjectRemoved == combatToCheckForTrash) then + Details:DestroyCombat(combatObjectRemoved) + bSegmentDestroyed = true + end + end + end + end + end + + --update the amount of segments in use in case a segment was removed + amountSegmentsInUse = #segmentsTable + + --add +1 into the amount of segments in use to count for the combat which will be added at the end of this function + local amountOfSegmentsInUsePlusOne = amountSegmentsInUse + 1 + + --check if the segment table will exceed the amount of segments allowed (user setting) + if (amountOfSegmentsInUsePlusOne > maxSegmentsAllowed) then + ---@type combat last combat in the segment table + local combatObjectToBeRemoved = segmentsTable[amountSegmentsInUse] + + ---@type boolean, combat|nil + local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegmentByCombatObject(combatObjectToBeRemoved) + if (bSegmentRemoved and combatObjectRemoved == combatObjectToBeRemoved) then + Details:DestroyCombat(combatObjectRemoved) + bSegmentDestroyed = true + end + end + + --update the amount of segments in use in case a segment was removed + amountSegmentsInUse = #segmentsTable + + ---@debug check if there's a destroyed segment within the segment container + if (amountSegmentsInUse > 0) then + for i = 1, amountSegmentsInUse do + local thisCombatObject = segmentsTable[i] + if (thisCombatObject.__destroyed) then + Details:Msg("(debug) container_segments line: 418 (__destroyed combat in segments container)") + end + end + end + ---@end-debug + + --insert the combat into the segments table + table.insert(segmentsTable, 1, combatToBeAdded) + + --see if can add the encounter to overall data + local bCanAddToOverall = Details:CanAddCombatToOverall(combatToBeAdded) + + if (bCanAddToOverall) then + if (Details.debug) then + Details:Msg("(debug) overall data flag match addind the combat to overall data.") + end + --add to overall data + segmentClass:AddToOverallData(combatToBeAdded) + end + + Details:InstanceCall(function(instanceObject) instanceObject:RefreshCombat() end) + + --update the combat shown on all instances + Details:InstanciaCallFunction(Details.AtualizaSegmentos_AfterCombat) + + if (bSegmentDestroyed) then + Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED") + end +end + + ---add the combat to the segment table, check adding to overall ---@param combatObject combat function segmentClass:AddCombat(combatObject) + if true then + return Details222.Combat.AddCombat(combatObject) + end + ---@type combat[] local segmentsTable = Details:GetCombatSegments() ---@type number @@ -261,7 +463,7 @@ function segmentClass:AddCombat(combatObject) local bSegmentDestroyed = false --check all instances for freeze state - if (#segmentsTable < maxSegmentsAllowed) then + if (#segmentsTable < maxSegmentsAllowed) then --done ---@type combat local oldestCombatObject = segmentsTable[#segmentsTable] --if there's no segment stored, then this as the first segment @@ -272,12 +474,12 @@ function segmentClass:AddCombat(combatObject) end --add to the first index of the segment table - table.insert(segmentsTable, 1, combatObject) + --table.insert(segmentsTable, 1, combatObject) --will be added at the end --count boss tries ---@type string local bossName = combatObject.is_boss and combatObject.is_boss.name - if (bossName) then + if (bossName) then --done local tryNumber = Details.encounter_counter[bossName] if (not tryNumber) then @@ -304,7 +506,6 @@ function segmentClass:AddCombat(combatObject) --see if can add the encounter to overall data local canAddToOverall = Details:CanAddCombatToOverall(combatObject) - if (canAddToOverall) then if (Details.debug) then Details:Msg("(debug) overall data flag match addind the combat to overall data.") @@ -497,10 +698,6 @@ function segmentClass:ResetOverallData() end end - if (Details.schedule_add_to_overall) then --deprecated - Details:Destroy(Details.schedule_add_to_overall) - end - --stop bar testing if any Details:StopTestBarUpdate() Details:ClockPluginTickOnSegment() @@ -509,20 +706,33 @@ function segmentClass:ResetOverallData() end function segmentClass:ResetAllCombatData() + if (Details:IsInCombat()) then + Details:EndCombat() + end + if (Details.bosswindow) then Details.bosswindow:Reset() end + Details222.GuessSpecSchedules.ClearSchedules() + --stop bar testing if any Details:StopTestBarUpdate() + --close breakdown window + Details:CloseBreakdownWindow() + --empty damage class cache tables + Details.atributo_damage:ClearCacheTables() + --clear caches + Details:ClearSpellCache() + Details:Destroy(Details.ShieldCache) + Details:Destroy(Details.cache_damage_group) + Details:Destroy(Details.cache_healing_group) - local currentCombat = Details:GetCurrentCombat() + Details222.Pets.PetContainerCleanup() + Details:ResetSpecCache(true) - if (currentCombat.verifica_combate) then --finaliza a checagem se esta ou n�o no combate - Details:CancelTimer(currentCombat.verifica_combate) - end - - Details.last_closed_combat = nil + --stop combat ticker + Details:StopCombatTicker() --remove mythic dungeon schedules if any Details.schedule_mythicdungeon_trash_merge = nil @@ -532,54 +742,45 @@ function segmentClass:ResetAllCombatData() --clear other schedules Details.schedule_flag_boss_components = nil Details.schedule_store_boss_encounter = nil - --_detalhes.schedule_remove_overall = nil - --close breakdown window - Details:CloseBreakdownWindow() + --> handle segments destruction + do + ---@type combat + local currentCombat = Details:GetCurrentCombat() - --empty temporary tables - Details.atributo_damage:ClearTempTables() - - local segmentsTable = Details:GetCombatSegments() - - for i = #segmentsTable, 1, -1 do - ---@type boolean, combat - local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegment(i) - Details:DestroyCombat(combatObjectRemoved) - end - - --the current combat when finished will be moved to the first index of "segmentsTable", need the check if the current combat was already destroyed - if (not currentCombat.__destroyed) then - Details:DestroyCombat(currentCombat) - if (currentCombat == segmentsTable[1]) then - ---@type boolean, combat - local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegment(1) + --handle segments + local segmentsTable = Details:GetCombatSegments() + --destroy all combat objects stored in the segments table + for i = #segmentsTable, 1, -1 do + ---@type combat + local thisCombatObject = segmentsTable[i] + Details:DestroyCombat(thisCombatObject) end + + --the current combat when finished will be moved to the first index of "segmentsTable", need the check if the current combat was already destroyed + if (not currentCombat.__destroyed) then + Details:DestroyCombat(currentCombat) + end + + --destroy the overall combat object + Details:DestroyCombat(Details.tabela_overall) end - Details:DestroyCombat(Details.tabela_overall) --not creating a new one immediatelly + --> handle the creation of new combat objects and segment container + do + --create new segment container + Details.tabela_historico = segmentClass:CreateNewSegmentDatabase() + --create new overall combat object + Details.tabela_overall = combatClass:NovaTabela() --joga fora a tabela antiga e cria uma nova + --create a new current combat object + Details.tabela_vigente = combatClass:NovaTabela(nil, Details.tabela_overall) - Details:Destroy(Details.spellcache) - - if (Details.schedule_add_to_overall) then --deprecated - Details:Destroy(Details.schedule_add_to_overall) + --create new container to store pets + Details.tabela_pets = Details.container_pets:NovoContainer() + Details:UpdatePetCache() + Details.container_pets:BuscarPets() end - Details:PetContainerCleanup() - Details:ResetSpecCache(true) - - -- novo container de historico - Details.tabela_historico = segmentClass:CreateNewSegmentDatabase() --joga fora a tabela antiga e cria uma nova - -- nova tabela do overall e current - Details.tabela_overall = combatClass:NovaTabela() --joga fora a tabela antiga e cria uma nova - -- cria nova tabela do combate atual - Details.tabela_vigente = combatClass:NovaTabela(nil, Details.tabela_overall) - - --novo container para armazenar pets - Details.tabela_pets = Details.container_pets:NovoContainer() - Details:UpdateContainerCombatentes() - Details.container_pets:BuscarPets() - ---@type instance[] local allInstances = Details:GetAllInstances() @@ -596,12 +797,6 @@ function segmentClass:ResetAllCombatData() --zera o contador de combates Details:GetOrSetCombatId(0) - --clear caches - Details:ClearSpellCache() - Details:Destroy(Details.ShieldCache) - Details:Destroy(Details.cache_damage_group) - Details:Destroy(Details.cache_healing_group) - --reinicia a time machine Details222.TimeMachine.Restart() Details:UpdateParserGears() diff --git a/core/control.lua b/core/control.lua index 7c21c000..57a76edf 100644 --- a/core/control.lua +++ b/core/control.lua @@ -344,31 +344,41 @@ Details:InstanciaCallFunction(Details.UpdateCombatObjectInUse) --atualiza o showing end - --re-lock nos tempos da tabela passada -- lock again last table times - Details.tabela_vigente:TravarTempos() + --get the yet 'current' combat and lock the activity time on all actors + local pastCombatObject = Details:GetCurrentCombat() + if (not pastCombatObject.__destroyed) then + pastCombatObject:LockActivityTime() + end - ---@type number - local combatCounter = Details:GetOrSetCombatId(1) --increate the combat counter by 1 - - Details.tabela_vigente = Details.combate:NovaTabela (true, Details.tabela_overall, combatCounter, ...) --cria uma nova tabela de combate + ---@type number increate the combat counter by 1 + local combatCounter = Details:GetOrSetCombatId(1) + --create a new combat object and preplace the current one + local newCombatObject = Details.combate:NovaTabela(true, Details.tabela_overall, combatCounter, ...) + Details.tabela_vigente = newCombatObject --flag this combat as being created - Details.tabela_vigente.IsBeingCreated = true + newCombatObject.IsBeingCreated = true - Details.tabela_vigente:seta_data (Details._detalhes_props.DATA_TYPE_START) --seta na tabela do combate a data do inicio do combate -- setup time data - Details.in_combat = true --sinaliza ao addon que h� um combate em andamento -- in combat flag up - Details.tabela_vigente.combat_id = combatCounter --grava o n�mero deste combate na tabela atual -- setup combat id on new table + --flag Details! as 'in combat' + Details.in_combat = true + + newCombatObject:seta_data(Details._detalhes_props.DATA_TYPE_START) --seta na tabela do combate a data do inicio do combate -- setup time data + + --set the combat id on the combat object + newCombatObject.combat_id = combatCounter + + --clear cache Details.last_combat_pre_pot_used = nil - Details:FlagCurrentCombat() + --flags the new combat as pvp or arena match + Details:FlagNewCombat_PVPState() - --� o timer que ve se o jogador ta em combate ou n�o -- check if any party or raid members are in combat - Details.tabela_vigente.verifica_combate = Details:ScheduleRepeatingTimer ("EstaEmCombate", 1) + --start the ticker to know if the player is in combat or not + Details:StartCombatTicker() Details:ClearCCPetsBlackList() Details:Destroy(Details.encounter_end_table) - Details:Destroy(Details.pets_ignored) Details:Destroy(Details.pets_no_owner) Details.container_pets:BuscarPets() @@ -378,8 +388,8 @@ Details:UpdateParserGears() --get all buff already applied before the combat start - Details:CatchRaidBuffUptime ("BUFF_UPTIME_IN") - Details:CatchRaidDebuffUptime ("DEBUFF_UPTIME_IN") + Details:CatchRaidBuffUptime("BUFF_UPTIME_IN") + Details:CatchRaidDebuffUptime("DEBUFF_UPTIME_IN") Details:UptadeRaidMembersCache() --Details222.TimeCapture.StartCombatTimer(Details.tabela_vigente) @@ -469,37 +479,39 @@ end end - function Details:EndCombat() - return Details:SairDoCombate() + --alias + function Details:EndCombat(bossKilled, bIsFromEncounterEnd) + return Details:SairDoCombate(bossKilled, bIsFromEncounterEnd) end -- ~end ~leave - function Details:SairDoCombate (bossKilled, from_encounter_end) - + function Details:SairDoCombate(bossKilled, bIsFromEncounterEnd) if (Details.debug) then Details:Msg("(debug) |cFFFFFF00ended a combat|r|cFFFF7700", Details.encounter_table and Details.encounter_table.name or "") end - --in case of something somehow someway call to close the same combat a second time. - if (Details.tabela_vigente == Details.last_closed_combat) then + if (Details.tabela_vigente.bIsClosed) then return end - Details.last_closed_combat = Details.tabela_vigente + Details.tabela_vigente.bIsClosed = true - --if (Details.statistics) then - -- for k, v in pairs(Details.statistics) do - -- print(k, v) - -- end - --end + if (Details.tabela_vigente.__destroyed) then + Details:Msg("a deleted combat was found during combat end, please report this bug on discord:") + Details:Msg("combat destroyed by:", Details.tabela_vigente.__destroyedBy) + end + --flag the addon as 'leaving combat' Details.leaving_combat = true + --save the unixtime of the latest combat end Details.last_combat_time = _tempo - Details:CatchRaidBuffUptime ("BUFF_UPTIME_OUT") - Details:CatchRaidDebuffUptime ("DEBUFF_UPTIME_OUT") + Details:CatchRaidBuffUptime("BUFF_UPTIME_OUT") + Details:CatchRaidDebuffUptime("DEBUFF_UPTIME_OUT") Details:CloseEnemyDebuffsUptime() - --Details222.TimeCapture.StopCombat() + Details222.GuessSpecSchedules.ClearSchedules() + + --Details222.TimeCapture.StopCombat() --it did not start --check if this isn't a boss and try to find a boss in the segment if (not Details.tabela_vigente.is_boss) then @@ -520,19 +532,18 @@ end end + Details:OnCombatPhaseChanged() --.PhaseData is nil here on alpha-32 + if (Details.tabela_vigente.bossFunction) then Details:CancelTimer(Details.tabela_vigente.bossFunction) Details.tabela_vigente.bossFunction = nil end - --finaliza a checagem se esta ou n�o no combate -- finish combat check - if (Details.tabela_vigente.verifica_combate) then - Details:CancelTimer(Details.tabela_vigente.verifica_combate) - Details.tabela_vigente.verifica_combate = nil - end + --stop combat ticker + Details:StopCombatTicker() --lock timers - Details.tabela_vigente:TravarTempos() + Details.tabela_vigente:LockActivityTime() --get waste shields if (Details.close_shields) then @@ -550,8 +561,8 @@ local _, InstanceType = GetInstanceInfo() Details.tabela_vigente.instance_type = InstanceType - if (not Details.tabela_vigente.is_boss and from_encounter_end and type(from_encounter_end) == "table") then - local encounterID, encounterName, difficultyID, raidSize, endStatus = unpack(from_encounter_end) + if (not Details.tabela_vigente.is_boss and bIsFromEncounterEnd and type(bIsFromEncounterEnd) == "table") then + local encounterID, encounterName, difficultyID, raidSize, endStatus = unpack(bIsFromEncounterEnd) if (encounterID) then local ZoneName, InstanceType, DifficultyID, DifficultyName, _, _, _, ZoneMapID = GetInstanceInfo() @@ -625,7 +636,7 @@ else if (not in_instance) then if (Details.world_combat_is_trash) then - Details.tabela_vigente.is_temporary = true + Details.tabela_vigente.is_world_trash_combat = true end end end @@ -691,72 +702,64 @@ end - --if (Details:GetBossDetails (Details.tabela_vigente.is_boss.mapid, Details.tabela_vigente.is_boss.index) or ) then + Details.tabela_vigente.is_boss.index = Details.tabela_vigente.is_boss.index or 1 - Details.tabela_vigente.is_boss.index = Details.tabela_vigente.is_boss.index or 1 + Details.tabela_vigente.enemy = Details.tabela_vigente.is_boss.encounter - Details.tabela_vigente.enemy = Details.tabela_vigente.is_boss.encounter + if (Details.tabela_vigente.instance_type == "raid") then - if (Details.tabela_vigente.instance_type == "raid") then + Details.last_encounter2 = Details.last_encounter + Details.last_encounter = Details.tabela_vigente.is_boss.name - Details.last_encounter2 = Details.last_encounter - Details.last_encounter = Details.tabela_vigente.is_boss.name - - if (Details.pre_pot_used) then - Details.last_combat_pre_pot_used = Details.CopyTable(Details.pre_pot_used) - end - - if (Details.pre_pot_used and Details.announce_prepots.enabled) then - Details:Msg(Details.pre_pot_used or "") - Details.pre_pot_used = nil - end + if (Details.pre_pot_used) then + Details.last_combat_pre_pot_used = Details.CopyTable(Details.pre_pot_used) end - if (from_encounter_end) then - if (Details.encounter_table.start) then - Details.tabela_vigente:SetStartTime (Details.encounter_table.start) - end - Details.tabela_vigente:SetEndTime (Details.encounter_table ["end"] or GetTime()) + if (Details.pre_pot_used and Details.announce_prepots.enabled) then + Details:Msg(Details.pre_pot_used or "") + Details.pre_pot_used = nil end + end - --encounter boss function - local bossFunction, bossFunctionType = Details:GetBossFunction (Details.tabela_vigente.is_boss.mapid or 0, Details.tabela_vigente.is_boss.index or 0) - if (bossFunction) then - if (bitBand(bossFunctionType, 0x2) ~= 0) then --end of combat - if (not Details.logoff_saving_data) then - local successful, errortext = pcall(bossFunction, Details.tabela_vigente) - if (not successful) then - Details:Msg("error occurred on Encounter Boss Function:", errortext) - end + if (bIsFromEncounterEnd) then + if (Details.encounter_table.start) then + Details.tabela_vigente:SetStartTime (Details.encounter_table.start) + end + Details.tabela_vigente:SetEndTime (Details.encounter_table ["end"] or GetTime()) + end + + --encounter boss function + local bossFunction, bossFunctionType = Details:GetBossFunction (Details.tabela_vigente.is_boss.mapid or 0, Details.tabela_vigente.is_boss.index or 0) + if (bossFunction) then + if (bitBand(bossFunctionType, 0x2) ~= 0) then --end of combat + if (not Details.logoff_saving_data) then + local successful, errortext = pcall(bossFunction, Details.tabela_vigente) + if (not successful) then + Details:Msg("error occurred on Encounter Boss Function:", errortext) end end end + end - if (Details.tabela_vigente.instance_type == "raid") then - --schedule captures off + if (Details.tabela_vigente.instance_type == "raid") then + --schedule captures off - Details:CaptureSet (false, "damage", false, 15) - Details:CaptureSet (false, "energy", false, 15) - Details:CaptureSet (false, "aura", false, 15) - Details:CaptureSet (false, "energy", false, 15) - Details:CaptureSet (false, "spellcast", false, 15) + Details:CaptureSet (false, "damage", false, 15) + Details:CaptureSet (false, "energy", false, 15) + Details:CaptureSet (false, "aura", false, 15) + Details:CaptureSet (false, "energy", false, 15) + Details:CaptureSet (false, "spellcast", false, 15) - if (Details.debug) then - Details:Msg("(debug) freezing parser for 15 seconds.") - end + if (Details.debug) then + Details:Msg("(debug) freezing parser for 15 seconds.") end + end - --schedule sync - Details:EqualizeActorsSchedule (Details.host_of) - if (Details:GetEncounterEqualize (Details.tabela_vigente.is_boss.mapid, Details.tabela_vigente.is_boss.index)) then - Details:ScheduleTimer("DelayedSyncAlert", 3) - end - - --else - -- if (Details.debug) then - -- Details:EqualizeActorsSchedule (Details.host_of) - -- end - --end + --schedule sync + Details:EqualizeActorsSchedule (Details.host_of) + if (Details:GetEncounterEqualize (Details.tabela_vigente.is_boss.mapid, Details.tabela_vigente.is_boss.index)) then + Details:ScheduleTimer("DelayedSyncAlert", 3) + end end if (Details.solo) then @@ -829,12 +832,18 @@ else --combat denied: combat did not pass the filter and cannot be added into the segment history + --rewind the data set to the first slot in the segments table showTutorialForDiscardedSegment() --change the current combat to the latest combat available in the segment table invalidCombat = Details.tabela_vigente Details.tabela_vigente = segmentsTable[1] + --if it rewinds to an already erased combat, then create a new combat + if (Details.tabela_vigente.__destroyed) then + Details.tabela_vigente = Details.combate:NovaTabela(nil, Details.tabela_overall) + end + if (Details.tabela_vigente:GetStartTime() == 0) then Details.tabela_vigente:SetStartTime(GetTime()) Details.tabela_vigente:SetEndTime(GetTime()) @@ -871,8 +880,6 @@ Details.in_combat = false Details.leaving_combat = false - Details:OnCombatPhaseChanged() --.PhaseData is nil - Details:Destroy(Details.tabela_vigente.PhaseData.damage_section) Details:Destroy(Details.tabela_vigente.PhaseData.heal_section) Details:Destroy(Details.cache_damage_group) diff --git a/core/meta.lua b/core/meta.lua index f89c2f61..3d311534 100644 --- a/core/meta.lua +++ b/core/meta.lua @@ -700,7 +700,7 @@ local classTypeUtility = Details.atributos.misc end --cleanup backlisted pets within the handler of actor containers - Details:PetContainerCleanup() + Details222.Pets.PetContainerCleanup() Details:ClearCCPetsBlackList() --cleanup spec cache diff --git a/core/parser.lua b/core/parser.lua index b7227e4c..d62e36d0 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -4262,12 +4262,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 else --no last cooldown found so just add a last cooldown used event with no spellId and time 0 local eventTable = {} - eventTable [1] = 3 --true if this is a damage || false for healing || 1 for cooldown usage || 2 for last cooldown - eventTable [2] = 0 --spellId - eventTable [3] = 0 --amount of damage or healing but in this case is 0 - eventTable [4] = 0 --when the event happened using unix time - eventTable [5] = 0 --player health when the event happened - eventTable [6] = targetName --source name + eventTable[1] = 3 --true if this is a damage || false for healing || 1 for cooldown usage || 2 for last cooldown + eventTable[2] = 0 --spellId + eventTable[3] = 0 --amount of damage or healing but in this case is 0 + eventTable[4] = 0 --when the event happened using unix time + eventTable[5] = 0 --player health when the event happened + eventTable[6] = targetName --source name eventsBeforePlayerDeath[#eventsBeforePlayerDeath+1] = eventTable end @@ -4751,7 +4751,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 -- PARSER --serach key: ~parser ~events ~start ~inicio - function Details:FlagCurrentCombat() + function Details:FlagNewCombat_PVPState() if (Details.is_in_battleground) then Details.tabela_vigente.pvp = true Details.tabela_vigente.is_pvp = {name = Details.zone_name, mapid = Details.zone_id} @@ -5292,71 +5292,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details.SoloTables.Plugins [Details.SoloTables.Mode].Stop() end end - - --[=[ code maintenance: disabled deprecated code Feb 2022 - - --deprecated shcedules - do - if (_detalhes.schedule_add_to_overall and #_detalhes.schedule_add_to_overall > 0) then --deprecated (combat are now added immediatelly since there's no script run too long) - if (_detalhes.debug) then - _detalhes:Msg("(debug) adding ", #_detalhes.schedule_add_to_overall, "combats in queue to overall data.") - end - - for i = #_detalhes.schedule_add_to_overall, 1, -1 do - local CombatToAdd = tremove(_detalhes.schedule_add_to_overall, i) - if (CombatToAdd) then - _detalhes.historico:AddToOverallData (CombatToAdd) - end - end - end - - if (_detalhes.schedule_mythicdungeon_trash_merge) then --deprecated (combat are now added immediatelly since there's no script run too long) - _detalhes.schedule_mythicdungeon_trash_merge = nil - DetailsMythicPlusFrame.MergeTrashCleanup (true) - end - - if (_detalhes.schedule_mythicdungeon_endtrash_merge) then --deprecated (combat are now added immediatelly since there's no script run too long) - _detalhes.schedule_mythicdungeon_endtrash_merge = nil - DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone() - end - - if (_detalhes.schedule_mythicdungeon_overallrun_merge) then --deprecated (combat are now added immediatelly since there's no script run too long) - _detalhes.schedule_mythicdungeon_overallrun_merge = nil - DetailsMythicPlusFrame.MergeSegmentsOnEnd() - end - - if (_detalhes.schedule_flag_boss_components) then --deprecated (combat are now added immediatelly since there's no script run too long) - _detalhes.schedule_flag_boss_components = false - _detalhes:FlagActorsOnBossFight() - end - - if (_detalhes.schedule_remove_overall) then --deprecated (combat are now added immediatelly since there's no script run too long) - if (_detalhes.debug) then - _detalhes:Msg("(debug) found schedule overall data clean up.") - end - _detalhes.schedule_remove_overall = false - _detalhes.tabela_historico:ResetOverallData() - end - - if (_detalhes.wipe_called and false) then --disabled - _detalhes.wipe_called = nil - _detalhes:CaptureSet (nil, "damage", true) - _detalhes:CaptureSet (nil, "energy", true) - _detalhes:CaptureSet (nil, "aura", true) - _detalhes:CaptureSet (nil, "energy", true) - _detalhes:CaptureSet (nil, "spellcast", true) - - _detalhes:CaptureSet (false, "damage", false, 10) - _detalhes:CaptureSet (false, "energy", false, 10) - _detalhes:CaptureSet (false, "aura", false, 10) - _detalhes:CaptureSet (false, "energy", false, 10) - _detalhes:CaptureSet (false, "spellcast", false, 10) - end - end - - --]=] - - end function Details.parser_functions:CHALLENGE_MODE_START(...) @@ -6451,7 +6386,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 return Details.combat_id end - --if in combat + ---return true if in combat + ---@return boolean bIsInCombat function Details:IsInCombat() return _in_combat end diff --git a/core/util.lua b/core/util.lua index 50ffda58..94bbfcc1 100644 --- a/core/util.lua +++ b/core/util.lua @@ -1,13 +1,10 @@ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - local _detalhes = _G.Details + local Details = _G.Details local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" ) local addonName, Details222 = ... local _ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---local pointers - local upper = string.upper --lua local local ipairs = ipairs --lua local local pairs = pairs --lua local @@ -31,7 +28,7 @@ local UnitAffectingCombat = UnitAffectingCombat --wow api local local _InCombatLockdown = InCombatLockdown --wow api local - local gump = _detalhes.gump --details local + local gump = Details.gump --details local ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --fade handler @@ -40,7 +37,6 @@ frames = {} } - --fade in is hidding the frame, it is the opposite of the stardard local fadeINFinishedCallback = function(frame) if (frame.fading_in) then @@ -178,7 +174,7 @@ --hide all instanceBars on all instances if (frame == "all") then - for _, instancia in ipairs(_detalhes.tabela_instancias) do + for _, instancia in ipairs(Details.tabela_instancias) do if (hideType == "barras") then for i = 1, instancia.rows_created do local instanceBar = instancia.barras[i] @@ -291,7 +287,7 @@ --details api functions --get the npc id from guid - function _detalhes:GetNpcIdFromGuid (guid) + function Details:GetNpcIdFromGuid (guid) local NpcId = select( 6, strsplit( "-", guid ) ) if (NpcId) then return tonumber( NpcId ) @@ -299,12 +295,12 @@ return 0 end - function _detalhes:GetSourceFromNpcId (npcId) - for index, container in ipairs(_detalhes.tabela_vigente) do + function Details:GetSourceFromNpcId (npcId) + for index, container in ipairs(Details.tabela_vigente) do if (index <= 4) then local t = container._ActorTable for i = 1, #t do - if (_detalhes:GetNpcIdFromGuid (t[i].serial) == npcId) then + if (Details:GetNpcIdFromGuid (t[i].serial) == npcId) then return t[i].nome end end @@ -315,24 +311,33 @@ function Details:GetRaidLeader() if (IsInRaid()) then for i = 1, GetNumGroupMembers() do - local name, rank = GetRaidRosterInfo(i) + local actorName, rank = GetRaidRosterInfo(i) if (rank == 2) then - return name, "raid" .. i + return actorName, "raid" .. i end end end - return end - function _detalhes:UnpackDeathTable (t) - local deathevents = t[1] - local deathtime = t[2] - local playername = t[3] - local playerclass = t[4] - local playermaxhealth = t[5] - local deathtimestring = t[6] - local lastcooldown = t.last_cooldown - local deathcombattime = t.dead_at + ---unpack a death table + ---@param deathTable table + ---@return actorname actorName name of the actor + ---@return actorclass actorClass class of the actor + ---@return unixtime deathTime unittime of when the death occurred + ---@return combattime deathCombatTime time in seconds since the combat start + ---@return timestring deathTimeString time in string format + ---@return number maxHealth max health of the actor + ---@return table deathEvents events that lead the actor to death + ---@return {key1: unixtime, key2: spellid} + function Details:UnpackDeathTable(deathTable) + local deathevents = deathTable[1] + local deathtime = deathTable[2] + local playername = deathTable[3] + local playerclass = deathTable[4] + local playermaxhealth = deathTable[5] + local deathtimestring = deathTable[6] + local lastcooldown = deathTable.last_cooldown + local deathcombattime = deathTable.dead_at return playername, playerclass, deathtime, deathcombattime, deathtimestring, playermaxhealth, deathevents, lastcooldown end @@ -350,7 +355,7 @@ --0.000004 --set all table keys to lower local temptable = {} - function _detalhes:LowerizeKeys (_table) + function Details:LowerizeKeys (_table) for key, value in pairs(_table) do temptable [string.lower(key)] = value end @@ -358,10 +363,10 @@ return _table end - _detalhes.ToKFunctions = {} + Details.ToKFunctions = {} --krKR by @yuk6196 (http://wow.curseforge.com/profiles/yuk6196) - function _detalhes:UseEastAsianNumericalSystem() + function Details:UseEastAsianNumericalSystem() --try to auto detect the language local symbol_1K, symbol_10K, symbol_1B @@ -377,13 +382,13 @@ --usage: _detalhes:SetNumericalSystemOverride (language) language can be: "kr", "cn", "tw" --just in case the user mess up something - if (type(_detalhes.numerical_system_symbols) ~= "string") then - _detalhes.numerical_system_symbols = "auto" + if (type(Details.numerical_system_symbols) ~= "string") then + Details.numerical_system_symbols = "auto" end --do the override - if (_detalhes.numerical_system_symbols ~= "auto") then - local locale = string.lower(_detalhes.numerical_system_symbols) + if (Details.numerical_system_symbols ~= "auto") then + local locale = string.lower(Details.numerical_system_symbols) if (locale == "kr") then symbol_1K, symbol_10K, symbol_1B = "천", "만", "억" @@ -400,7 +405,7 @@ symbol_1K, symbol_10K, symbol_1B = "千", "万", "亿" end - function _detalhes:ToK (numero) + function Details:ToK (numero) if (numero > 100000000) then return _string_format ("%.2f", numero/100000000) .. symbol_1B elseif (numero > 10000) then @@ -411,7 +416,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToK2 (numero) + function Details:ToK2 (numero) if (numero > 99999999) then return _string_format ("%.2f", numero/100000000) .. symbol_1B elseif (numero > 999999) then @@ -427,7 +432,7 @@ end --short numbers no numbers after comma - function _detalhes:ToK0 (numero) + function Details:ToK0 (numero) if (numero > 100000000) then return _string_format ("%.0f", numero/100000000) .. symbol_1B elseif (numero > 10000) then @@ -438,7 +443,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToKMin (numero) + function Details:ToKMin (numero) if (numero > 100000000) then return _string_format ("%.2f", numero/100000000) .. symbol_1B elseif (numero > 10000) then @@ -449,7 +454,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToK2Min (numero) + function Details:ToK2Min (numero) if (numero > 99999999) then return _string_format ("%.2f", numero/100000000) .. symbol_1B elseif (numero > 999999) then @@ -465,7 +470,7 @@ end --short numbers no numbers after comma - function _detalhes:ToK0Min (numero) + function Details:ToK0Min (numero) if (numero > 100000000) then return _string_format ("%.0f", numero/100000000) .. symbol_1B elseif (numero > 10000) then @@ -477,7 +482,7 @@ end --short numbers no numbers after comma - function _detalhes:ToKReport (numero) + function Details:ToKReport (numero) if (numero > 100000000) then return _string_format ("%.2f", numero/100000000) .. symbol_1B elseif (numero > 10000) then @@ -488,7 +493,7 @@ return numero end - function _detalhes:Format (n, custom) + function Details:Format (n, custom) n = _math_floor(n) if (custom) then if (n > 99999999) then @@ -501,17 +506,17 @@ return n end else - return _detalhes.ToKFunctions [_detalhes.ps_abbreviation] (nil, n) + return Details.ToKFunctions [Details.ps_abbreviation] (nil, n) end end --no changes - function _detalhes:NoToK (numero) + function Details:NoToK (numero) return _math_floor(numero) end -- thanks http://richard.warburton.it - function _detalhes:comma_value (n) + function Details:comma_value (n) if (not n) then return "0" end n = _math_floor(n) if (n == 0) then @@ -520,28 +525,28 @@ local left,num,right = _string_match (n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - - function _detalhes:comma_value_raw (n) + + function Details:comma_value_raw (n) local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - Details:Destroy(_detalhes.ToKFunctions) + Details:Destroy(Details.ToKFunctions) - tinsert(_detalhes.ToKFunctions, _detalhes.NoToK) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK2) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK0) - tinsert(_detalhes.ToKFunctions, _detalhes.ToKMin) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK2Min) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK0Min) - tinsert(_detalhes.ToKFunctions, _detalhes.comma_value) + tinsert(Details.ToKFunctions, Details.NoToK) + tinsert(Details.ToKFunctions, Details.ToK) + tinsert(Details.ToKFunctions, Details.ToK2) + tinsert(Details.ToKFunctions, Details.ToK0) + tinsert(Details.ToKFunctions, Details.ToKMin) + tinsert(Details.ToKFunctions, Details.ToK2Min) + tinsert(Details.ToKFunctions, Details.ToK0Min) + tinsert(Details.ToKFunctions, Details.comma_value) end - function _detalhes:UseWestNumericalSystem() + function Details:UseWestNumericalSystem() --short numbers - function _detalhes:ToK (numero) + function Details:ToK (numero) if (numero > 999999999) then return format("%.2f", numero/1000000000) .. "B" elseif (numero > 1000000) then @@ -553,7 +558,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToK2 (numero) + function Details:ToK2 (numero) if (numero > 999999999) then return format("%.2f", numero/1000000000) .. "B" elseif (numero > 999999) then @@ -568,7 +573,7 @@ end --short numbers no numbers after comma - function _detalhes:ToK0 (numero) + function Details:ToK0 (numero) if (numero > 999999999) then return format("%.2f", numero/1000000000) .. "B" elseif (numero > 1000000) then @@ -580,7 +585,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToKMin (numero) + function Details:ToKMin (numero) if (numero > 1000000) then return _string_format ("%.2f", numero/1000000) .. "m" elseif (numero > 1000) then @@ -590,7 +595,7 @@ return _string_format ("%.0f", numero) end - function _detalhes:ToK2Min (numero) + function Details:ToK2Min (numero) if (numero > 999999) then return _string_format ("%.2f", numero/1000000) .. "m" elseif (numero > 99999) then @@ -603,7 +608,7 @@ end --short numbers no numbers after comma - function _detalhes:ToK0Min (numero) + function Details:ToK0Min (numero) if (numero > 1000000) then return _string_format ("%.0f", numero/1000000) .. "m" elseif (numero > 1000) then @@ -614,7 +619,7 @@ end --short numbers no numbers after comma - function _detalhes:ToKReport (numero) + function Details:ToKReport (numero) if (numero > 1000000) then return _string_format ("%.2f", numero/1000000) .. "M" elseif (numero > 1000) then @@ -624,7 +629,7 @@ return numero end - function _detalhes:Format (n, custom) + function Details:Format (n, custom) n = _math_floor(n) if (custom) then if (n > 999999) then @@ -635,17 +640,17 @@ return n end else - return _detalhes.ToKFunctions [_detalhes.ps_abbreviation] (nil, n) + return Details.ToKFunctions [Details.ps_abbreviation] (nil, n) end end --no changes - function _detalhes:NoToK (numero) + function Details:NoToK (numero) return _math_floor(numero) end -- thanks http://richard.warburton.it - function _detalhes:comma_value (n) + function Details:comma_value (n) if (not n) then return "0" end n = _math_floor(n) if (n == 0) then @@ -654,30 +659,30 @@ local left,num,right = _string_match (n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - function _detalhes:comma_value_raw (n) + function Details:comma_value_raw (n) local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end - Details:Destroy(_detalhes.ToKFunctions) + Details:Destroy(Details.ToKFunctions) - tinsert(_detalhes.ToKFunctions, _detalhes.NoToK) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK2) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK0) - tinsert(_detalhes.ToKFunctions, _detalhes.ToKMin) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK2Min) - tinsert(_detalhes.ToKFunctions, _detalhes.ToK0Min) - tinsert(_detalhes.ToKFunctions, _detalhes.comma_value) + tinsert(Details.ToKFunctions, Details.NoToK) + tinsert(Details.ToKFunctions, Details.ToK) + tinsert(Details.ToKFunctions, Details.ToK2) + tinsert(Details.ToKFunctions, Details.ToK0) + tinsert(Details.ToKFunctions, Details.ToKMin) + tinsert(Details.ToKFunctions, Details.ToK2Min) + tinsert(Details.ToKFunctions, Details.ToK0Min) + tinsert(Details.ToKFunctions, Details.comma_value) -- end --load western as default, the proper method is loaded within the profile - _detalhes:UseWestNumericalSystem() + Details:UseWestNumericalSystem() - function _detalhes:GetCurrentToKFunction() - return _detalhes.ToKFunctions [_detalhes.ps_abbreviation] + function Details:GetCurrentToKFunction() + return Details.ToKFunctions [Details.ps_abbreviation] end --alias @@ -692,49 +697,49 @@ ------------------------------------------------------------------------------------------------------------ --numerical system - function _detalhes:SetNumericalSystemOverride (language) + function Details:SetNumericalSystemOverride (language) if (not language) then language = "auto" end - _detalhes.numerical_system_symbols = language - _detalhes:Msg("NumSystem override is now:", language) + Details.numerical_system_symbols = language + Details:Msg("NumSystem override is now:", language) - _detalhes:SelectNumericalSystem() + Details:SelectNumericalSystem() end - function _detalhes:GetNumericalSystem() - return _detalhes.numerical_system + function Details:GetNumericalSystem() + return Details.numerical_system end - function _detalhes:SelectNumericalSystem (system) + function Details:SelectNumericalSystem (system) if (not system or type(system) ~= "number") then - system = _detalhes.numerical_system or 1 + system = Details.numerical_system or 1 end - _detalhes.numerical_system = system + Details.numerical_system = system if (system == 1) then - _detalhes:UseWestNumericalSystem() + Details:UseWestNumericalSystem() elseif (system == 2) then - _detalhes:UseEastAsianNumericalSystem() + Details:UseEastAsianNumericalSystem() end - _detalhes:UpdateToKFunctions() + Details:UpdateToKFunctions() end - function _detalhes:UpdateToKFunctions() - _detalhes.atributo_damage:UpdateSelectedToKFunction() - _detalhes.atributo_heal:UpdateSelectedToKFunction() - _detalhes.atributo_energy:UpdateSelectedToKFunction() - _detalhes.atributo_misc:UpdateSelectedToKFunction() - _detalhes.atributo_custom:UpdateSelectedToKFunction() + function Details:UpdateToKFunctions() + Details.atributo_damage:UpdateSelectedToKFunction() + Details.atributo_heal:UpdateSelectedToKFunction() + Details.atributo_energy:UpdateSelectedToKFunction() + Details.atributo_misc:UpdateSelectedToKFunction() + Details.atributo_custom:UpdateSelectedToKFunction() Details:RefreshMainWindow(-1, true) end --------end of ToK functions---- --replacing data for custom texts - _detalhes.string = {} + Details.string = {} local function_cache = {} local arguments_cache = {} @@ -749,7 +754,7 @@ if (not func) then func = loadstring (str) if (not func) then - _detalhes:Msg("|cFFFF9900error compiling script on custom text|r: ", errortext) + Details:Msg("|cFFFF9900error compiling script on custom text|r: ", errortext) return 0 end DetailsFramework:SetEnvironment(func) @@ -758,13 +763,13 @@ local okey, value = _pcall (func, parameters_cache [1], parameters_cache [2], parameters_cache [3], parameters_cache [4], arguments_cache[1], arguments_cache[2], arguments_cache[3]) if (not okey) then - _detalhes:Msg("|cFFFF9900error on custom text|r:", value) + Details:Msg("|cFFFF9900error on custom text|r:", value) return 0 end return value or 0 end - function _detalhes.string.replace (str, v1, v2, v3, v4, v5, v6, v7) + function Details.string.replace (str, v1, v2, v3, v4, v5, v6, v7) arguments_cache [1] = v1 arguments_cache [2] = v2 arguments_cache [3] = v3 @@ -777,7 +782,7 @@ end --remove a index from a hash table - function _detalhes:tableRemove (tabela, indexName) + function Details:tableRemove (tabela, indexName) local newtable = {} for hash, value in pairs(tabela) do if (hash ~= indexName) then @@ -788,7 +793,7 @@ end --return if the numeric table have an object - function _detalhes:tableIN (tabela, objeto) + function Details:tableIN (tabela, objeto) for index, valor in ipairs(tabela) do if (valor == objeto) then return index @@ -798,7 +803,7 @@ end --reverse numerical table - function _detalhes:reverse_table (t) + function Details:reverse_table (t) local new = {} local index = 1 for i = #t, 1, -1 do @@ -808,9 +813,9 @@ return new end - _detalhes.table = {} + Details.table = {} - function _detalhes.table.reverse (t) + function Details.table.reverse (t) local new = {} local index = 1 for i = #t, 1, -1 do @@ -821,7 +826,7 @@ end --yah, i know - function _detalhes.table.copy(t1, t2) + function Details.table.copy(t1, t2) for key, value in pairs(t2) do if (type(value) == "table") then t1 [key] = Details.CopyTable(value) @@ -832,29 +837,29 @@ return t1 end - function _detalhes.table.deploy(t1, t2) + function Details.table.deploy(t1, t2) for key, value in pairs(t2) do if (type(value) == "table") then t1 [key] = t1 [key] or {} - _detalhes.table.deploy(t1 [key], t2 [key]) + Details.table.deploy(t1 [key], t2 [key]) elseif (t1 [key] == nil) then t1 [key] = value end end end - function _detalhes.table.overwrite (t1, t2) + function Details.table.overwrite (t1, t2) for key, value in pairs(t2) do if (type(value) == "table") then t1 [key] = t1 [key] or {} - _detalhes.table.overwrite (t1 [key], t2 [key]) + Details.table.overwrite (t1 [key], t2 [key]) else t1 [key] = value end end end - function _detalhes.table.dump (t, s, deep) + function Details.table.dump (t, s, deep) if (type(t) == "number") then return t @@ -887,7 +892,7 @@ else s = s .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9table {|r\n" end - s = s .. _detalhes.table.dump (value, nil, deep+1) + s = s .. Details.table.dump (value, nil, deep+1) s = s .. space .. "|cFFa9ffa9}|r\n" elseif (tpe == "string") then @@ -909,7 +914,7 @@ return s end - function _detalhes:hex (num) + function Details:hex (num) local hexstr = '0123456789abcdef' local s = '' while num > 0 do @@ -924,7 +929,7 @@ return s end - function _detalhes:percent_color (value, inverted) + function Details:percent_color (value, inverted) local r, g if (value < 50) then r = 255 @@ -947,7 +952,7 @@ --unpack more than 1 table -- http://www.dzone.com/snippets/lua-unpack-multiple-tables - function _detalhes:unpacks (...) + function Details:unpacks (...) local values = {} for i = 1, select('#', ...) do for _, value in ipairs(select(i, ...)) do @@ -958,14 +963,14 @@ end --trim http://lua-users.org/wiki/StringTrim - function _detalhes:trim (s) + function Details:trim (s) local from = s:match"^%s*()" return from > #s and "" or s:match(".*%S", from) end -- lua base64 codec (c) 2006-2008 by Alex Kloss - http://www.it-rfc.de - licensed under the terms of the LGPL2 - http://lua-users.org/wiki/BaseSixtyFour do - _detalhes._encode = {} + Details._encode = {} -- shift left local function lsh (value,shift) @@ -994,7 +999,7 @@ do -- function encode -- encodes input string to base64. - function _detalhes._encode:enc (data) + function Details._encode:enc (data) local bytes = {} local result = "" for spos=0,string.len(data)-1,3 do @@ -1009,7 +1014,7 @@ do -- function decode -- decode base64 input to string - function _detalhes._encode:Decode (data) + function Details._encode:Decode (data) local chars = {} local result="" for dpos=0,string.len(data)-1,4 do @@ -1019,44 +1024,44 @@ do return result end - function _detalhes._encode:Encode (s) - return _detalhes._encode:enc (s) + function Details._encode:Encode (s) + return Details._encode:enc (s) end end --scale - function _detalhes:Scale (rangeMin, rangeMax, scaleMin, scaleMax, x) + function Details:Scale (rangeMin, rangeMax, scaleMin, scaleMax, x) return 1 + (x - rangeMin) * (scaleMax - scaleMin) / (rangeMax - rangeMin) end --font color - function _detalhes:SetFontColor(fontString, r, g, b, a) + function Details:SetFontColor(fontString, r, g, b, a) r, g, b, a = gump:ParseColors(r, g, b, a) fontString:SetTextColor(r, g, b, a) end --font size - function _detalhes:SetFontSize(fontString, ...) + function Details:SetFontSize(fontString, ...) local fonte, _, flags = fontString:GetFont() fontString:SetFont(fonte, _math_max (...), flags) end - function _detalhes:GetFontSize (fontString) + function Details:GetFontSize (fontString) local _, size = fontString:GetFont() return size end --font face - function _detalhes:SetFontFace (fontString, fontface) + function Details:SetFontFace (fontString, fontface) local _, size, flags = fontString:GetFont() fontString:SetFont(fontface, size, flags) end - function _detalhes:GetFontFace (fontString) + function Details:GetFontFace (fontString) local fontface = fontString:GetFont() return fontface end --font outline - function _detalhes:SetFontOutline (fontString, outline) + function Details:SetFontOutline (fontString, outline) local fonte, size = fontString:GetFont() if (outline) then if (type(outline) == "boolean" and outline) then @@ -1068,12 +1073,12 @@ end end end - if (_detalhes.force_font_outline ~= "") then - if (_detalhes.force_font_outline == "OUTLINE") then + if (Details.force_font_outline ~= "") then + if (Details.force_font_outline == "OUTLINE") then outline = "OUTLINE" - elseif (_detalhes.force_font_outline == "THICKOUTLINE") then + elseif (Details.force_font_outline == "THICKOUTLINE") then outline = "THICKOUTLINE" - elseif (_detalhes.force_font_outline == "MONOCHROME") then + elseif (Details.force_font_outline == "MONOCHROME") then outline = "MONOCHROME" end end @@ -1081,10 +1086,10 @@ end fontString:SetFont(fonte, size, outline) end - function _detalhes:UseOutline (outline) + function Details:UseOutline (outline) outline = outline or "" - _detalhes.force_font_outline = outline - for ID, instance in _detalhes:ListInstances() do + Details.force_font_outline = outline + for ID, instance in Details:ListInstances() do if (instance:IsEnabled()) then instance:RefreshBars() instance:InstanceReset() @@ -1096,26 +1101,28 @@ end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --internal functions - function _detalhes:HealthTick() + function Details:HealthTick() if (UnitExists("boss1") and IsInRaid() and IsInInstance()) then local health = (UnitHealth ("boss1") or 0) / (UnitHealthMax ("boss1") or 0) - if (_detalhes.boss1_health_percent) then - if (_detalhes.boss1_health_percent < health) then + if (Details.boss1_health_percent) then + if (Details.boss1_health_percent < health) then return end end - _detalhes.boss1_health_percent = health + Details.boss1_health_percent = health end end - --is in combat yet? - function _detalhes:EstaEmCombate() + ---do tasks that need to run every second during the combat + ---also check if all members of the group are in combat or not + ---when no one is in combat, the combat is over + ---@return boolean bIsInCombat if true, the comabt is still going on + local combatTicker = function() + Details:TimeDataTick() + Details:BrokerTick() + Details:HealthTick() - _detalhes:TimeDataTick() - _detalhes:BrokerTick() - _detalhes:HealthTick() - - local _, zoneType = GetInstanceInfo() + local zoneName, zoneType = GetInstanceInfo() if (Details.Coach.Server.IsEnabled()) then if (Details.debug) then @@ -1124,7 +1131,7 @@ end return true --battleground - elseif (zoneType == "pvp" and _detalhes.use_battleground_server_parser) then + elseif (zoneType == "pvp" and Details.use_battleground_server_parser) then return true --arena @@ -1132,26 +1139,26 @@ end return true --is in combat - elseif (UnitAffectingCombat("player")) then - return true + elseif (UnitAffectingCombat("player")) then + return true - elseif (IsInRaid()) then - local unitIdCache = Details222.UnitIdCache.Raid - for i = 1, GetNumGroupMembers(), 1 do - if (UnitAffectingCombat(unitIdCache[i])) then - return true - end - end - - elseif (IsInGroup()) then - local unitIdCache = Details222.UnitIdCache.Party - for i = 1, GetNumGroupMembers()-1, 1 do - if (UnitAffectingCombat(unitIdCache[i])) then - return true - end + elseif (IsInRaid()) then + local unitIdCache = Details222.UnitIdCache.Raid + for i = 1, GetNumGroupMembers(), 1 do + if (UnitAffectingCombat(unitIdCache[i])) then + return true end end + elseif (IsInGroup()) then + local unitIdCache = Details222.UnitIdCache.Party + for i = 1, GetNumGroupMembers()-1, 1 do + if (UnitAffectingCombat(unitIdCache[i])) then + return true + end + end + end + --coach feature if (not Details.Coach.Server.IsEnabled()) then if (Details.debug) then @@ -1159,10 +1166,25 @@ end end end + Details:StopCombatTicker() Details:SairDoCombate() + return false end - function _detalhes:FindGUIDFromName (name) + function Details:StartCombatTicker() + if (Details.CombatTicker) then + Details.CombatTicker:Cancel() + end + Details.CombatTicker = Details.Schedules.NewTicker(1, combatTicker) + end + + function Details:StopCombatTicker() + if (Details.CombatTicker) then + Details.CombatTicker:Cancel() + end + end + + function Details:FindGUIDFromName (name) if (IsInRaid()) then for i = 1, GetNumGroupMembers(), 1 do local this_name, _ = UnitName ("raid"..i) @@ -1185,8 +1207,8 @@ end end --[[ test grayscale ]] - function _detalhes:teste_grayscale() - local instancia = _detalhes.tabela_instancias[1] + function Details:teste_grayscale() + local instancia = Details.tabela_instancias[1] for i = 1, instancia.rows_created, 1 do local barra = instancia.barras[i] local red, green, blue, alpha = barra.textura:GetVertexColor() @@ -1227,7 +1249,7 @@ end if (ThisGradient.Func) then local okey, errortext = _pcall (ThisGradient.Func, ThisGradient.FuncParam) if (not okey) then - _detalhes:Msg("GradientEffect() end function error:", errortext) + Details:Msg("GradientEffect() end function error:", errortext) end end @@ -1303,7 +1325,7 @@ end EndBlue = 1.0 end - local GradientFrameControl = _detalhes.listener + local GradientFrameControl = Details.listener GradientFrameControl.gradientes = GradientFrameControl.gradientes or {} for index = 1, #GradientFrameControl.gradientes do @@ -1496,7 +1518,7 @@ end --esse ALL aqui pode dar merda com as inst�ncias n�o ativadas if (frame == "all") then --todas as inst�ncias - for _, instancia in ipairs(_detalhes.tabela_instancias) do + for _, instancia in ipairs(Details.tabela_instancias) do if (parametros == "barras") then --hida todas as barras da inst�ncia for i = 1, instancia.rows_created, 1 do Details.FadeHandler.Fader(instancia.barras[i], tipo, velocidade+(i/10)) @@ -1616,7 +1638,7 @@ end end end - function _detalhes:name_space (barra) + function Details:name_space (barra) --if (barra.icone_secundario_ativo) then -- local tamanho = barra:GetWidth()-barra.lineText4:GetStringWidth()-16-barra:GetHeight() -- barra.lineText1:SetSize(tamanho-2, 15) @@ -1625,7 +1647,7 @@ end --end end - function _detalhes:name_space_info (barra) + function Details:name_space_info (barra) if (barra.icone_secundario_ativo) then local tamanho = barra:GetWidth()-barra.lineText4:GetStringWidth()-16-barra:GetHeight() barra.lineText1:SetSize(tamanho-10, 15) @@ -1635,7 +1657,7 @@ end end end - function _detalhes:name_space_generic (barra, separador) + function Details:name_space_generic (barra, separador) local texto_direita_tamanho = barra.lineText4:GetStringWidth() local tamanho = barra:GetWidth()-texto_direita_tamanho-16 if (separador) then diff --git a/frames/window_breakdown/breakdown_spells_spellframes.lua b/frames/window_breakdown/breakdown_spells_spellframes.lua index 389d7a92..ebc43118 100644 --- a/frames/window_breakdown/breakdown_spells_spellframes.lua +++ b/frames/window_breakdown/breakdown_spells_spellframes.lua @@ -959,7 +959,12 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll local r, g, b = Details:GetSpellSchoolColor(spellTable.spellschool or 1) spellBar.statusBar:SetStatusBarColor(r, g, b, 0.963) - spellBar.average = value / spellTable.counter + if (spellTable.counter > 0) then + spellBar.average = value / spellTable.counter + else + spellBar.average = 0.0001 + end + spellBar.combatTime = combatTime ---@type fontstring diff --git a/frames/window_breakdown/window_playerbreakdown_auras.lua b/frames/window_breakdown/window_playerbreakdown_auras.lua index 71bc70b8..b2371ff0 100644 --- a/frames/window_breakdown/window_playerbreakdown_auras.lua +++ b/frames/window_breakdown/window_playerbreakdown_auras.lua @@ -1,12 +1,12 @@ local Details = Details local GameTooltip = GameTooltip +local detailsFramework = DetailsFramework local unpack = unpack local CreateFrame = CreateFrame local GetSpellInfo = GetSpellInfo -local auras_tab_create = function(tab, frame) - local DF = DetailsFramework +local createAuraTabOnBreakdownWindow = function(tab, frame) local scroll_line_amount = 22 local scroll_width = 410 local scrollHeight = 445 @@ -25,192 +25,159 @@ local auras_tab_create = function(tab, frame) 426, 630, 729, 775, 820 } - local line_onenter = function(self) + local onEnterLine = function(self) GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") - Details:GameTooltipSetSpellByID (self.spellID) + Details:GameTooltipSetSpellByID(self.spellID) GameTooltip:Show() self:SetBackdropColor(1, 1, 1, .2) end - local line_onleave = function(self) + local onLeaveLine = function(self) GameTooltip:Hide() self:SetBackdropColor(unpack(self.BackgroundColor)) end - local line_onclick = function(self) + local onClickLine = function(self) end - --buff scroll - --icon - name - applications - refreshes - uptime - -- - - --local wa_button = function(self, mouseButton, spellID, auraType) - -- local spellName, _, spellIcon = GetSpellInfo(spellID) - -- Details:OpenAuraPanel (spellID, spellName, spellIcon, nil, auraType == "BUFF" and 4 or 2, 1) - --end - - local scroll_createline = function(self, index) + local createLineScroll = function(self, index) local line = CreateFrame("button", "$parentLine" .. index, self,"BackdropTemplate") line:SetPoint("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1))) line:SetSize(scroll_width -2, scroll_line_height) - line:SetScript("OnEnter", line_onenter) - line:SetScript("OnLeave", line_onleave) - line:SetScript("OnClick", line_onclick) + line:SetScript("OnEnter", onEnterLine) + line:SetScript("OnLeave", onLeaveLine) + line:SetScript("OnClick", onClickLine) - line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) + line:SetBackdrop({bgFile =[[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) line:SetBackdropColor(0, 0, 0, 0.2) - local icon = line:CreateTexture("$parentIcon", "overlay") - icon:SetSize(scroll_line_height -2 , scroll_line_height - 2) - local name = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - local uptime = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - local apply = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - local refresh = line:CreateFontString("$parentName", "overlay", "GameFontNormal") + local iconTexture = line:CreateTexture("$parentIcon", "overlay") + iconTexture:SetSize(scroll_line_height -2 , scroll_line_height - 2) + local nameLabel = line:CreateFontString("$parentName", "overlay", "GameFontNormal") + local uptimeLabel = line:CreateFontString("$parentName", "overlay", "GameFontNormal") + local applyLabel = line:CreateFontString("$parentName", "overlay", "GameFontNormal") + local refreshLabel = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - --local waButton = DF:CreateButton(line, wa_button, 18, 18) - --waButton:SetIcon ([[Interface\AddOns\WeakAuras\Media\Textures\icon]]) + detailsFramework:SetFontSize(nameLabel, text_size) + detailsFramework:SetFontSize(uptimeLabel, text_size) + detailsFramework:SetFontSize(applyLabel, text_size) + detailsFramework:SetFontSize(refreshLabel, text_size) - DF:SetFontSize(name, text_size) - DF:SetFontSize(uptime, text_size) - DF:SetFontSize(apply, text_size) - DF:SetFontSize(refresh, text_size) + iconTexture:SetPoint("left", line, "left", 2, 0) + nameLabel:SetPoint("left", iconTexture, "right", 2, 0) + uptimeLabel:SetPoint("left", line, "left", 186, 0) + applyLabel:SetPoint("left", line, "left", 276, 0) + refreshLabel:SetPoint("left", line, "left", 322, 0) - icon:SetPoint("left", line, "left", 2, 0) - name:SetPoint("left", icon, "right", 2, 0) - uptime:SetPoint("left", line, "left", 186, 0) - apply:SetPoint("left", line, "left", 276, 0) - refresh:SetPoint("left", line, "left", 322, 0) - --waButton:SetPoint("left", line, "left", 372, 0) + line.Icon = iconTexture + line.Name = nameLabel + line.Uptime = uptimeLabel + line.Apply = applyLabel + line.Refresh = refreshLabel - line.Icon = icon - line.Name = name - line.Uptime = uptime - line.Apply = apply - line.Refresh = refresh - --line.WaButton = waButton + nameLabel:SetJustifyH("left") + uptimeLabel:SetJustifyH("left") - name:SetJustifyH("left") - uptime:SetJustifyH("left") - - apply:SetJustifyH("center") - refresh:SetJustifyH("center") - apply:SetWidth(26) - refresh:SetWidth(26) + applyLabel:SetJustifyH("center") + refreshLabel:SetJustifyH("center") + applyLabel:SetWidth(26) + refreshLabel:SetWidth(26) return line end - local line_bg_color = {{1, 1, 1, .1}, {1, 1, 1, 0}} - - local scroll_buff_refresh = function(self, data, offset, total_lines) - - local haveWA = false --_G.WeakAuras + local lineBackgroundColor = {{1, 1, 1, .1}, {1, 1, 1, 0}} + local scrollRefreshBuffs = function(self, data, offset, total_lines) for i = 1, total_lines do local index = i + offset - local aura = data [index] + local aura = data[index] if (aura) then - local line = self:GetLine (i) + local line = self:GetLine(i) line.spellID = aura.spellID - line.Icon:SetTexture(aura [1]) + line.Icon:SetTexture(aura[1]) line.Icon:SetTexCoord(.1, .9, .1, .9) - line.Name:SetText(aura [2]) - line.Uptime:SetText(DF:IntegerToTimer(aura [3]) .. " (|cFFBBAAAA" .. math.floor(aura [6]) .. "%|r)") - line.Apply:SetText(aura [4]) - line.Refresh:SetText(aura [5]) + line.Name:SetText(aura[2]) + line.Uptime:SetText(detailsFramework:IntegerToTimer(aura[3]) .. "(|cFFBBAAAA" .. math.floor(aura[6]) .. "%|r)") + line.Apply:SetText(aura[4]) + line.Refresh:SetText(aura[5]) - --if (haveWA) then - -- line.WaButton:SetClickFunction(wa_button, aura.spellID, line.AuraType) - --else - -- line.WaButton:Disable() - --end - - if (i%2 == 0) then - line:SetBackdropColor(unpack(line_bg_color [1])) - line.BackgroundColor = line_bg_color [1] + if (i % 2 == 0) then + line:SetBackdropColor(unpack(lineBackgroundColor[1])) + line.BackgroundColor = lineBackgroundColor[1] else - line:SetBackdropColor(unpack(line_bg_color [2])) - line.BackgroundColor = line_bg_color [2] + line:SetBackdropColor(unpack(lineBackgroundColor[2])) + line.BackgroundColor = lineBackgroundColor[2] end end end end - local create_titledesc_frame = function(anchorWidget, desc) - local f = CreateFrame("frame", nil, frame) - f:SetSize(40, 20) - f:SetPoint("center", anchorWidget, "center") - f:SetScript("OnEnter", function() - GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT") + local createTitleDesc_Frame = function(anchorWidget, desc) + local newTitleDescFrame = CreateFrame("frame", nil, frame) + newTitleDescFrame:SetSize(40, 20) + newTitleDescFrame:SetPoint("center", anchorWidget, "center") + + newTitleDescFrame:SetScript("OnEnter", function() + GameTooltip:SetOwner(newTitleDescFrame, "ANCHOR_TOPRIGHT") GameTooltip:AddLine(desc) GameTooltip:Show() end) - f:SetScript("OnLeave", function() + + newTitleDescFrame:SetScript("OnLeave", function() GameTooltip:Hide() end) - return f + + return newTitleDescFrame end - - - local buffLabel = DF:CreateLabel(frame, "Buff Name") + local buffLabel = detailsFramework:CreateLabel(frame, "Buff Name") buffLabel:SetPoint(headerOffsetsBuffs[1], -10) - local uptimeLabel = DF:CreateLabel(frame, "Uptime") + local uptimeLabel = detailsFramework:CreateLabel(frame, "Uptime") uptimeLabel:SetPoint(headerOffsetsBuffs[2], -10) - local appliedLabel = DF:CreateLabel(frame, "A") + local appliedLabel = detailsFramework:CreateLabel(frame, "A") appliedLabel:SetPoint(headerOffsetsBuffs[3], -10) - create_titledesc_frame (appliedLabel.widget, "applications") + createTitleDesc_Frame(appliedLabel.widget, "applications") - local refreshedLabel = DF:CreateLabel(frame, "R") + local refreshedLabel = detailsFramework:CreateLabel(frame, "R") refreshedLabel:SetPoint(headerOffsetsBuffs[4], -10) - create_titledesc_frame (refreshedLabel.widget, "refreshes") + createTitleDesc_Frame(refreshedLabel.widget, "refreshes") - --local waLabel = DF:CreateLabel(frame, "WA") - --waLabel:SetPoint(headerOffsetsBuffs[5], -10) - --create_titledesc_frame (waLabel.widget, "create weak aura") - - local buffScroll = DF:CreateScrollBox (frame, "$parentBuffUptimeScroll", scroll_buff_refresh, {}, scroll_width, scrollHeight, scroll_line_amount, scroll_line_height) + local buffScroll = detailsFramework:CreateScrollBox(frame, "$parentBuffUptimeScroll", scrollRefreshBuffs, {}, scroll_width, scrollHeight, scroll_line_amount, scroll_line_height) buffScroll:SetPoint("topleft", frame, "topleft", 5, -30) for i = 1, scroll_line_amount do - local line = buffScroll:CreateLine (scroll_createline) + local line = buffScroll:CreateLine(createLineScroll) line.AuraType = "BUFF" end - DF:ReskinSlider(buffScroll) + detailsFramework:ReskinSlider(buffScroll) tab.BuffScroll = buffScroll - --debuff scroll - --icon - name - applications - refreshes - uptime - -- - - local debuffLabel = DF:CreateLabel(frame, "Debuff Name") + local debuffLabel = detailsFramework:CreateLabel(frame, "Debuff Name") debuffLabel:SetPoint(headerOffsetsDebuffs[1], -10) - local uptimeLabel2 = DF:CreateLabel(frame, "Uptime") + + local uptimeLabel2 = detailsFramework:CreateLabel(frame, "Uptime") uptimeLabel2:SetPoint(headerOffsetsDebuffs[2], -10) - local appliedLabel2 = DF:CreateLabel(frame, "A") + local appliedLabel2 = detailsFramework:CreateLabel(frame, "A") appliedLabel2:SetPoint(headerOffsetsDebuffs[3], -10) - create_titledesc_frame (appliedLabel2.widget, "applications") + createTitleDesc_Frame(appliedLabel2.widget, "applications") - local refreshedLabel2 = DF:CreateLabel(frame, "R") + local refreshedLabel2 = detailsFramework:CreateLabel(frame, "R") refreshedLabel2:SetPoint(headerOffsetsDebuffs[4], -10) - create_titledesc_frame (refreshedLabel2.widget, "refreshes") + createTitleDesc_Frame(refreshedLabel2.widget, "refreshes") - --local waLabel2 = DF:CreateLabel(frame, "WA") - --waLabel2:SetPoint(headerOffsetsDebuffs[5], -10) - --create_titledesc_frame (waLabel2.widget, "create weak aura") - - local debuffScroll = DF:CreateScrollBox (frame, "$parentDebuffUptimeScroll", scroll_buff_refresh, {}, scroll_width, scrollHeight, scroll_line_amount, scroll_line_height) + local debuffScroll = detailsFramework:CreateScrollBox(frame, "$parentDebuffUptimeScroll", scrollRefreshBuffs, {}, scroll_width, scrollHeight, scroll_line_amount, scroll_line_height) debuffScroll:SetPoint("topleft", frame, "topleft", debuffScrollStartX, -30) for i = 1, scroll_line_amount do - local line = debuffScroll:CreateLine (scroll_createline) + local line = debuffScroll:CreateLine(createLineScroll) line.AuraType = "DEBUFF" end - DF:ReskinSlider(debuffScroll) + detailsFramework:ReskinSlider(debuffScroll) tab.DebuffScroll = debuffScroll @@ -220,9 +187,9 @@ local auras_tab_create = function(tab, frame) end end -local auras_tab_fill = function(tab, player, combat) +local aurasTabFillCallback = function(tab, player, combat) ---@type actor - local miscActor = combat:GetActor(4, player:name()) + local miscActor = combat:GetActor(DETAILS_ATTRIBUTE_MISC, player:Name()) ---@type number local combatTime = combat:GetCombatTime() @@ -233,14 +200,11 @@ local auras_tab_fill = function(tab, player, combat) if (spellContainer) then for spellId, spellTable in spellContainer:ListSpells() do local spellName, _, spellIcon = GetSpellInfo(spellId) - if (not spellTable.uptime) then - --print(_GetSpellInfo(spellID)) - --dumpt(spellObject) - end local uptime = spellTable.uptime or 0 table.insert(newAuraTable, {spellIcon, spellName, uptime, spellTable.appliedamt, spellTable.refreshamt, uptime / combatTime * 100, spellID = spellId}) end end + table.sort(newAuraTable, Details.Sort3) tab.BuffScroll:SetData(newAuraTable) tab.BuffScroll:Refresh() @@ -255,6 +219,7 @@ local auras_tab_fill = function(tab, player, combat) table.insert(newAuraTable, {spellIcon, spellName, spellTable.uptime, spellTable.appliedamt, spellTable.refreshamt, spellTable.uptime / combatTime * 100, spellID = spellId}) end end + table.sort(newAuraTable, Details.Sort3) tab.DebuffScroll:SetData(newAuraTable) tab.DebuffScroll:Refresh() @@ -284,11 +249,11 @@ function Details:InitializeAurasTab() return true end, - auras_tab_fill, --[4] fill function + aurasTabFillCallback, --[4] fill function nil, --[5] onclick - auras_tab_create, --[6] oncreate + createAuraTabOnBreakdownWindow, --[6] oncreate iconTableAuras --icon table ) end \ No newline at end of file diff --git a/frames/window_options2.lua b/frames/window_options2.lua index b4093d61..0aafdc5c 100644 --- a/frames/window_options2.lua +++ b/frames/window_options2.lua @@ -2,12 +2,13 @@ if (true) then --return end +local addonName, Details222 = ... local Details = _G.Details local detailsFramework = _G.DetailsFramework local Loc = _G.LibStub("AceLocale-3.0"):GetLocale("Details") --options panel namespace -Details.options = {} +Details222.OptionsPanel = {} --local tinsert = _G.tinsert local unpack = _G.unpack @@ -32,10 +33,10 @@ local section_menu_button_height = 20 --build the options window function Details:InitializeOptionsWindow(instance) - return Details.options.InitializeOptionsWindow(instance) + return Details222.OptionsPanel.InitializeOptionsWindow(instance) end -function Details.options.InitializeOptionsWindow(instance) +function Details222.OptionsPanel.InitializeOptionsWindow(instance) local DetailsOptionsWindow = detailsFramework:NewPanel(UIParent, _, "DetailsOptionsWindow", _, 897, 592) local optionsFrame = DetailsOptionsWindow.frame @@ -81,7 +82,7 @@ function Details.options.InitializeOptionsWindow(instance) Details.CriarInstancia (_, _, instanceObject.meu_id) end - Details.options.SetCurrentInstanceAndRefresh(instanceObject) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(instanceObject) optionsFrame.updateMicroFrames() end @@ -311,11 +312,11 @@ function Details.options.InitializeOptionsWindow(instance) maxSectionIds = maxSectionIds + 1 end - Details.options.maxSectionIds = maxSectionIds + Details222.OptionsPanel.maxSectionIds = maxSectionIds local buttonYPosition = -40 - function Details.options.SelectOptionsSection(sectionId) + function Details222.OptionsPanel.SelectOptionsSection(sectionId) for i = 1, maxSectionIds do optionsFrame.sectionFramesContainer[i]:Hide() if (optionsFrame.sectionFramesContainer[i].sectionButton) then @@ -330,7 +331,7 @@ function Details.options.InitializeOptionsWindow(instance) optionsFrame.sectionFramesContainer[sectionId].sectionButton:SetIcon({1, 1, 0}, 4, section_menu_button_height -4, "overlay") end - Details.options.SetCurrentInstance(instance) + Details222.OptionsPanel.SetCurrentInstance(instance) --create frames for sections for index, sectionId in ipairs(optionsSectionsOrder) do @@ -368,7 +369,7 @@ function Details.options.InitializeOptionsWindow(instance) buildOptionSectionFunc(sectionFrame) --create a button for the section - local sectionButton = detailsFramework:CreateButton(optionsFrame, function() Details.options.SelectOptionsSection(sectionId) end, section_menu_button_width, section_menu_button_height, sectionsName[sectionId], sectionId, nil, nil, nil, "$parentButtonSection" .. sectionId, nil, options_button_template, options_text_template) + local sectionButton = detailsFramework:CreateButton(optionsFrame, function() Details222.OptionsPanel.SelectOptionsSection(sectionId) end, section_menu_button_width, section_menu_button_height, sectionsName[sectionId], sectionId, nil, nil, nil, "$parentButtonSection" .. sectionId, nil, options_button_template, options_text_template) sectionButton:SetIcon({.4, .4, .4}, 4, section_menu_button_height -4, "overlay") sectionButton:SetPoint("topleft", optionsFrame, "topleft", 10, buttonYPosition) buttonYPosition = buttonYPosition - (section_menu_button_height + 1) @@ -386,7 +387,7 @@ function Details.options.InitializeOptionsWindow(instance) end end - function Details.options.GetOptionsSection(sectionId) + function Details222.OptionsPanel.GetOptionsSection(sectionId) return optionsFrame.sectionFramesContainer[sectionId] end @@ -405,7 +406,7 @@ function Details.options.InitializeOptionsWindow(instance) end end - Details.options.SelectOptionsSection(1) + Details222.OptionsPanel.SelectOptionsSection(1) end -- ~options @@ -426,15 +427,15 @@ function Details:OpenOptionsWindow(instance, bNoReopen, section) local window = _G.DetailsOptionsWindow if (not window) then - Details.options.InitializeOptionsWindow(instance) + Details222.OptionsPanel.InitializeOptionsWindow(instance) window = _G.DetailsOptionsWindow end - Details.options.SetCurrentInstanceAndRefresh(instance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(instance) _G.DetailsPluginContainerWindow.OpenPlugin(_G.DetailsOptionsWindow) if (section) then - Details.options.SelectOptionsSection(section) + Details222.OptionsPanel.SelectOptionsSection(section) end window.instanceDropdown:Refresh() diff --git a/frames/window_options2_sections.lua b/frames/window_options2_sections.lua index eeeafc32..807fa568 100644 --- a/frames/window_options2_sections.lua +++ b/frames/window_options2_sections.lua @@ -58,25 +58,25 @@ local font_select_icon, font_select_texcoord = [[Interface\AddOns\Details\images --store the current instance being edited local currentInstance -function Details.options.SetCurrentInstance(instance) +function Details222.OptionsPanel.SetCurrentInstance(instance) currentInstance = instance end -function Details.options.SetCurrentInstanceAndRefresh(instance) +function Details222.OptionsPanel.SetCurrentInstanceAndRefresh(instance) currentInstance = instance _G.DetailsOptionsWindow.instance = instance --get all the frames created and update the options - for i = 1, Details.options.maxSectionIds do - local sectionFrame = Details.options.GetOptionsSection(i) + for i = 1, Details222.OptionsPanel.maxSectionIds do + local sectionFrame = Details222.OptionsPanel.GetOptionsSection(i) if (sectionFrame.RefreshOptions) then sectionFrame:RefreshOptions() end end - Details.options.UpdateAutoHideSettings(instance) + Details222.OptionsPanel.UpdateAutoHideSettings(instance) end -function Details.options.UpdateAutoHideSettings(instance) +function Details222.OptionsPanel.UpdateAutoHideSettings(instance) for contextId, line in ipairs(_G.DetailsOptionsWindowTab13.AutoHideOptions) do --tab13 = automation settings line.enabledCheckbox:SetValue(instance.hide_on_context[contextId].enabled) line.reverseCheckbox:SetValue(instance.hide_on_context[contextId].inverse) @@ -84,7 +84,7 @@ function Details.options.UpdateAutoHideSettings(instance) end end -function Details.options.RefreshInstances(instance) +function Details222.OptionsPanel.RefreshInstances(instance) if (instance) then Details:InstanceGroupCall(instance, "InstanceRefreshRows") instance:InstanceReset() @@ -94,7 +94,7 @@ function Details.options.RefreshInstances(instance) end end -function Details.options.GetCurrentInstanceInOptionsPanel() +function Details222.OptionsPanel.GetCurrentInstanceInOptionsPanel() return currentInstance end @@ -577,7 +577,7 @@ do local accepted, errortext = Details:SetNickname(text) if (not accepted) then Details:ResetPlayerPersona() - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) end afterUpdate() end, @@ -588,7 +588,7 @@ do type = "execute", func = function(self) Details:ResetPlayerPersona() - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) end, icontexture = [[Interface\GLUES\LOGIN\Glues-CheckBox-Check]], --icontexcoords = {160/512, 179/512, 142/512, 162/512}, @@ -769,7 +769,7 @@ do --add the new skin Details.savedStyles [#Details.savedStyles+1] = dataTable Details:Msg(Loc ["STRING_OPTIONS_SAVELOAD_IMPORT_OKEY"]) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() else Details:Msg(Loc ["STRING_CUSTOM_IMPORT_ERROR"]) @@ -807,7 +807,7 @@ do type = "execute", func = function(self) Details:InstanceGroupCall(currentInstance, "SetUserCustomSkinFile", "") - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, icontexture = [[Interface\GLUES\LOGIN\Glues-CheckBox-Check]], @@ -821,7 +821,7 @@ do get = function() return "" end, set = function(self, _, text) saveAsSkin(text) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) Details:Msg(Loc ["STRING_OPTIONS_SAVELOAD_SKINCREATED"]) afterUpdate() end, @@ -848,7 +848,7 @@ do end Details:Msg(Loc ["STRING_OPTIONS_SAVELOAD_APPLYALL"]) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, icontexture = [[Interface\Buttons\UI-HomeButton]], @@ -887,7 +887,7 @@ do for index, _table in ipairs(Details.savedStyles) do tinsert(loadtable, {value = index, label = _table.name, onclick = function(_, _, index) table.remove (Details.savedStyles, index) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() Details:Msg(Loc ["STRING_OPTIONS_SKIN_REMOVED"]) end, @@ -914,7 +914,7 @@ do else Details:Msg("failed to export skin.") --localize-me end - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, icon = [[Interface\Buttons\UI-GuildButton-MOTD-Up]], color = {1, 1, 1}, iconcolor = {1, .9, .9, 0.8}, texcoord = {1, 0, 0, 1}}) @@ -944,7 +944,7 @@ do get = function() return Details.chat_tab_embed.enabled end, set = function(self, fixedparam, value) Details.chat_embed:SetTabSettings(nil, value) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, name = Loc ["STRING_ENABLED"], @@ -966,7 +966,7 @@ do get = function() return Details.chat_tab_embed.single_window end, set = function(self, fixedparam, value) Details.chat_embed:SetTabSettings (nil, nil, value) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, name = Loc ["STRING_OPTIONS_TABEMB_SINGLE"], @@ -1409,7 +1409,7 @@ do editInstanceSetting(currentInstance, "SetBarSettings", nil, nil, nil, nil, nil, nil, nil, nil, text) end - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() end, name = Loc ["STRING_OPTIONS_BARS_CUSTOM_TEXTURE"], @@ -1539,7 +1539,7 @@ do set = function(self, fixedparam, value) editInstanceSetting(currentInstance, "fontstrings_text_limit_offset", value) editInstanceSetting(currentInstance, "InstanceRefreshRows") - Details.options.RefreshInstances(currentInstance) + Details222.OptionsPanel.RefreshInstances(currentInstance) afterUpdate() end, min = -30, @@ -1604,7 +1604,7 @@ do set = function(self, fixedparam, value) editInstanceSetting(currentInstance, "total_bar", "enabled", value) afterUpdate() - Details.options.RefreshInstances(currentInstance) + Details222.OptionsPanel.RefreshInstances(currentInstance) end, name = Loc ["STRING_ENABLED"], desc = Loc ["STRING_OPTIONS_SHOW_TOTALBAR_DESC"], @@ -2116,8 +2116,8 @@ do local separatorOption = sectionFrame.widget_list[25] local bracketOption = sectionFrame.widget_list[26] local warningLabel = sectionFrame.widget_list[27] - Details.options.textSeparatorOption = separatorOption - Details.options.textbracketOption = bracketOption + Details222.OptionsPanel.textSeparatorOption = separatorOption + Details222.OptionsPanel.textbracketOption = bracketOption sectionFrame:SetScript("OnShow", function() if (currentInstance.use_multi_fontstrings) then @@ -3854,7 +3854,7 @@ do local selectProfile = function(_, _, profileName) Details:ApplyProfile(profileName) Details:Msg(Loc ["STRING_OPTIONS_PROFILE_LOADED"], profileName) - --Details.options.SetCurrentInstanceAndRefresh(currentInstance) + --Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) --afterUpdate() _G.DetailsOptionsWindow:Hide() Details:OpenOptionsWindow(currentInstance, false, 9) @@ -3930,7 +3930,7 @@ do if (new_profile) then Details:ApplyProfile(profileName) afterUpdate() - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) else return Details:Msg(Loc ["STRING_OPTIONS_PROFILE_NOTCREATED"]) end @@ -3970,7 +3970,7 @@ do Details:EraseProfile(profileName) - Details.options.SetCurrentInstanceAndRefresh(currentInstance) + Details222.OptionsPanel.SetCurrentInstanceAndRefresh(currentInstance) afterUpdate() Details:Msg(Loc ["STRING_OPTIONS_PROFILE_REMOVEOKEY"]) end, @@ -5496,7 +5496,7 @@ do sectionFrame.AutoHideOptions[i] = line end - Details.options.UpdateAutoHideSettings(currentInstance) + Details222.OptionsPanel.UpdateAutoHideSettings(currentInstance) --profile by spec diff --git a/functions/boss.lua b/functions/boss.lua index fc144bfd..1670fc53 100644 --- a/functions/boss.lua +++ b/functions/boss.lua @@ -1,18 +1,18 @@ do - local _detalhes = _G.Details + local Details = _G.Details local addonName, Details222 = ... - _detalhes.EncounterInformation = {} + Details.EncounterInformation = {} local ipairs = ipairs --lua local ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --details api functions --return if the player is inside a raid supported by details - function _detalhes:IsInInstance() + function Details:IsInInstance() local _, _, _, _, _, _, _, zoneMapID = GetInstanceInfo() - if (_detalhes.EncounterInformation [zoneMapID]) then + if (Details.EncounterInformation [zoneMapID]) then return true else return false @@ -20,8 +20,8 @@ do end --return the full table with all data for the instance - function _detalhes:GetRaidInfoFromEncounterID (encounterID, encounterEJID) - for id, raidTable in pairs(_detalhes.EncounterInformation) do + function Details:GetRaidInfoFromEncounterID (encounterID, encounterEJID) + for id, raidTable in pairs(Details.EncounterInformation) do if (encounterID) then local ids = raidTable.encounter_ids2 --combatlog if (ids) then @@ -42,12 +42,12 @@ do end --return the ids of trash mobs in the instance - function _detalhes:GetInstanceTrashInfo (mapid) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].trash_ids + function Details:GetInstanceTrashInfo (mapid) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].trash_ids end - function _detalhes:GetInstanceIdFromEncounterId (encounterid) - for id, instanceTable in pairs(_detalhes.EncounterInformation) do + function Details:GetInstanceIdFromEncounterId (encounterid) + for id, instanceTable in pairs(Details.EncounterInformation) do --combatlog encounter id local ids = instanceTable.encounter_ids2 if (ids) then @@ -66,10 +66,10 @@ do end --return the boss table using a encounter id - function _detalhes:GetBossEncounterDetailsFromEncounterId (mapid, encounterid) + function Details:GetBossEncounterDetailsFromEncounterId (mapid, encounterid) if (not mapid) then local bossIndex, instance - for id, instanceTable in pairs(_detalhes.EncounterInformation) do + for id, instanceTable in pairs(Details.EncounterInformation) do local ids = instanceTable.encounter_ids2 if (ids) then bossIndex = ids [encounterid] @@ -90,41 +90,41 @@ do return end - local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] + local bossindex = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounter_ids and Details.EncounterInformation [mapid].encounter_ids [encounterid] if (bossindex) then - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex], bossindex + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex], bossindex else - local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids2 and _detalhes.EncounterInformation [mapid].encounter_ids2 [encounterid] + local bossindex = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounter_ids2 and Details.EncounterInformation [mapid].encounter_ids2 [encounterid] if (bossindex) then - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex], bossindex + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex], bossindex end end end --return the EJ boss id - function _detalhes:GetEncounterIdFromBossIndex (mapid, index) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [index] + function Details:GetEncounterIdFromBossIndex (mapid, index) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounter_ids and Details.EncounterInformation [mapid].encounter_ids [index] end --return the table which contain information about the start of a encounter - function _detalhes:GetEncounterStartInfo (mapid, encounterid) - local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] + function Details:GetEncounterStartInfo (mapid, encounterid) + local bossindex = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounter_ids and Details.EncounterInformation [mapid].encounter_ids [encounterid] if (bossindex) then - return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_start + return Details.EncounterInformation [mapid].encounters [bossindex] and Details.EncounterInformation [mapid].encounters [bossindex].encounter_start end end --return the table which contain information about the end of a encounter - function _detalhes:GetEncounterEndInfo (mapid, encounterid) - local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid] + function Details:GetEncounterEndInfo (mapid, encounterid) + local bossindex = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounter_ids and Details.EncounterInformation [mapid].encounter_ids [encounterid] if (bossindex) then - return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_end + return Details.EncounterInformation [mapid].encounters [bossindex] and Details.EncounterInformation [mapid].encounters [bossindex].encounter_end end end --return the function for the boss - function _detalhes:GetEncounterEnd (mapid, bossindex) - local t = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] + function Details:GetEncounterEnd (mapid, bossindex) + local t = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] if (t) then local _end = t.combat_end if (_end) then @@ -135,37 +135,37 @@ do end --generic boss find function - function _detalhes:GetRaidBossFindFunction (mapid) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].find_boss_encounter + function Details:GetRaidBossFindFunction (mapid) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].find_boss_encounter end --return if the boss need sync - function _detalhes:GetEncounterEqualize (mapid, bossindex) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].equalize + function Details:GetEncounterEqualize (mapid, bossindex) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] and Details.EncounterInformation [mapid].encounters [bossindex].equalize end --return the function for the boss - function _detalhes:GetBossFunction (mapid, bossindex) - local func = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].func + function Details:GetBossFunction (mapid, bossindex) + local func = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] and Details.EncounterInformation [mapid].encounters [bossindex].func if (func) then - return func, _detalhes.EncounterInformation [mapid].encounters [bossindex].funcType + return func, Details.EncounterInformation [mapid].encounters [bossindex].funcType end return end --return the boss table with information about name, adds, spells, etc - function _detalhes:GetBossDetails (mapid, bossindex) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] + function Details:GetBossDetails (mapid, bossindex) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] end --return a table with all names of boss enemies - function _detalhes:GetEncounterActors (mapid, bossindex) + function Details:GetEncounterActors (mapid, bossindex) end --return a table with spells id of specified encounter - function _detalhes:GetEncounterSpells (mapid, bossindex) - local encounter = _detalhes:GetBossDetails (mapid, bossindex) + function Details:GetEncounterSpells (mapid, bossindex) + local encounter = Details:GetBossDetails (mapid, bossindex) local habilidades_poll = {} if (encounter.continuo) then for index, spellid in ipairs(encounter.continuo) do @@ -186,35 +186,35 @@ do end --return a table with all boss ids from a raid instance - function _detalhes:GetBossIds (mapid) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_ids + function Details:GetBossIds (mapid) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].boss_ids end - function _detalhes:InstanceIsRaid (mapid) - return _detalhes:InstanceisRaid (mapid) + function Details:InstanceIsRaid (mapid) + return Details:InstanceisRaid (mapid) end - function _detalhes:InstanceisRaid (mapid) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].is_raid + function Details:InstanceisRaid (mapid) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].is_raid end --return a table with all encounter names present in raid instance - function _detalhes:GetBossNames (mapid) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names + function Details:GetBossNames (mapid) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].boss_names end --return the encounter name - function _detalhes:GetBossName (mapid, bossindex) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names [bossindex] + function Details:GetBossName (mapid, bossindex) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].boss_names [bossindex] end --same thing as GetBossDetails, just a alias - function _detalhes:GetBossEncounterDetails (mapid, bossindex) - return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] + function Details:GetBossEncounterDetails (mapid, bossindex) + return Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] end - function _detalhes:GetEncounterInfoFromEncounterName (EJID, encountername) + function Details:GetEncounterInfoFromEncounterName (EJID, encountername) DetailsFramework.EncounterJournal.EJ_SelectInstance (EJID) --11ms per call for i = 1, 20 do local name = DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, EJID) @@ -228,8 +228,8 @@ do end --return the wallpaper for the raid instance - function _detalhes:GetRaidBackground (mapid) - local bosstables = _detalhes.EncounterInformation [mapid] + function Details:GetRaidBackground (mapid) + local bosstables = Details.EncounterInformation [mapid] if (bosstables) then local bg = bosstables.backgroundFile if (bg) then @@ -238,8 +238,8 @@ do end end --return the icon for the raid instance - function _detalhes:GetRaidIcon (mapid, ejID, instanceType) - local raidIcon = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].icon + function Details:GetRaidIcon (mapid, ejID, instanceType) + local raidIcon = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].icon if (raidIcon) then return raidIcon end @@ -258,8 +258,8 @@ do return nil end - function _detalhes:GetBossIndex (mapid, encounterCLID, encounterEJID, encounterName) - local raidInfo = _detalhes.EncounterInformation [mapid] + function Details:GetBossIndex (mapid, encounterCLID, encounterEJID, encounterName) + local raidInfo = Details.EncounterInformation [mapid] if (raidInfo) then local index = raidInfo.encounter_ids2 [encounterCLID] or raidInfo.encounter_ids [encounterEJID] if (not index) then @@ -275,25 +275,25 @@ do end --return the boss icon - function _detalhes:GetBossIcon (mapid, bossindex) - if (_detalhes.EncounterInformation [mapid]) then + function Details:GetBossIcon (mapid, bossindex) + if (Details.EncounterInformation [mapid]) then local line = math.ceil (bossindex / 4) local x = ( bossindex - ( (line-1) * 4 ) ) / 4 - return x-0.25, x, 0.25 * (line-1), 0.25 * line, _detalhes.EncounterInformation [mapid].icons + return x-0.25, x, 0.25 * (line-1), 0.25 * line, Details.EncounterInformation [mapid].icons end end --return the boss portrit - function _detalhes:GetBossPortrait(mapid, bossindex, encounterName, ejID) + function Details:GetBossPortrait(mapid, bossindex, encounterName, ejID) if (mapid and bossindex) then - local haveIcon = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].portrait + local haveIcon = Details.EncounterInformation [mapid] and Details.EncounterInformation [mapid].encounters [bossindex] and Details.EncounterInformation [mapid].encounters [bossindex].portrait if (haveIcon) then return haveIcon end end if (encounterName and ejID and ejID ~= 0) then - local index, name, description, encounterID, rootSectionID, link = _detalhes:GetEncounterInfoFromEncounterName (ejID, encounterName) + local index, name, description, encounterID, rootSectionID, link = Details:GetEncounterInfoFromEncounterName (ejID, encounterName) if (index and name and encounterID) then local id, name, description, displayInfo, iconImage = DetailsFramework.EncounterJournal.EJ_GetCreatureInfo (1, encounterID) @@ -307,7 +307,7 @@ do end --return a list with names of adds and bosses - function _detalhes:GetEncounterActorsName (EJ_EncounterID) + function Details:GetEncounterActorsName (EJ_EncounterID) --code snippet from wowpedia local actors = {} local stack, encounter, _, _, curSectionID = {}, DetailsFramework.EncounterJournal.EJ_GetEncounterInfo (EJ_EncounterID) @@ -329,10 +329,10 @@ do return actors end - function _detalhes:GetInstanceEJID (mapid) + function Details:GetInstanceEJID (mapid) mapid = mapid or select(8, GetInstanceInfo()) if (mapid) then - local instance_info = _detalhes.EncounterInformation [mapid] + local instance_info = Details.EncounterInformation [mapid] if (instance_info) then return instance_info.ej_id or 0 end @@ -340,7 +340,7 @@ do return 0 end - function _detalhes:GetCurrentDungeonBossListFromEJ() + function Details:GetCurrentDungeonBossListFromEJ() local mapID = C_Map.GetBestMapForUnit ("player") @@ -352,8 +352,8 @@ do local EJ_CInstance = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap(mapID) if (EJ_CInstance and EJ_CInstance ~= 0) then - if (_detalhes.encounter_dungeons [EJ_CInstance]) then - return _detalhes.encounter_dungeons [EJ_CInstance] + if (Details.encounter_dungeons [EJ_CInstance]) then + return Details.encounter_dungeons [EJ_CInstance] end DetailsFramework.EncounterJournal.EJ_SelectInstance (EJ_CInstance) @@ -380,14 +380,14 @@ do end end - _detalhes.encounter_dungeons [EJ_CInstance] = boss_list + Details.encounter_dungeons [EJ_CInstance] = boss_list return boss_list end end - function _detalhes:IsRaidRegistered(mapid) - return _detalhes.EncounterInformation [mapid] and true + function Details:IsRaidRegistered(mapid) + return Details.EncounterInformation [mapid] and true end --this cache is local and isn't shared with other components of the addon @@ -874,8 +874,8 @@ do ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --core - function _detalhes:InstallEncounter(InstanceTable) - _detalhes.EncounterInformation[InstanceTable.id] = InstanceTable + function Details:InstallEncounter(InstanceTable) + Details.EncounterInformation[InstanceTable.id] = InstanceTable return true end end diff --git a/functions/events.lua b/functions/events.lua index 7c26a1d7..4bc2849e 100644 --- a/functions/events.lua +++ b/functions/events.lua @@ -7,6 +7,7 @@ --Event types: Details.RegistredEvents = { --instances + ["DETAILS_STARTED"] = {}, ["DETAILS_INSTANCE_OPEN"] = {}, ["DETAILS_INSTANCE_CLOSE"] = {}, ["DETAILS_INSTANCE_SIZECHANGED"] = {}, @@ -132,9 +133,9 @@ local common_events = { function Details:RegisterEvent(object, event, func) if (not Details.RegistredEvents[event]) then if (object.Msg) then - object:DelayMsg("[debug] unknown event:", event, object.__name) + object:DelayMsg("[debug] unknown event1: " .. (event or "no-event")) else - Details:DelayMsg("[debug] unknown event:", event, object.__name) + Details:DelayMsg("[debug] unknown event2:", event, object.__name) end return end diff --git a/functions/loaddata.lua b/functions/loaddata.lua index b9688e18..153101b8 100644 --- a/functions/loaddata.lua +++ b/functions/loaddata.lua @@ -137,7 +137,7 @@ function Details222.LoadSavedVariables.CombatSegments() Details.tabela_overall = Details.combate:NovaTabela() Details.tabela_vigente = Details.combate:NovaTabela(_, Details.tabela_overall) Details.tabela_pets = Details.container_pets:NovoContainer() - Details:UpdateContainerCombatentes() + Details:UpdatePetCache() if (currentCharacterData.tabela_pets) then Details:Destroy(currentCharacterData.tabela_pets) --saved pet data @@ -193,7 +193,7 @@ function Details222.LoadSavedVariables.CombatSegments() actorContainer.need_refresh = true end - Details:UpdateContainerCombatentes() + Details:UpdatePetCache() Details:RestoreMetatables() end end diff --git a/functions/playerclass.lua b/functions/playerclass.lua index b4501602..f81a6e8d 100644 --- a/functions/playerclass.lua +++ b/functions/playerclass.lua @@ -380,6 +380,12 @@ do --attempt to get from the spells the actor used in the current combat if (not actorSpec) then local currentCombatObject = Details:GetCurrentCombat() + + if (currentCombatObject.__destroyed) then + --schedule made before a destroy combat call, but not cancelled + return + end + for containerId = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do if (actorSpec) then break diff --git a/functions/spellcache.lua b/functions/spellcache.lua index 28c43462..cf712ab6 100644 --- a/functions/spellcache.lua +++ b/functions/spellcache.lua @@ -278,7 +278,7 @@ do local savedSpellData = Details.savedCustomSpells[index] if (savedSpellData) then savedSpellData[2], savedSpellData[3] = spellName or savedSpellData[2], spellIcon or savedSpellData[3] - return rawset (Details.spellcache, savedSpellData[1], {savedSpellData[2], 1, savedSpellData[3]}) + return rawset(Details.spellcache, savedSpellData[1], {savedSpellData[2], 1, savedSpellData[3]}) else return false end @@ -382,12 +382,12 @@ do --overwrite for API GetSpellInfo function Details.getspellinfo = function(spellId) - return unpack(Details.spellcache[spellId]) + return unpack(Details.spellcache[spellId]) --won't be nil due to the __index metatable in the spellcache table end Details.GetSpellInfo = Details.getspellinfo --overwrite SpellInfo if the spell is a DoT, so Details.GetSpellInfo will return the name modified - function Details:SpellIsDot(spellId) + function Details:SetAsDotSpell(spellId) --do nothing if this spell already has a customization if (defaultSpellCustomization[spellId]) then return diff --git a/startup.lua b/startup.lua index 4f24c160..14e0014f 100644 --- a/startup.lua +++ b/startup.lua @@ -316,7 +316,7 @@ function Details:StartMeUp() Details.AnnounceStartup = nil end - Details.Schedules.NewTimer(5, Details.AnnounceStartup, Details) + Details.Schedules.NewTimer(4, Details.AnnounceStartup, Details) if (Details.failed_to_load) then Details.failed_to_load:Cancel() @@ -520,7 +520,7 @@ function Details:StartMeUp() --embed windows on the chat window Details.chat_embed:CheckChatEmbed(true) - if (Details.player_details_window.skin ~= "ElvUI") then + if (Details.player_details_window.skin ~= "ElvUI") then --obsolete local setDefaultSkinOnPlayerBreakdownWindow = function() Details:ApplyPDWSkin("ElvUI") end