Skip to content

Commit

Permalink
Added Evoker Buff Uptime Bar
Browse files Browse the repository at this point in the history
- Added an extra bar within the evoker damage bar, this new bar when hovered over shows the buff uptime of Ebon Might and Prescience on all players.
  • Loading branch information
Tercioo committed Sep 10, 2023
1 parent 8bbd81d commit 933c107
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 40 deletions.
191 changes: 153 additions & 38 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,7 @@ end
---@param onEnterFunc function?
---@param onLeaveFunc function?
function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount, topAmount, instanceObject, onEnterFunc, onLeaveFunc)
if (extraAmount and extraAmount > 0 and Details.combat_log.evoker_calc_damage) then
if (extraAmount and extraAmount > 0) then
local extraStatusbar = thisLine.extraStatusbar
local initialOffset = 0
local icon_offset_x, icon_offset_y = unpack(instanceObject.row_info.icon_offset)
Expand All @@ -3021,13 +3021,18 @@ function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount,
end

extraStatusbar:SetWidth(extraStatusbarWidth)

--extraStatusbar:SetFrameStrata("TOOLTIP")
extraStatusbar:SetFrameLevel(thisLine:GetFrameLevel() + 1)

extraStatusbar.OnEnterCallback = onEnterFunc
extraStatusbar.OnLeaveCallback = onLeaveFunc

if (Details.combat_log.evoker_calc_damage) then
extraStatusbar:SetAlpha(0.8)
extraStatusbar.defaultAlpha = 0.8
else
extraStatusbar:SetAlpha(0.1)
extraStatusbar.defaultAlpha = 0.1
end
extraStatusbar:Show()
end
end
Expand All @@ -3036,9 +3041,16 @@ end
local handleShowExtraStatusbar = function(thisLine, self, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue)
if (self.spec == 1473 and self.augmentedSpellsContainer) then
--prepare the extra bar to show the damage prediction to augmented evoker
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance, damageClass.PredictedAugSpellsOnEnter, damageClass.PredictedAugSpellsOnLeave)
local onEnterFunc = damageClass.PredictedAugSpellsOnEnter
local onLeaveFunc = damageClass.PredictedAugSpellsOnLeave

Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance, onEnterFunc, onLeaveFunc)
thisLine.extraStatusbar.augmentedSpellsContainer = self.augmentedSpellsContainer
thisLine.extraStatusbar.instance = instance

thisLine.extraStatusbar.actorName = self:Name()

---@cast instance instance
thisLine.extraStatusbar.instanceId = instance:GetId()
else
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance)
end
Expand Down Expand Up @@ -3377,58 +3389,161 @@ function Details:RefreshBarra(thisLine, instance, fromResize) --[[exported]]
self:SetBarLeftText(thisLine, instance, enemy, arenaEnemy, arenaAlly, UsingCustomLeftText)
end


---comment
---@param self table extraStatusbar frame
function damageClass.PredictedAugSpellsOnEnter(self)
if (not Details.show_aug_predicted_spell_damage) then
return
end
if (Details.show_aug_predicted_spell_damage) then
---@type spellcontainer
local spellContainer = self.augmentedSpellsContainer

GameCooltip:Preset(2)
---@type instance
local instanceObject = Details:GetInstance(self.instanceId)
---@type combat
local combatObject = instanceObject:GetCombat()

for spellId, spellTable in spellContainer:ListSpells() do
local spellName, _, spellTexture = GetSpellInfo(spellId)
if (spellName) then
GameCooltip:AddLine(spellName, Details:Format(spellTable.total))
GameCooltip:AddIcon(spellTexture, 1, 1, 14, 14)

local spellsAugmented = {}

