HealComm: Add toggle for Absorbs and reduce redundant updates (#94)

* HealComm: Add toggle for Absorbs and reduce redundant updates

* HealComm: Throttle updates, cache anchors
This commit is contained in:
scorpzor
2025-12-24 18:16:58 -05:00
committed by GitHub
parent 3d456d036a
commit 5ee511181e
7 changed files with 169 additions and 37 deletions
+38 -3
View File
@@ -135,7 +135,7 @@ end
function NP:Update_HealComm(nameplate)
local db = NP:PlateDB(nameplate)
if db.health.enable and db.health.healPrediction then
if db.health.enable and db.health.healPrediction and db.health.healPrediction.enable then
if not nameplate:IsElementEnabled('HealCommBar') then
nameplate:EnableElement('HealCommBar')
end
@@ -232,6 +232,15 @@ function NP:Construct_HealComm(frame)
absorbBar:SetStatusBarTexture(texture)
healAbsorbBar:SetStatusBarTexture(texture)
myBar:SetMinMaxValues(0, 1)
myBar:SetValue(0)
otherBar:SetMinMaxValues(0, 1)
otherBar:SetValue(0)
absorbBar:SetMinMaxValues(0, 1)
absorbBar:SetValue(0)
healAbsorbBar:SetMinMaxValues(0, 1)
healAbsorbBar:SetValue(0)
local healPrediction = {
myBar = myBar,
otherBar = otherBar,
@@ -267,6 +276,7 @@ function NP:Configure_HealComm(frame)
healPrediction.maxOverflow = 1 + (c.maxOverflow or 0)
healPrediction.overflowHeals = c.overflowHeals
healPrediction.overflowAbsorbs = c.overflowAbsorbs
healPrediction.absorbs = frame.db.healPrediction.absorbs
if healPrediction.allowClippingUpdate then
NP:SetVisibility_HealComm(healPrediction)
@@ -289,6 +299,13 @@ function NP:Configure_HealComm(frame)
absorbBar:SetOrientation(orientation)
healAbsorbBar:SetOrientation(orientation)
healPrediction.cachedOrientation = orientation
myBar._anchorState = nil
otherBar._anchorState = nil
absorbBar._anchorState = nil
healAbsorbBar._anchorState = nil
if orientation == "HORIZONTAL" then
local p1 = "LEFT"
local p2 = "RIGHT"
@@ -364,12 +381,26 @@ function NP:Configure_HealComm(frame)
frame.HealCommBar.otherBar:SetStatusBarColor(hpc.others.r, hpc.others.g, hpc.others.b)
frame.HealCommBar.absorbBar:SetStatusBarColor(hpc.absorbs.r, hpc.absorbs.g, hpc.absorbs.b, hpc.absorbs.a)
frame.HealCommBar.healAbsorbBar:SetStatusBarColor(hpc.healAbsorbs.r, hpc.healAbsorbs.g, hpc.healAbsorbs.b, hpc.healAbsorbs.a)
if not healPrediction.absorbs then
absorbBar:Hide()
healAbsorbBar:Hide()
end
elseif frame:IsElementEnabled('HealComm4') then
frame:DisableElement('HealComm4')
end
end
local function AnchorPredictionBar(bar, health, orientation, anchorTexture, hasEnoughSpace, overflowMode, p1, p2, reverseAnchorTexture)
local needsReverse = not overflowMode and not hasEnoughSpace
local anchorKey = orientation .. (overflowMode and "O" or (hasEnoughSpace and "E" or "R"))
if bar._anchorState == anchorKey and bar._reverseFill == needsReverse then
return
end
bar._anchorState = anchorKey
bar._reverseFill = needsReverse
bar:ClearAllPoints()
if orientation == "HORIZONTAL" then
@@ -397,8 +428,11 @@ function NP:UpdateHealComm(unit, myIncomingHeal, allIncomingHeal, totalAbsorb, m
if not self.frame or not self.health then return end
local health = self.health
local healthTexture = self.healthBarTexture or health:GetStatusBarTexture()
local orientation = health:GetOrientation()
local healthTexture = self.healthBarTexture
if not healthTexture then
healthTexture = health:GetStatusBarTexture()
self.healthBarTexture = healthTexture
end
local currentHealth = UnitHealth(unit) or 0
local maxHealth = UnitHealthMax(unit) or 1
@@ -406,6 +440,7 @@ function NP:UpdateHealComm(unit, myIncomingHeal, allIncomingHeal, totalAbsorb, m
local otherIncomingHeal = allIncomingHeal - myIncomingHeal
local totalIncomingHeal = myIncomingHeal + otherIncomingHeal
local orientation = self.cachedOrientation or health:GetOrientation()
local p1 = self.anchor1 or (orientation == "HORIZONTAL" and "LEFT" or "BOTTOM")
local p2 = self.anchor2 or (orientation == "HORIZONTAL" and "RIGHT" or "TOP")