From 8f8a605c149c81405f2e0745657219eec7f4c4ab Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 12 May 2023 22:06:35 -0300 Subject: [PATCH] Added options "Group Player Spells With Same Name" and ""Group Pets By Spell" --- classes/class_damage.lua | 124 +++++++++++------- .../window_playerbreakdown_spells_options.lua | 21 +++ functions/profiles.lua | 2 + 3 files changed, 100 insertions(+), 47 deletions(-) diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 82d689228..547ae744c 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -3592,10 +3592,7 @@ local ENEMIES_format_amount = function(amount) if (amount <= 0) then return fals function damageClass:ReportEnemyDamageTaken (actor, instance, ShiftKeyDown, ControlKeyDown, fromFrags) --can open the breakdown window now - - - - if (true) then return end + --this function is deprecated if (ShiftKeyDown) then local inimigo = actor.nome @@ -3634,6 +3631,8 @@ function damageClass:ReportEnemyDamageTaken (actor, instance, ShiftKeyDown, Cont return instance:TrocaTabela(instance.segmento, 5, #Details.custom) end + if (true) then return end + local report_table = {"Details!: " .. actor.nome .. " - " .. Loc ["STRING_ATTRIBUTE_DAMAGE_TAKEN"]} Details:FormatReportLines (report_table, tooltip_temp_table, ENEMIES_format_name, ENEMIES_format_amount) @@ -4606,6 +4605,8 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel ---@type table local alreadyAdded = {} + local bShouldMergePlayerSpells = Details.breakdown_spell_tab.merge_players_spells_with_same_name + ---@type number, spelltable for spellId, spellTable in pairs(actorSpells) do spellTable.ChartData = nil --~ChartData @@ -4615,7 +4616,7 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel if (spellName) then ---@type number in which index the spell with the same name was stored local index = alreadyAdded[spellName] - if (index) then + if (index and bShouldMergePlayerSpells) then ---@type spelltableadv local bkSpellData = breakdownSpellDataList[index] @@ -4645,48 +4646,73 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel end --pets spells + local bShouldMergeSpellsWithThePet = false + local bShouldMergePetSpells = Details.breakdown_spell_tab.merge_pet_spells_with_same_name + local actorPets = actorObject:GetPets() for _, petName in ipairs(actorPets) do ---@type actor local petActor = combatObject(DETAILS_ATTRIBUTE_DAMAGE, petName) if (petActor) then --PET - local spells = petActor:GetSpellList() - for spellId, spellTable in pairs(spells) do - ---@cast spellId number - ---@cast spellTable spelltable - - spellTable.ChartData = nil - --PET - ---@type string - local spellName = _GetSpellInfo(spellId) - if (spellName) then - ---@type number in which index the spell with the same name was stored - local index = alreadyAdded[spellName] - if (index) then --PET - ---@type spelltableadv - local bkSpellData = breakdownSpellDataList[index] - - bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable - - ---@type bknesteddata - local nestedData = {spellId = spellId, spellTable = spellTable, petName = petName, value = 0} - bkSpellData.nestedData[#bkSpellData.nestedData+1] = nestedData - bkSpellData.bCanExpand = true - else --PET - ---@type spelltableadv - local bkSpellData = { - id = spellId, - spellschool = spellTable.spellschool, - bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), - bCanExpand = false, - - spellTables = {spellTable}, - nestedData = {{spellId = spellId, spellTable = spellTable, petName = petName, value = 0}}, - } - - detailsFramework:Mixin(bkSpellData, Details.SpellTableMixin) - breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData - alreadyAdded[spellName] = #breakdownSpellDataList + if (bShouldMergeSpellsWithThePet) then + --so, this is the bar with the pet name, it'll have a sum of all pet damage and other stuff to show in a bar + ---@type spelltableadv + local bkSpellData = { + id = 0, + spellschool = spellTable.spellschool, + bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, + + spellTables = {spellTable}, + nestedData = {{spellId = spellId, spellTable = spellTable, petName = petName, value = 0}}, + } + + detailsFramework:Mixin(bkSpellData, Details.SpellTableMixin) + breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData + alreadyAdded[spellName] = #breakdownSpellDataList + + + + else + local spells = petActor:GetSpellList() + --all these spells belong to the current pet in the loop + for spellId, spellTable in pairs(spells) do + ---@cast spellId number + ---@cast spellTable spelltable + + spellTable.ChartData = nil + --PET + ---@type string + local spellName = _GetSpellInfo(spellId) + if (spellName) then + ---@type number in which index the spell with the same name was stored + local index = alreadyAdded[spellName] + if (index and bShouldMergePetSpells) then --PET + ---@type spelltableadv + local bkSpellData = breakdownSpellDataList[index] + + bkSpellData.spellTables[#bkSpellData.spellTables+1] = spellTable + + ---@type bknesteddata + local nestedData = {spellId = spellId, spellTable = spellTable, petName = petName, value = 0} + bkSpellData.nestedData[#bkSpellData.nestedData+1] = nestedData + bkSpellData.bCanExpand = true + else --PET + ---@type spelltableadv + local bkSpellData = { + id = spellId, + spellschool = spellTable.spellschool, + bIsExpanded = Details222.BreakdownWindow.IsSpellExpanded(spellId), + bCanExpand = false, + + spellTables = {spellTable}, + nestedData = {{spellId = spellId, spellTable = spellTable, petName = petName, value = 0}}, + } + + detailsFramework:Mixin(bkSpellData, Details.SpellTableMixin) + breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData + alreadyAdded[spellName] = #breakdownSpellDataList + end end end end @@ -5258,12 +5284,12 @@ end ---@param blockIndex number ---@param summaryBlock breakdownspellblock ---@param spellId number ----@param elapsedTime number +---@param combatTime number ---@param actorName string ---@param spellTable spelltableadv ---@param trinketData trinketdata ---@param combatObject combat -function damageClass:BuildSpellDetails(spellBar, spellBlockContainer, blockIndex, summaryBlock, spellId, elapsedTime, actorName, spellTable, trinketData, combatObject) +function damageClass:BuildSpellDetails(spellBar, spellBlockContainer, blockIndex, summaryBlock, spellId, combatTime, actorName, spellTable, trinketData, combatObject) ---@type number local totalHits = spellTable.counter @@ -5292,7 +5318,11 @@ function damageClass:BuildSpellDetails(spellBar, spellBlockContainer, blockIndex blockLine2.rightText:SetText(Details:GetSpellSchoolFormatedName(spellTable.spellschool)) --spell school blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:Format(spellBar.average)) --average damage - blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellBar.perSecond)) --dps + if (spellBar.perSecond and spellBar.perSecond > 0) then + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellBar.perSecond)) --dps + else + blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.total / combatTime)) --dps + end end local emporwerSpell = spellTable.e_total @@ -5382,7 +5412,7 @@ function damageClass:BuildSpellDetails(spellBar, spellBlockContainer, blockIndex local normalAverage = spellTable.n_total / math.max(normalHitsAmt, 0.0001) blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(normalAverage)) - local tempo = (elapsedTime * spellTable.n_total) / math.max(spellTable.total, 0.001) + local tempo = (combatTime * spellTable.n_total) / math.max(spellTable.total, 0.001) local normalAveragePercent = spellBar.average / normalAverage * 100 local normalTempoPercent = normalAveragePercent * tempo / 100 blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.n_total / normalTempoPercent)) @@ -5410,7 +5440,7 @@ function damageClass:BuildSpellDetails(spellBar, spellBlockContainer, blockIndex local critAverage = Details.SpellTableMixin.GetCritAverage(spellTable) blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(critAverage)) - local tempo = (elapsedTime * spellTable.c_total) / math.max(spellTable.total, 0.001) + local tempo = (combatTime * spellTable.c_total) / math.max(spellTable.total, 0.001) local critAveragePercent = spellBar.average / critAverage * 100 local critTempoPercent = critAveragePercent * tempo / 100 blockLine3.rightText:SetText(Loc ["STRING_DPS"] .. ": " .. Details:CommaValue(spellTable.c_total / critTempoPercent)) diff --git a/frames/window_playerbreakdown_spells_options.lua b/frames/window_playerbreakdown_spells_options.lua index cc7f44aac..24811d340 100644 --- a/frames/window_playerbreakdown_spells_options.lua +++ b/frames/window_playerbreakdown_spells_options.lua @@ -200,6 +200,27 @@ local createOptionsPanel = function() desc = "Background Alpha", }, + {type = "blank"}, + {type = "label", get = function() return "Merge Options" end, text_template = subSectionTitleTextTemplate}, + { --merge player spells + type = "toggle", + get = function() return Details.breakdown_spell_tab.merge_players_spells_with_same_name end, + set = function(self, fixedparam, value) + Details.breakdown_spell_tab.merge_players_spells_with_same_name = value + end, + name = "Group Player Spells With Same Name", + desc = "Group Player Spells With Same Name", + }, + + { --merge pet spells with the same name + type = "toggle", + get = function() return Details.breakdown_spell_tab.merge_pet_spells_with_same_name end, + set = function(self, fixedparam, value) + Details.breakdown_spell_tab.merge_pet_spells_with_same_name = value + end, + name = "Group Pets By Spell", + desc = "Group Pets By Spell", + }, } --build the menu diff --git a/functions/profiles.lua b/functions/profiles.lua index 0d010c835..d9c80161e 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1411,6 +1411,8 @@ local default_global_data = { --/run Details.breakdown_spell_tab.statusbar_alpha = 0.823 --breakdown spell tab breakdown_spell_tab = { + merge_players_spells_with_same_name = true, + merge_pet_spells_with_same_name = true, blockcontainer_width = 430, blockcontainer_height = 270, blockcontainer_islocked = true,