Code cleanup, framework update and bug fixes

This commit is contained in:
Tercio Jose
2023-06-23 14:16:12 -03:00
parent 9fb2b0d66b
commit a86f717200
6 changed files with 72 additions and 47 deletions
+18 -1
View File
@@ -1,6 +1,6 @@
local dversion = 441
local dversion = 442
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -837,6 +837,23 @@ function DF:RemoveRealmName(name)
return name:gsub(("%-.*"), "")
end
---remove the owner name of the pet or guardian
---@param name string
---@return string, number
function DF:RemoveOwnerName(name)
return name:gsub((" <.*"), "")
end
---remove realm and owner names also remove brackets from spell actors
---@param name string
---@return string
function DF:CleanUpName(name)
name = DF:RemoveRealmName(name)
name = DF:RemoveOwnerName(name)
name = name:gsub("%[%*%]%s", "")
return name
end
---remove the realm name from a name
---@param name string
---@return string, number
+36 -33
View File
@@ -1156,41 +1156,42 @@ function atributo_misc:ToolTipCC (instancia, numero, barra)
return true
end
function atributo_misc:ToolTipDispell (instancia, numero, barra)
function atributo_misc:ToolTipDispell(instancia, numero, barra)
local owner = self.owner
if (owner and owner.classe) then
r, g, b = unpack(_detalhes.class_colors [owner.classe])
r, g, b = unpack(_detalhes.class_colors[owner.classe])
else
r, g, b = unpack(_detalhes.class_colors [self.classe])
r, g, b = unpack(_detalhes.class_colors[self.classe])
end
local meu_total = _math_floor(self ["dispell"])
local totalDispels = math.floor(self["dispell"])
local habilidades = self.dispell_spells._ActorTable
--habilidade usada para dispelar
local meus_dispells = {}
for _spellid, _tabela in pairs(habilidades) do
if (_tabela.dispell) then
meus_dispells [#meus_dispells+1] = {_spellid, _math_floor(_tabela.dispell)} --_math_floor valor é nil, uma magia na tabela de dispel, sem dispel?
--habilidade usada para dispelar
local spellsUsedToDispel = {}
for spellId, spellTable in pairs(habilidades) do
if (spellTable.dispell) then
spellsUsedToDispel[#spellsUsedToDispel+1] = {spellId, math.floor(spellTable.dispell)}
else
Details:Msg("D! table.dispell is invalid. spellId:", _spellid)
Details:Msg("D! table.dispell is invalid. spellId:", spellId)
end
end
table.sort (meus_dispells, _detalhes.Sort2)
table.sort (spellsUsedToDispel, _detalhes.Sort2)
_detalhes:AddTooltipSpellHeaderText (Loc ["STRING_SPELLS"], headerColor, #meus_dispells, [[Interface\ICONS\Spell_Arcane_ArcaneTorrent]], 0.078125, 0.9375, 0.078125, 0.953125)
_detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha)
_detalhes:AddTooltipSpellHeaderText(Loc ["STRING_SPELLS"], headerColor, #spellsUsedToDispel, [[Interface\ICONS\Spell_Arcane_ArcaneTorrent]], 0.078125, 0.9375, 0.078125, 0.953125)
_detalhes:AddTooltipHeaderStatusbar(r, g, b, barAlha)
local icon_size = _detalhes.tooltip.icon_size
local icon_border = _detalhes.tooltip.icon_border_texcoord
if (#meus_dispells > 0) then
for i = 1, min (25, #meus_dispells) do
local esta_habilidade = meus_dispells[i]
local nome_magia, _, icone_magia = _GetSpellInfo(esta_habilidade[1])
GameCooltip:AddLine(nome_magia, esta_habilidade[2].." (".._cstr("%.1f", esta_habilidade[2]/meu_total*100).."%)")
GameCooltip:AddIcon (icone_magia, nil, nil, icon_size.W, icon_size.H, icon_border.L, icon_border.R, icon_border.T, icon_border.B)
if (#spellsUsedToDispel > 0) then
for i = 1, math.min(25, #spellsUsedToDispel) do
local spellInfo = spellsUsedToDispel[i]
local spellId = spellInfo[1]
local amountDispels = spellInfo[2]
local spellName, _, spellicon = _GetSpellInfo(spellId)
GameCooltip:AddLine(spellName, amountDispels .. " (" .. string.format("%.1f", amountDispels / totalDispels * 100) .. "%)")
GameCooltip:AddIcon(spellicon, nil, nil, icon_size.W, icon_size.H, icon_border.L, icon_border.R, icon_border.T, icon_border.B)
_detalhes:AddTooltipBackgroundStatusbar()
end
else
@@ -1198,21 +1199,23 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra)
end
--quais habilidades foram dispaladas
local buffs_dispelados = {}
for _spellid, amt in pairs(self.dispell_oque) do
buffs_dispelados [#buffs_dispelados+1] = {_spellid, amt}
local dispelledSpells = {}
for spellId, amount in pairs(self.dispell_oque) do
dispelledSpells[#dispelledSpells+1] = {spellId, amount}
end
table.sort (buffs_dispelados, _detalhes.Sort2)
table.sort(dispelledSpells, _detalhes.Sort2)
_detalhes:AddTooltipSpellHeaderText (Loc ["STRING_DISPELLED"], headerColor, #buffs_dispelados, [[Interface\ICONS\Spell_Arcane_ManaTap]], 0.078125, 0.9375, 0.078125, 0.953125)
_detalhes:AddTooltipHeaderStatusbar (r, g, b, barAlha)
_detalhes:AddTooltipSpellHeaderText(Loc ["STRING_DISPELLED"], headerColor, #dispelledSpells, [[Interface\ICONS\Spell_Arcane_ManaTap]], 0.078125, 0.9375, 0.078125, 0.953125)
_detalhes:AddTooltipHeaderStatusbar(r, g, b, barAlha)
if (#buffs_dispelados > 0) then
for i = 1, min (25, #buffs_dispelados) do
local esta_habilidade = buffs_dispelados[i]
local nome_magia, _, icone_magia = _GetSpellInfo(esta_habilidade[1])
GameCooltip:AddLine(nome_magia, esta_habilidade[2].." (".._cstr("%.1f", esta_habilidade[2]/meu_total*100).."%)")
GameCooltip:AddIcon (icone_magia, nil, nil, icon_size.W, icon_size.H, icon_border.L, icon_border.R, icon_border.T, icon_border.B)
if (#dispelledSpells > 0) then
for i = 1, math.min(25, #dispelledSpells) do
local spellInfo = dispelledSpells[i]
local spellId = spellInfo[1]
local amountDispels = spellInfo[2]
local spellName, _, spellIcon = _GetSpellInfo(spellId)
GameCooltip:AddLine(spellName, amountDispels .. " (" .. string.format("%.1f", amountDispels / totalDispels * 100) .. "%)")
GameCooltip:AddIcon (spellIcon, nil, nil, icon_size.W, icon_size.H, icon_border.L, icon_border.R, icon_border.T, icon_border.B)
_detalhes:AddTooltipBackgroundStatusbar()
end
end
@@ -1221,7 +1224,7 @@ function atributo_misc:ToolTipDispell (instancia, numero, barra)
local alvos_dispelados = {}
for target_name, amount in pairs(self.dispell_targets) do
alvos_dispelados [#alvos_dispelados + 1] = {target_name, _math_floor(amount), amount / meu_total * 100}
alvos_dispelados [#alvos_dispelados + 1] = {target_name, _math_floor(amount), amount / totalDispels * 100}
end
table.sort (alvos_dispelados, _detalhes.Sort2)
+4 -7
View File
@@ -95,7 +95,6 @@
-- try get the current encounter name during the encounter
local boss_found_not_registered = function(t, ZoneName, ZoneMapID, DifficultyID)
local boss_table = {
index = 0,
name = t[1],
@@ -113,7 +112,6 @@
end
local boss_found = function(index, name, zone, mapid, diff, encounterid)
local mapID = C_Map.GetBestMapForUnit ("player")
local ejid
if (mapID) then
@@ -141,16 +139,16 @@
id = encounterid,
}
if (not Details:IsRaidRegistered (mapid) and Details.zone_type == "raid") then
if (not Details:IsRaidRegistered(mapid) and Details.zone_type == "raid") then
local boss_list = Details:GetCurrentDungeonBossListFromEJ()
if (boss_list) then
local ActorsContainer = Details.tabela_vigente [class_type_dano]._ActorTable
local ActorsContainer = Details.tabela_vigente[class_type_dano]._ActorTable
if (ActorsContainer) then
for index, Actor in ipairs(ActorsContainer) do
if (not Actor.grupo) then
if (boss_list [Actor.nome]) then
if (boss_list[Actor.nome]) then
Actor.boss = true
boss_table.bossimage = boss_list [Actor.nome][4]
boss_table.bossimage = boss_list[Actor.nome][4]
break
end
end
@@ -1424,7 +1422,6 @@
end
function Details:FlagActorsOnCommonFight()
local damage_container = Details.tabela_vigente [1]
local healing_container = Details.tabela_vigente [2]
local energy_container = Details.tabela_vigente [3]
+11 -6
View File
@@ -5724,12 +5724,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--load up data from saved variables for the account (shared among all the players' characters; this is not the Blizzard account, lol).
Details222.LoadSavedVariables.SharedData()
--load data of the segments saved from latest game session
Details222.LoadSavedVariables.CombatSegments()
--load the profiles
Details:LoadConfig()
--load data of the segments saved from latest game session
Details222.LoadSavedVariables.CombatSegments()
Details:UpdateParserGears()
--load auto run code
@@ -5852,14 +5852,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
---@param text string the error to be logged
local addToExitErrors = function(text)
table.insert(exitErrors, 1, Details222.Date.GetDateForLogs() .. "|" .. text)
table.remove(exitErrors, 10)
table.remove(exitErrors, 11)
end
---@type string current step of the logout process, used to log which is the current step when an error happens
local currentStep = ""
Details222.AutoRunCode.OnLogout()
--save the time played on this class, run protected
local savePlayTimeClass, savePlayTimeErrorText = pcall(function() Details.SavePlayTimeOnClass() end)
@@ -5964,6 +5962,13 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_detalhes_database.nick_tag_cache = Details.CopyTable(_detalhes_database.nick_tag_cache)
end
xpcall(saveNicktabCache, logSaverError)
--save auto run code data
tinsert(_detalhes_global.exit_log, "9 - Saving Auto Run Code.")
local saveAutoRunCode = function()
Details222.AutoRunCode.OnLogout()
end
xpcall(saveAutoRunCode, logSaverError)
end) --end of saving data
+2
View File
@@ -171,6 +171,8 @@ function Details222.LoadSavedVariables.CombatSegments()
if (currentCharacterData.tabela_overall) then
Details.tabela_overall = Details.CopyTable(currentCharacterData.tabela_overall)
Details:RestoreOverallMetatables()
else
Details.tabela_overall = Details.combate:NovaTabela()
end
else
Details.tabela_overall = Details.combate:NovaTabela()
+1
View File
@@ -261,6 +261,7 @@ function SlashCmdList.DETAILS (msg, editbox)
resultLog[#resultLog+1] = ""
--from backup
if (__details_backup._exit_error) then
for _, str in ipairs(__details_backup._exit_error) do
resultLog[#resultLog+1] = str