From 47bad31a56ebde7040bee99faa31aa815fa5671f Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 15 Mar 2024 15:36:54 -0300 Subject: [PATCH] Added phase and elapsed time for boss wipes on the segment selection menu --- Definitions.lua | 1 + classes/class_combat.lua | 16 ++++++++++++++++ classes/class_utility.lua | 2 +- frames/window_main.lua | 10 ++++++++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Definitions.lua b/Definitions.lua index 78629ece..e13b1d06 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -303,6 +303,7 @@ ---@field GetBossImage fun(combat: combat) : texturepath|textureid get the icon of the encounter ---@field SetDateToNow fun(combat: combat, bSetStartDate: boolean?, bSetEndDate: boolean?) set the date to the current time. format: "H:M:S" ---@field GetBossHealth fun(combat: combat) : number get the percentage of the boss health when the combat ended +---@field GetBossHealthString fun(combat: combat) : string get the percentage of the boss health when the combat ended as a string ---@field GetBossName fun(combat: combat) : string? return the name of the unitId "boss1", nil if the unit doesn't existed during the combat diff --git a/classes/class_combat.lua b/classes/class_combat.lua index 13c189c7..af571abd 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -881,6 +881,22 @@ local segmentTypeToString = { return self.boss_hp end + ---Return the percentage of the boss as a string, includes a zero on the left side if the number is less than 10 + ---@param self combat + ---@return string + function classCombat:GetBossHealthString() + local bossHealth = self:GetBossHealth() + if (bossHealth) then + bossHealth = math.floor(bossHealth * 100) + local bossHealthString = tostring(bossHealth) + if (bossHealth < 10) then + bossHealthString = "0" .. bossHealthString + end + return bossHealthString + end + return "00" + end + ---Get the boss name ---@param self combat ---@return string? diff --git a/classes/class_utility.lua b/classes/class_utility.lua index a6153e73..5fbd6173 100644 --- a/classes/class_utility.lua +++ b/classes/class_utility.lua @@ -175,7 +175,7 @@ local statusBarBackgroundTable_ForDeathTooltip = { --expose in case someone want to customize the death tooltip background Details.StatusBarBackgroundTable_ForDeathTooltip = statusBarBackgroundTable_ForDeathTooltip -function Details.ShowDeathTooltip(instance, lineFrame, combatObject, deathTable) +function Details.ShowDeathTooltip(instance, lineFrame, combatObject, deathTable) --~death local events = deathTable[1] local timeOfDeath = deathTable[2] local maxHP = max(deathTable[5], 0.001) diff --git a/frames/window_main.lua b/frames/window_main.lua index 3e87b0f5..7db66521 100644 --- a/frames/window_main.lua +++ b/frames/window_main.lua @@ -6625,14 +6625,20 @@ local buildSegmentTooltip = function(self, deltaTime) local combatIcon, categoryIcon = thisCombat:GetCombatIcon() + --remove anything after the first comma from the combat name + local commaIndex = string.find(combatName, ",") + if (commaIndex) then + combatName = string.sub(combatName, 1, commaIndex - 1) + end + if (combatInstanceType == "party") then gameCooltip:AddLine(combatName, formattedElapsedTime, 1, dungeonColor, combatTimeColor) elseif (bossInfo.killed) then gameCooltip:AddLine(combatName, formattedElapsedTime, 1, "lime", combatTimeColor) else - --include phase string: "P" .. thisCombat:GetCurrentPhase() .. " " .. - gameCooltip:AddLine(combatName, math.floor(thisCombat:GetBossHealth()*100) .. "%", 1, "orange", combatTimeColor) --formattedElapsedTime + local bossHealth = thisCombat:GetBossHealthString() + gameCooltip:AddLine(combatName, "P" .. thisCombat:GetCurrentPhase() .. " " .. bossHealth .. "% " .. formattedElapsedTime, 1, "orange", combatTimeColor) --formattedElapsedTime end gameCooltip:AddIcon(combatIcon, "main", "left")