Skip to content

Commit

Permalink
More progress on caching stuff; journal links; cooltip hotfixes; code…
Browse files Browse the repository at this point in the history
… cleanups
  • Loading branch information
Tercioo committed Dec 23, 2022
1 parent ce9a3b8 commit 7d5d800
Show file tree
Hide file tree
Showing 10 changed files with 416 additions and 161 deletions.
1 change: 1 addition & 0 deletions Details.toc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ functions\testbars.lua
functions\editmode.lua
functions\warcraftlogs.lua
functions\textures.lua
functions\journal.lua

core\timemachine.lua

Expand Down
10 changes: 8 additions & 2 deletions Libs/DF/cooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local max = math.max

--api locals
local PixelUtil = PixelUtil or DFPixelUtil
local version = 11
local version = 12

local CONST_MENU_TYPE_MAINMENU = "main"
local CONST_MENU_TYPE_SUBMENU = "sub"
Expand Down Expand Up @@ -2649,10 +2649,12 @@ function DF:CreateCoolTip()

if (anchor and index == 1) then
local myAnchor, hisAnchor, x, y = unpack(anchor)
fontstring:ClearAllPoints()
fontstring:SetPoint(myAnchor, frame.upperImage, hisAnchor or myAnchor, x or 0, y or 0)

elseif (anchor and index == 2) then
local myAnchor, hisAnchor, x, y = unpack(anchor)
fontstring:ClearAllPoints()
fontstring:SetPoint(myAnchor, frame, hisAnchor or myAnchor, x or 0, y or 0)
end

Expand Down Expand Up @@ -2725,10 +2727,12 @@ function DF:CreateCoolTip()
if (type(anchor[1]) == "table") then
for anchorIndex, anchorPoints in ipairs(anchor) do
local myAnchor, hisAnchor, x, y = unpack(anchorPoints)
texture:ClearAllPoints()
texture:SetPoint(myAnchor, frame, hisAnchor or myAnchor, x or 0, y or 0)
end
else
local myAnchor, hisAnchor, x, y = unpack(anchor)
texture:ClearAllPoints()
texture:SetPoint(myAnchor, frame, hisAnchor or myAnchor, x or 0, y or 0)
end
end
Expand All @@ -2737,8 +2741,10 @@ function DF:CreateCoolTip()
local leftCoord, rightCoord, topCoord, bottomCoord = unpack(texCoord)
texture:SetTexCoord(leftCoord, rightCoord, topCoord, bottomCoord)
end

if (overlay) then
texture:SetVertexColor(unpack(overlay))
local red, green, blue, alpha = DF:ParseColors(overlay)
texture:SetVertexColor(red, green, blue, alpha)
end

gameCooltip.Banner[index] = true
Expand Down
9 changes: 8 additions & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 406
local dversion = 407
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -775,6 +775,13 @@ function DF:AddClassColorToText(text, className)
return text
end

function DF:MakeStringFromSpellId(spellId)
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
return "|T" .. spellIcon .. ":16:16:0:0:64:64:4:60:4:60|t " .. spellName
end
end

function DF:GetClassTCoordsAndTexture(class)
local l, r, t, b = unpack(CLASS_ICON_TCOORDS[class])
return l, r, t, b, [[Interface\WORLDSTATEFRAME\Icons-Classes]]
Expand Down
81 changes: 81 additions & 0 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
Details222.Pets = {}
Details222.MythicPlus = {}
Details222.EJCache = {}
Details222.Segments = {}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--initialization stuff
Expand Down Expand Up @@ -994,3 +995,83 @@ if (select(4, GetBuildInfo()) >= 100000) then
end
end)
end

Details222.ClassCache = {}
Details222.ClassCache.ByName = {}
Details222.ClassCache.ByGUID = {}

function Details222.ClassCache.GetClass(value)
local className = Details222.ClassCache.ByName[value] or Details222.ClassCache.ByGUID[value]
if (className) then
return className
end

local _, unitClass = UnitClass(value)
return unitClass
end

function Details222.ClassCache.MakeCache()
--iterage among all segments in the container history, get the damage container and get the actor list, check if the actor is a player and if it is, get the class and store it in the cache
for _, combatObject in ipairs(Details.tabela_historico.tabelas) do
for _, actorObject in combatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do
if (actorObject:IsPlayer()) then
local actorName = actorObject.nome
local actorClass = actorObject.classe
local actorGUID = actorObject.serial
Details222.ClassCache.ByName[actorName] = actorClass
Details222.ClassCache.ByGUID[actorGUID] = actorClass
end
end
end
end

