From 8875c15b33cf13e5aadd1df9e248531798c54720 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 18 Jul 2023 22:06:06 -0300 Subject: [PATCH] General BugFixes and Changes - Renamed damageActor.extra_bar to damageActor.total_extra - Added: Details:ShowExtraStatusbar(barLineObject, amount, amountPercent, extraAmount) - If any damage actor has 'total_extra' bigger than 0, the extra bar is shown. - List of spec names for spec tooltip detection now load at Startup not at lua compiling. - Fixes on Encounter Details plugin. - Fixed an issue of clicking in a plugin icon in the title bar of Details! but the plugin not open. --- classes/class_damage.lua | 61 +++++++++++-------- core/control.lua | 53 +++++++++------- core/parser.lua | 9 +-- .../window_playerbreakdown.lua | 18 ++++++ frames/window_main.lua | 14 +++-- functions/playerclass.lua | 43 ++++++++----- startup.lua | 2 + 7 files changed, 128 insertions(+), 72 deletions(-) diff --git a/classes/class_damage.lua b/classes/class_damage.lua index 0ed5ca47..35e5c984 100644 --- a/classes/class_damage.lua +++ b/classes/class_damage.lua @@ -207,7 +207,7 @@ function Details:IsEnemy() --[[exported]] return false end -function Details:GetSpellList() --[[ exported]] +function Details:GetSpellList() --[[exported]] return self.spells._ActorTable end @@ -405,7 +405,7 @@ end --total: amount of damage done total = alphabetical, - extra_bar = 0, + total_extra = 0, --totalabsorbed: amount of damage done absorbed by shields totalabsorbed = alphabetical, --total_without_pet: amount of damage done without pet damage @@ -2905,30 +2905,37 @@ function damageClass:RefreshLine(instance, lineContainer, whichRowLine, rank, to return self:RefreshLineValue(thisLine, instance, previousData, forcar, percentNumber, whichRowLine, lineContainer, bUseAnimations) end -local alignExtraBar = function(thisLine, actorObject, instanceObject, percentAmount) - local extraAmount = actorObject.extra_bar - if (extraAmount > 0 and Details.combat_log.evoker_calc_damage) then +---show an extra statusbar on the line, after the main statusbar +---@param thisLine frame +---@param amount valueamount +---@param amountPercent number +---@param extraAmount valueamount +function Details:ShowExtraStatusbar(thisLine, amount, amountPercent, extraAmount, instanceObject) + if (extraAmount and extraAmount > 0 and Details.combat_log.evoker_calc_damage) then local bIsUsingBarStartAfterIcon = instanceObject.row_info.start_after_icon local initialOffset = 0 if (bIsUsingBarStartAfterIcon) then initialOffset = thisLine.icone_classe:GetWidth() end - local whiteBarStartOffset = initialOffset + thisLine:GetWidth() * percentAmount / 100 - local whiteBarWidth = (extraAmount / actorObject.total) * (percentAmount / 100) * thisLine:GetWidth() + local thisLineWidth = thisLine:GetWidth() + initialOffset + local extraStatusbar = thisLine.extraStatusbar - thisLine.extraTexture:SetPoint("left", thisLine, "left", whiteBarStartOffset - 7, 0) - thisLine.extraTexture:SetWidth(whiteBarWidth) + local statusbarStartOffset = thisLineWidth * amountPercent / 100 + extraStatusbar:SetPoint("left", thisLine, "left", statusbarStartOffset, 0) - thisLine.extraTexture:SetHeight(thisLine:GetHeight()) - thisLine.extraTexture:Show() + local statusbarWidth = (extraAmount / amount) * (amountPercent / 100) * thisLineWidth + extraStatusbar:SetSize(statusbarWidth, thisLine:GetHeight()) + + extraStatusbar:SetFrameStrata("TOOLTIP") + extraStatusbar:SetFrameLevel(3000) + + extraStatusbar:Show() end end -function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefresh, percent, whichRowLine, lineContainer, bUseAnimations) --[[ exported]] - if (self.spec ~= 1473) then - thisLine.extraTexture:Hide() - end +function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefresh, percent, whichRowLine, lineContainer, bUseAnimations) --[[exported]] + thisLine.extraStatusbar:Hide() if (thisLine.colocacao == 1) then thisLine.animacao_ignorar = true @@ -2957,8 +2964,8 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre Details.FadeHandler.Fader(thisLine, "out") - if (self.spec == 1473) then - alignExtraBar(thisLine, self, instance, percent) + if (self.total_extra and self.total_extra > 0) then + Details:ShowExtraStatusbar(thisLine, self.total, percent, self.total_extra, instance) end return self:RefreshBarra(thisLine, instance) @@ -2974,8 +2981,8 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre thisLine.last_value = percent --reseta o ultimo valor da barra - if (self.spec == 1473) then - alignExtraBar(thisLine, self, instance, percent) + if (self.total_extra and self.total_extra > 0) then + Details:ShowExtraStatusbar(thisLine, self.total, percent, self.total_extra, instance) end return self:RefreshBarra(thisLine, instance) @@ -2989,11 +2996,15 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre end thisLine.last_value = percent - if (self.spec == 1473) then - alignExtraBar(thisLine, self, instance, percent) + if (self.total_extra and self.total_extra > 0) then + Details:ShowExtraStatusbar(thisLine, self.total, percent, self.total_extra, instance) end return self:RefreshBarra(thisLine, instance) + else + if (self.total_extra and self.total_extra > 0) then + Details:ShowExtraStatusbar(thisLine, self.total, percent, self.total_extra, instance) + end end end end @@ -3008,7 +3019,7 @@ local setLineTextSize = function(line, instance) end -function Details:SetBarLeftText(bar, instance, enemy, arenaEnemy, arenaAlly, usingCustomLeftText) --[[ exported]] +function Details:SetBarLeftText(bar, instance, enemy, arenaEnemy, arenaAlly, usingCustomLeftText) --[[exported]] local barNumber = "" if (instance.row_info.textL_show_number) then barNumber = bar.colocacao .. ". " @@ -3089,7 +3100,7 @@ function Details:SetBarLeftText(bar, instance, enemy, arenaEnemy, arenaAlly, usi setLineTextSize (bar, instance) end -function Details:SetBarColors(bar, instance, r, g, b, a) --[[exported]] +function Details:SetBarColors(bar, instance, r, g, b, a) --[[exported]] --~colors a = a or 1 if (instance.row_info.texture_class_colors) then @@ -3130,7 +3141,7 @@ end ---@param texture texture ---@param instance instance ---@param class string -function Details:SetClassIcon(texture, instance, class) --[[ exported]] +function Details:SetClassIcon(texture, instance, class) --[[exported]] --~icons local customIcon if (Details.immersion_unit_special_icons) then customIcon = Details.Immersion.GetIcon(self.aID) @@ -3226,7 +3237,7 @@ function Details:SetClassIcon(texture, instance, class) --[[ exported]] end -function Details:RefreshBarra(thisLine, instance, fromResize) --[[ exported]] +function Details:RefreshBarra(thisLine, instance, fromResize) --[[exported]] local class, enemy, arenaEnemy, arenaAlly = self.classe, self.enemy, self.arena_enemy, self.arena_ally if (not class) then diff --git a/core/control.lua b/core/control.lua index 1c7d0c21..0f361d49 100644 --- a/core/control.lua +++ b/core/control.lua @@ -1732,39 +1732,48 @@ end function Details:MontaTooltip(frame, whichRowLine, keydown) - - self:BuildInstanceBarTooltip (frame) + self:BuildInstanceBarTooltip(frame) local GameCooltip = GameCooltip - local esta_barra = self.barras [whichRowLine] --barra que o mouse passou em cima e ir� mostrar o tooltip - local objeto = esta_barra.minha_tabela --pega a referencia da tabela --retorna a classe_damage ou classe_heal - if (not objeto) then --a barra n�o possui um objeto + local thisLine = self.barras[whichRowLine] --hoverovered line + local object = thisLine.minha_tabela --the object the line is showing + + --check if the object is valid + if (not object) then return false end - --verifica por tooltips especiais: - if (objeto.dead) then --� uma barra de dead - return Details:ToolTipDead (self, objeto, esta_barra, keydown) --inst�ncia, [morte], barra - elseif (objeto.byspell) then - return Details:ToolTipBySpell (self, objeto, esta_barra, keydown) - elseif (objeto.frags) then - return Details:ToolTipFrags (self, objeto, esta_barra, keydown) - elseif (objeto.boss_debuff) then - return Details:ToolTipVoidZones (self, objeto, esta_barra, keydown) + --check for special tooltips + if (object.dead) then --� uma barra de dead + return Details:ToolTipDead(self, object, thisLine, keydown) --inst�ncia, [morte], barra + + elseif (object.byspell) then + return Details:ToolTipBySpell(self, object, thisLine, keydown) + + elseif (object.frags) then + return Details:ToolTipFrags(self, object, thisLine, keydown) + + elseif (object.boss_debuff) then + return Details:ToolTipVoidZones(self, object, thisLine, keydown) end - local t = objeto:ToolTip (self, whichRowLine, esta_barra, keydown) --inst�ncia, n� barra, objeto barra, keydown + if (not object.ToolTip) then + if (object.__destroyed) then + Details:Msg("object:ToolTip() is invalid.", object.__destroyedBy) + end + end - if (t) then + local bTooltipBuilt = object:ToolTip(self, whichRowLine, thisLine, keydown) --instance, lineId, lineObject, keydown - if (objeto.serial and objeto.serial ~= "") then - local avatar = NickTag:GetNicknameTable (objeto.serial, true) + if (bTooltipBuilt) then + if (object.serial and object.serial ~= "") then + local avatar = NickTag:GetNicknameTable(object.serial, true) if (avatar and not Details.ignore_nicktag) then - if (avatar [2] and avatar [4] and avatar [1]) then - GameCooltip:SetBannerImage (1, 1, avatar [2], 80, 40, avatarPoint, avatarTexCoord, nil) --overlay [2] avatar path - GameCooltip:SetBannerImage (1, 2, avatar [4], 200, 55, backgroundPoint, avatar [5], avatar [6]) --background - GameCooltip:SetBannerText (1, 1, (not Details.ignore_nicktag and avatar [1]) or objeto.nome, textPoint, avatarTextColor, 14, SharedMedia:Fetch ("font", Details.tooltip.fontface)) --text [1] nickname + if (avatar[2] and avatar[4] and avatar[1]) then + GameCooltip:SetBannerImage(1, 1, avatar [2], 80, 40, avatarPoint, avatarTexCoord, nil) --overlay [2] avatar path + GameCooltip:SetBannerImage(1, 2, avatar [4], 200, 55, backgroundPoint, avatar [5], avatar [6]) --background + GameCooltip:SetBannerText(1, 1, (not Details.ignore_nicktag and avatar[1]) or object.nome, textPoint, avatarTextColor, 14, SharedMedia:Fetch("font", Details.tooltip.fontface)) --text [1] nickname end end end diff --git a/core/parser.lua b/core/parser.lua index 8c29f20a..685a8bbe 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -1247,10 +1247,11 @@ end if (evokerActor) then + evokerActor.total_extra = evokerActor.total_extra or 0 if (Details.zone_type == "raid") then - evokerActor.extra_bar = evokerActor.extra_bar + (amount * 0.1389541) + evokerActor.total_extra = evokerActor.total_extra + (amount * 0.1389541) else - evokerActor.extra_bar = evokerActor.extra_bar + (amount * 0.1966044) + evokerActor.total_extra = evokerActor.total_extra + (amount * 0.1966044) end end end @@ -1275,7 +1276,7 @@ end if (evokerActor) then - evokerActor.extra_bar = evokerActor.extra_bar + amount + evokerActor.total_extra = (evokerActor.total_extra or 0) + amount end end end @@ -1308,7 +1309,7 @@ end if (evokerActor) then - evokerActor.extra_bar = evokerActor.extra_bar + amount + evokerActor.total_extra = (evokerActor.total_extra or 0) + amount end end end diff --git a/frames/window_breakdown/window_playerbreakdown.lua b/frames/window_breakdown/window_playerbreakdown.lua index a8a2a29c..1fae30d4 100644 --- a/frames/window_breakdown/window_playerbreakdown.lua +++ b/frames/window_breakdown/window_playerbreakdown.lua @@ -55,6 +55,24 @@ function breakdownWindowFrame.ShowPluginOnBreakdown(pluginObject, button) thisPluginObject.Frame:Hide() end + --check if the breakdown window is closed + if (not breakdownWindowFrame:IsShown()) then + --as the breakdown require an actor and an instance, get a random one + local currentCombat = Details:GetCurrentCombat() + local damageContainer = currentCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE) + local actorObject = damageContainer._ActorTable[1] + if (actorObject) then + local instanceObject = Details:GetInstance(1) + if (instanceObject) then + Details:OpenBreakdownWindow(instanceObject, actorObject) + end + end + end + + if (not breakdownWindowFrame:IsShown()) then + return + end + --reset the template on all plugin buttons for _, thisPluginButton in ipairs(breakdownWindowFrame.RegisteredPluginButtons) do ---@cast thisPluginButton df_button diff --git a/frames/window_main.lua b/frames/window_main.lua index 3f19194e..a30d9b25 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -2251,7 +2251,7 @@ local iconFrame_OnEnter = function(self) end if (actor.spec == 1473 and actor.tipo == DETAILS_ATTRIBUTE_DAMAGE) then - local damageDone = math.floor(actor.total + actor.extra_bar) + local damageDone = math.floor(actor.total + actor.total_extra) GameCooltip:AddLine("Evoker Predicted Damage:", Details:Format(damageDone) .. " (" .. Details:Format(damageDone / Details:GetCurrentCombat():GetCombatTime()) .. ")", 1, "white") GameCooltip:AddIcon([[]], 1, 1, 1, 20) Details:AddTooltipBackgroundStatusbar() @@ -2264,7 +2264,6 @@ local iconFrame_OnEnter = function(self) self.showing = "actor" end end - end local iconFrame_OnLeave = function(self) @@ -4062,11 +4061,14 @@ function gump:CreateNewLine(instance, index) newLine.textura:SetVertTile(false) newLine.statusbar:SetStatusBarTexture(newLine.textura) - newLine.extraTexture = newLine.statusbar:CreateTexture(nil, "overlay") - + newLine.extraStatusbar = CreateFrame("StatusBar", "DetailsBarra_Statusbar2_" .. instance.meu_id .. "_" .. index, newLine) + newLine.extraStatusbar.texture = newLine.extraStatusbar:CreateTexture(nil, "overlay") + newLine.extraStatusbar:SetStatusBarTexture(newLine.extraStatusbar.texture) + --by default painting the extraStatusbar with the evoker color local evokerColor = Details.class_colors["EVOKER"] - newLine.extraTexture:SetColorTexture(unpack(evokerColor)) - newLine.extraTexture:Hide() + newLine.extraStatusbar.texture:SetColorTexture(1, 1, 1, 1) --setColorTexture is very expensive, so set the color once and use vertex color to change it + newLine.extraStatusbar.texture:SetVertexColor(unpack(evokerColor)) + newLine.extraStatusbar:Hide() --frame for hold the backdrop border newLine.border = CreateFrame("Frame", "DetailsBarra_Border_" .. instance.meu_id .. "_" .. index, newLine.statusbar, "BackdropTemplate") diff --git a/functions/playerclass.lua b/functions/playerclass.lua index 78845cc7..53bb990c 100644 --- a/functions/playerclass.lua +++ b/functions/playerclass.lua @@ -276,13 +276,26 @@ do end local specNamesToId = {} - if(DetailsFramework.IsDragonflightAndBeyond()) then - local classSpecList = DetailsFramework.ClassSpecs - for _, specs in pairs(classSpecList) do - for specId, __ in pairs(specs) do - local id, name = GetSpecializationInfoByID(specId) - if (id and name) then - specNamesToId[name] = id; + function Details:BuildSpecsNameCache() + if (DetailsFramework.IsDragonflightAndBeyond()) then + ---@type table> + local classSpecList = DetailsFramework.ClassSpecs + ---@number + local numClasses = GetNumClasses() + + for i = 1, numClasses do + local classInfo = C_CreatureInfo.GetClassInfo(i) + local localizedClassName = classInfo.className + local classTag = classInfo.classFile + + local specIdsList = classSpecList[classTag] + if (specIdsList) then + for specId in pairs(specIdsList) do + local specId2, specName = GetSpecializationInfoByID(specId) + if (specId2 and specName) then + specNamesToId[specName .. " " .. localizedClassName] = specId2 + end + end end end end @@ -391,19 +404,19 @@ do --attempt to get spec from tooltip if (not actorSpec and DetailsFramework:IsDragonflightAndBeyond()) then - local tooltipData = C_TooltipInfo.GetHyperlink("unit:".. actorObject.serial) + local tooltipData = C_TooltipInfo.GetHyperlink("unit:" .. actorObject.serial) if (tooltipData and tooltipData.lines) then - for _, line in pairs(tooltipData.lines) do - if (line.leftText) then - for str in line.leftText:gmatch("%S+") do - if (specNamesToId[str]) then - actorSpec = specNamesToId[str] - end + for i = 1, #tooltipData.lines do + local thisLineData = tooltipData.lines[i] + local text = thisLineData.leftText + if (text and thisLineData.type == 0) then + local specId = specNamesToId[text] + if (specId and type(specId) == "number") then + actorSpec = specId end end end end - end --attempt to get from the spells the actor used in the current combat diff --git a/startup.lua b/startup.lua index 236022a0..f6c90787 100644 --- a/startup.lua +++ b/startup.lua @@ -619,6 +619,8 @@ function Details:StartMeUp() pcall(Details222.ClassCache.MakeCache) + Details:BuildSpecsNameCache() + Details222.Cache.DoMaintenance() function Details:InstallOkey()