--the damage sources are added into the targets table for recycling
---@type table<actorname, valueamount>
local sources = spellTable.targets
for sourceName, sourceAmount in pairs(sources) do
spellsAugmented[#spellsAugmented+1] = {sourceName, sourceAmount}
end

---@type spellcontainer
local spellContainer = self.augmentedSpellsContainer
table.sort(spellsAugmented, Details.Sort2)

GameCooltip:Preset(2)
---@type instance
local instance = self.instance
for i = 1, math.min(#spellsAugmented, 5) do
local sourceName, sourceAmount = unpack(spellsAugmented[i])
GameCooltip:AddLine(sourceName, Details:Format(sourceAmount), 1, "yellow", "yellow", 10)
local actorObject = combatObject:GetActor(1, sourceName)
if (actorObject) then
local actorIcon = Details:GetActorIcon(actorObject)
if (actorIcon) then
GameCooltip:AddIcon(actorIcon.texture, 1, 1, 14, 14, actorIcon.coords.left, actorIcon.coords.right, actorIcon.coords.top, actorIcon.coords.bottom)
else
GameCooltip:AddIcon([[Interface\COMMON\Indicator-Gray]], 1, 1, 14, 14)
end
end
end
end
end
else
---@type instance
local instanceObject = Details:GetInstance(self.instanceId)
---@type combat
local combatObject = instanceObject:GetCombat()

local combatObject = instance:GetCombat()
for spellId, spellTable in spellContainer:ListSpells() do
local spellName, _, spellTexture = GetSpellInfo(spellId)
if (spellName) then
GameCooltip:AddLine(spellName, Details:Format(spellTable.total))
GameCooltip:AddIcon(spellTexture, 1, 1, 14, 14)
local combatTime = combatObject:GetCombatTime()

---@type actorname
local actorName = self.actorName

---@type actorcontainer
local utilityContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_MISC)

local buffUptimeTable = {}

--for each actor in the container
for _, actorObject in utilityContainer:ListActors() do
---@type spellcontainer
local receivedBuffs = actorObject.received_buffs_spells

local spellsAugmented = {}
if (receivedBuffs and actorObject:IsPlayer()) then
for sourceNameSpellId, spellTable in receivedBuffs:ListSpells() do
local sourceName, spellId = strsplit("@", sourceNameSpellId)
if (sourceName == actorName) then
spellId = tonumber(spellId)
local spellName, _, spellIcon = Details.GetSpellInfo(spellId)

--the damage sources are added into the targets table for recycling
---@type table<actorname, valueamount>
local sources = spellTable.targets
for sourceName, sourceAmount in pairs(sources) do
spellsAugmented[#spellsAugmented+1] = {sourceName, sourceAmount}
if (spellName) then
sourceName = detailsFramework:RemoveRealmName(sourceName)
local targetName = actorObject:Name()
targetName = detailsFramework:RemoveRealmName(targetName)

local uptime = spellTable.uptime or 0
buffUptimeTable[#buffUptimeTable+1] = {spellId, uptime, sourceName, targetName, actorObject:Class()}
end
end
end
end
end

table.sort(spellsAugmented, Details.Sort2)
table.sort(buffUptimeTable, Details.Sort2)

for i = 1, math.min(#spellsAugmented, 5) do
local sourceName, sourceAmount = unpack(spellsAugmented[i])
GameCooltip:AddLine(sourceName, Details:Format(sourceAmount), 1, "yellow", "yellow", 10)
local actorObject = combatObject:GetActor(1, sourceName)
if (actorObject) then
local actorIcon = Details:GetActorIcon(actorObject)
if (actorIcon) then
GameCooltip:AddIcon(actorIcon.texture, 1, 1, 14, 14, actorIcon.coords.left, actorIcon.coords.right, actorIcon.coords.top, actorIcon.coords.bottom)
else
GameCooltip:AddIcon([[Interface\COMMON\Indicator-Gray]], 1, 1, 14, 14)
Details:FormatCooltipForSpells()
Details:AddTooltipSpellHeaderText(Loc ["STRING_SPELLS"], headerColor, #buffUptimeTable, Details.tooltip_spell_icon.file, unpack(Details.tooltip_spell_icon.coords))
Details:AddTooltipHeaderStatusbar(.1, .1, .1, 0.834)

local iconSize = 22
local iconBorderInfo = Details.tooltip.icon_border_texcoord

local combatTimeMinutes, combatTimeSeconds = math.floor(combatTime / 60), math.floor(combatTime % 60)
GameCooltip:AddLine("Combat Time", combatTimeMinutes .. "m " .. combatTimeSeconds .. "s" .. " (" .. format("%.1f", 100) .. "%)")
GameCooltip:AddIcon([[Interface\TARGETINGFRAME\UnitFrameIcons]], nil, nil, iconSize, iconSize, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B)
Details:AddTooltipBackgroundStatusbar(false, 100, true, "green")

if (#buffUptimeTable > 0) then
for i = 1, min(30, #buffUptimeTable) do
local uptimeTable = buffUptimeTable[i]

local spellId = uptimeTable[1]
local uptime = uptimeTable[2]
local sourceName = uptimeTable[3]
local targetName = uptimeTable[4]
local targetClass = uptimeTable[5]

local uptimePercent = uptime / combatTime * 100

if (uptime > 0 and uptimePercent < 99.5) then
local spellName, _, spellIcon = _GetSpellInfo(spellId)

if (sourceName) then
targetName = detailsFramework:AddClassColorToText(targetName, targetClass)
targetName = detailsFramework:AddClassIconToText(targetName, targetName, targetClass)
spellName = spellName .. " [" .. targetName .. "]"
end

if (uptime <= combatTime) then
local minutes, seconds = math.floor(uptime / 60), math.floor(uptime % 60)
if (minutes > 0) then
GameCooltip:AddLine(spellName, minutes .. "m " .. seconds .. "s" .. " (" .. format("%.1f", uptimePercent) .. "%)")
Details:AddTooltipBackgroundStatusbar(false, uptimePercent, true, sourceName and "green")
else
GameCooltip:AddLine(spellName, seconds .. "s" .. " (" .. format("%.1f", uptimePercent) .. "%)")
Details:AddTooltipBackgroundStatusbar(false, uptimePercent, true, sourceName and "green")
end

GameCooltip:AddIcon(spellIcon, nil, nil, iconSize, iconSize, iconBorderInfo.L, iconBorderInfo.R, iconBorderInfo.T, iconBorderInfo.B)
end
end
end
else
GameCooltip:AddLine(Loc ["STRING_NO_SPELL"])
end
end

--GameCooltip:SetOption("LeftBorderSize", -5)
--GameCooltip:SetOption("RightBorderSize", 5)
--GameCooltip:SetOption("RightTextMargin", 0)
GameCooltip:SetOption("VerticalOffset", 0)
--GameCooltip:SetOption("AlignAsBlizzTooltip", true)
GameCooltip:SetOption("AlignAsBlizzTooltipFrameHeightOffset", 0)
GameCooltip:SetOption("LineHeightSizeOffset", 0)
GameCooltip:SetOption("VerticalPadding", 0)

GameCooltip:ShowCooltip(self, "tooltip")
end

function damageClass.PredictedAugSpellsOnLeave(self)
GameCooltip:Hide()
--extraStatusbar.defaultAlpha
end

--------------------------------------------- // TOOLTIPS // ---------------------------------------------
Expand Down Expand Up @@ -3902,7 +4017,7 @@ function damageClass:ToolTip_Enemies (instancia, numero, barra, keydown)
local combat = instancia:GetShowingCombat()
local enemy_name = self:name()

Details:Destroy(tooltip_temp_table)
Details:Destroy(tooltip_temp_table) --fix for translit bug report, 'player' is nil

--enemy damage taken
local i = 1
Expand Down
4 changes: 3 additions & 1 deletion classes/class_utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1706,14 +1706,16 @@ function atributo_misc:ToolTipDebuffUptime (instancia, numero, barra)
end

function atributo_misc:ToolTipBuffUptime(instance, barFrame)
---@cast instance instance

local owner = self.owner
if (owner and owner.classe) then
r, g, b = unpack(Details.class_colors[owner.classe])
else
r, g, b = unpack(Details.class_colors[self.classe])
end

local combatTime = instance.showing:GetCombatTime()
local combatTime = instance:GetCombat():GetCombatTime()
local buffUptimeSpells = self:GetSpellContainer("buff")
local buffUptimeTable = {}

Expand Down
2 changes: 1 addition & 1 deletion frames/window_options2_sections.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7100,7 +7100,7 @@ do
afterUpdate()
Details:ClearParserCache()
end,
name = DF:AddClassIconToText("Predict Augmentation Buffs", false, "EVOKER"),
name = DF:AddClassIconToText("Predict Augmentation Damage", false, "EVOKER"),
desc = "Calculate how much the Augmentation Evoker are buffing other players",
boxfirst = true,
},
Expand Down

0 comments on commit 933c107

Please sign in to comment.