Details222.UnitIdCache = {}
Details222.UnitIdCache.Raid = {
[1] = "raid1",
[2] = "raid2",
[3] = "raid3",
[4] = "raid4",
[5] = "raid5",
[6] = "raid6",
[7] = "raid7",
[8] = "raid8",
[9] = "raid9",
[10] = "raid10",
[11] = "raid11",
[12] = "raid12",
[13] = "raid13",
[14] = "raid14",
[15] = "raid15",
[16] = "raid16",
[17] = "raid17",
[18] = "raid18",
[19] = "raid19",
[20] = "raid20",
[21] = "raid21",
[22] = "raid22",
[23] = "raid23",
[24] = "raid24",
[25] = "raid25",
[26] = "raid26",
[27] = "raid27",
[28] = "raid28",
[29] = "raid29",
[30] = "raid30",
[31] = "raid31",
[32] = "raid32",
[33] = "raid33",
[34] = "raid34",
[35] = "raid35",
[36] = "raid36",
[37] = "raid37",
[38] = "raid38",
[39] = "raid39",
[40] = "raid40",
}

Details222.UnitIdCache.Party = {
[1] = "party1",
[2] = "party2",
[3] = "party3",
[4] = "party4",
}
110 changes: 51 additions & 59 deletions core/meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

local _InCombatLockdown = InCombatLockdown --wow api local

local atributo_damage = _detalhes.atributo_damage --details local
local atributo_heal = _detalhes.atributo_heal --details local
local atributo_energy = _detalhes.atributo_energy --details local
local atributo_misc = _detalhes.atributo_misc --details local
local classDamage = _detalhes.atributo_damage --details local
local classHeal = _detalhes.atributo_heal --details local
local classEnergy = _detalhes.atributo_energy --details local
local classUtility = _detalhes.atributo_misc --details local
local alvo_da_habilidade = _detalhes.alvo_da_habilidade --details local
local habilidade_dano = _detalhes.habilidade_dano --details local
local habilidade_cura = _detalhes.habilidade_cura --details local
Expand Down Expand Up @@ -216,30 +216,30 @@

if (class_type == class_type_dano) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_damage:r_connect_shadow (esta_classe)
shadow = classDamage:r_connect_shadow (esta_classe)
else
shadow = atributo_damage:r_onlyrefresh_shadow (esta_classe)
shadow = classDamage:r_onlyrefresh_shadow (esta_classe)
end

elseif (class_type == class_type_cura) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_heal:r_connect_shadow (esta_classe)
shadow = classHeal:r_connect_shadow (esta_classe)
else
shadow = atributo_heal:r_onlyrefresh_shadow (esta_classe)
shadow = classHeal:r_onlyrefresh_shadow (esta_classe)
end

elseif (class_type == class_type_e_energy) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_energy:r_connect_shadow (esta_classe)
shadow = classEnergy:r_connect_shadow (esta_classe)
else
shadow = atributo_energy:r_onlyrefresh_shadow (esta_classe)
shadow = classEnergy:r_onlyrefresh_shadow (esta_classe)
end

elseif (class_type == class_type_misc) then
if (combate.overall_added and not overall_saved) then
shadow = atributo_misc:r_connect_shadow (esta_classe)
shadow = classUtility:r_connect_shadow (esta_classe)
else
shadow = atributo_misc:r_onlyrefresh_shadow (esta_classe)
shadow = classUtility:r_onlyrefresh_shadow (esta_classe)
end
end

Expand All @@ -262,14 +262,14 @@
--restaura last_events_table
local primeiro_combate = tabelas_do_historico [1] --primeiro combate
if (primeiro_combate) then
primeiro_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
primeiro_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
primeiro_combate [1]:ActorCallFunction (classDamage.r_last_events_table)
primeiro_combate [2]:ActorCallFunction (classHeal.r_last_events_table)
end

local segundo_combate = tabelas_do_historico [2] --segundo combate
if (segundo_combate) then
segundo_combate [1]:ActorCallFunction (atributo_damage.r_last_events_table)
segundo_combate [2]:ActorCallFunction (atributo_heal.r_last_events_table)
segundo_combate [1]:ActorCallFunction (classDamage.r_last_events_table)
segundo_combate [2]:ActorCallFunction (classHeal.r_last_events_table)
end

end
Expand Down Expand Up @@ -748,7 +748,7 @@
UpdateAddOnMemoryUsage()
local memory = GetAddOnMemoryUsage ("Details")
if (memory > _detalhes.memory_ram) then
_detalhes:IniciarColetaDeLixo (true, 60) --sending true doesn't check anythink
_detalhes:RestartInternalGarbageCollector (true, 60) --sending true doesn't check anythink
end
end
end
Expand All @@ -762,96 +762,88 @@
_detalhes:Msg("(debug) checking memory periodically. Using: ",math.floor(memory))
end
if (memory > _detalhes.memory_ram * 1000) then
_detalhes:IniciarColetaDeLixo (1, 60) --sending 1 only check for combat and ignore garbage collect cooldown
_detalhes:RestartInternalGarbageCollector (1, 60) --sending 1 only check for combat and ignore garbage collect cooldown
end
end
end

function _detalhes:IniciarColetaDeLixo (forcar, lastevent)

if (not forcar) then
function _detalhes:RestartInternalGarbageCollector(bShouldForceCollect, lastEvent)
if (not bShouldForceCollect) then
if (_detalhes.ultima_coleta + _detalhes.intervalo_coleta > _detalhes._tempo + 1) then
return

elseif (_detalhes.in_combat or _InCombatLockdown() or _detalhes:IsInInstance()) then
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5)
_detalhes:ScheduleTimer("RestartInternalGarbageCollector", 5)
return
end
else
if (type(forcar) ~= "boolean") then
if (forcar == 1) then
if (type(bShouldForceCollect) ~= "boolean") then
if (bShouldForceCollect == 1) then
if (_detalhes.in_combat or _InCombatLockdown()) then
_detalhes:ScheduleTimer("IniciarColetaDeLixo", 5, forcar)
_detalhes:ScheduleTimer("RestartInternalGarbageCollector", 5, bShouldForceCollect)
return
end
end
end
end

if (_detalhes.debug) then
if (forcar) then
_detalhes:Msg("(debug) collecting garbage with forced state: ", forcar)
if (bShouldForceCollect) then
_detalhes:Msg("(debug) collecting garbage with forced state:", bShouldForceCollect)
else
_detalhes:Msg("(debug) collecting garbage.")
end
end

local memory = GetAddOnMemoryUsage ("Details")
--cleanup all the parser caches
Details:ClearParserCache()

--reseta o cache do parser
_detalhes:ClearParserCache()

--limpa barras que n�o est�o sendo usadas nas inst�ncias.
for index, instancia in ipairs(_detalhes.tabela_instancias) do
if (instancia.barras and instancia.barras [1]) then
for i, barra in ipairs(instancia.barras) do
if (not barra:IsShown()) then
barra.minha_tabela = nil
--cleanup all the window lines (bars) which isn't in use
for index, instanceObject in ipairs(Details.tabela_instancias) do
if (instanceObject.barras and instanceObject.barras[1]) then
for i, lineRow in ipairs(instanceObject.barras) do
if (not lineRow:IsShown()) then
lineRow.minha_tabela = nil
end
end
end
end

--faz a coleta nos 4 atributos
local damage = atributo_damage:ColetarLixo (lastevent)
local heal = atributo_heal:ColetarLixo (lastevent)
local energy = atributo_energy:ColetarLixo (lastevent)
local misc = atributo_misc:ColetarLixo (lastevent)
--do garbage collection on the handler for each actor class
local damage = classDamage:ColetarLixo(lastEvent)
local heal = classHeal:ColetarLixo(lastEvent)
local energy = classEnergy:ColetarLixo(lastEvent)
local misc = classUtility:ColetarLixo(lastEvent)

local limpados = damage + heal + energy + misc

--refresh nas janelas
if (limpados > 0) then
_detalhes:InstanciaCallFunction(_detalhes.reset_window)
Details:InstanciaCallFunction(_detalhes.reset_window)
end

_detalhes:ManutencaoTimeMachine()
Details:ManutencaoTimeMachine()

--print cache states
--if (_detalhes.debug) then
-- _detalhes:Msg("(debug) removed: damage "..damage.." heal "..heal.." energy "..energy.." misc "..misc)
--end

--elimina pets antigos
--cleanup backlisted pets within the handler of actor containers
_detalhes:LimparPets()
if (not _detalhes.in_combat) then
_detalhes:ClearCCPetsBlackList()
Details:ClearCCPetsBlackList()
end

--reseta cache de specs
_detalhes:ResetSpecCache()
--cleanup spec cache
Details:ResetSpecCache()

--wipa container de escudos
wipe(_detalhes.escudos)
--cleanup the shield cache
wipe(Details.escudos)

_detalhes.ultima_coleta = _detalhes._tempo
--set the time of the latest internal garbage collect
Details.ultima_coleta = _detalhes._tempo

if (_detalhes.debug) then
Details:Msg("(debug) executing: collectgarbage().")
collectgarbage()
UpdateAddOnMemoryUsage()
--local memory2 = GetAddOnMemoryUsage ("Details")
--_detalhes:Msg("(debug) memory before: "..memory.." memory after: "..memory2)
end

end

--combates Normais
Expand Down
Loading

0 comments on commit 7d5d800

Please sign in to comment.