Add absorbs, heal absorbs (#90)

* HealComm - Absorb, HealAbsorb

* HealComm - Unify all bars
This commit is contained in:
scorpzor
2025-12-01 13:36:15 -05:00
committed by andrew6180
parent b3dee35be1
commit 3d456d036a
9 changed files with 674 additions and 127 deletions
+134 -54
View File
@@ -16,6 +16,8 @@ end
function UF:SetAlpha_HealComm(obj, show)
obj.myBar:SetAlpha(show and 1 or 0)
obj.otherBar:SetAlpha(show and 1 or 0)
obj.absorbBar:SetAlpha(show and 1 or 0)
obj.healAbsorbBar:SetAlpha(show and 1 or 0)
end
function UF:SetVisibility_HealComm(obj)
@@ -29,9 +31,13 @@ function UF:SetVisibility_HealComm(obj)
if obj.maxOverflow > 1 then
obj.myBar:SetParent(obj.health)
obj.otherBar:SetParent(obj.health)
obj.absorbBar:SetParent(obj.health)
obj.healAbsorbBar:SetParent(obj.health)
else
obj.myBar:SetParent(obj.parent)
obj.otherBar:SetParent(obj.parent)
obj.absorbBar:SetParent(obj.parent)
obj.healAbsorbBar:SetParent(obj.parent)
end
end
@@ -39,22 +45,27 @@ function UF:Construct_HealComm(frame)
local health = frame.Health
local parent = health.ClipFrame
local myBar = CreateFrame("StatusBar", nil, parent)
local otherBar = CreateFrame("StatusBar", nil, parent)
local myBar = E:CreateReversibleStatusBar(nil, parent)
local otherBar = E:CreateReversibleStatusBar(nil, parent)
local absorbBar = E:CreateReversibleStatusBar(nil, parent)
local healAbsorbBar = E:CreateReversibleStatusBar(nil, parent)
myBar:SetFrameLevel(11)
otherBar:SetFrameLevel(11)
UF.statusbars[myBar] = true
UF.statusbars[otherBar] = true
myBar:SetFrameLevel(12)
otherBar:SetFrameLevel(12)
absorbBar:SetFrameLevel(12)
healAbsorbBar:SetFrameLevel(12)
local texture = (not health.isTransparent and health:GetStatusBarTexture()) or E.media.blankTex
UF:Update_StatusBar(myBar, texture)
UF:Update_StatusBar(otherBar, texture)
myBar:SetStatusBarTexture(texture)
otherBar:SetStatusBarTexture(texture)
absorbBar:SetStatusBarTexture(texture)
healAbsorbBar:SetStatusBarTexture(texture)
local healPrediction = {
myBar = myBar,
otherBar = otherBar,
absorbBar = absorbBar,
healAbsorbBar = healAbsorbBar,
PostUpdate = UF.UpdateHealComm,
maxOverflow = 1,
health = health,
@@ -72,8 +83,13 @@ function UF:Configure_HealComm(frame)
local healPrediction = frame.HealCommBar
local myBar = healPrediction.myBar
local otherBar = healPrediction.otherBar
local absorbBar = healPrediction.absorbBar
local healAbsorbBar = healPrediction.healAbsorbBar
local c = self.db.colors.healPrediction
healPrediction.maxOverflow = 1 + (c.maxOverflow or 0)
healPrediction.overflowHeals = c.overflowHeals
healPrediction.overflowAbsorbs = c.overflowAbsorbs
if healPrediction.allowClippingUpdate then
UF:SetVisibility_HealComm(healPrediction)
@@ -86,82 +102,146 @@ function UF:Configure_HealComm(frame)
if frame.db.health then
local health = frame.Health
local orientation = frame.db.health.orientation or health:GetOrientation()
local healthTexture = health:GetStatusBarTexture()
local width = health:GetWidth()
width = (width > 0 and width) or health.WIDTH
local height = health:GetHeight()
height = (height > 0 and height) or health.HEIGHT
healPrediction.healthBarTexture = healthTexture
healPrediction.myBarTexture = myBar:GetStatusBarTexture()
healPrediction.otherBarTexture = otherBar:GetStatusBarTexture()
myBar:SetOrientation(orientation)
otherBar:SetOrientation(orientation)
absorbBar:SetOrientation(orientation)
healAbsorbBar:SetOrientation(orientation)
if orientation == "HORIZONTAL" then
local width = health:GetWidth()
width = (width > 0 and width) or health.WIDTH
local healthTexture = health:GetStatusBarTexture()
local p1 = "LEFT"
local p2 = "RIGHT"
myBar:Size(width, 0)
healPrediction.anchor1 = p1
healPrediction.anchor2 = p2
myBar:SetSize(width, height)
myBar:ClearAllPoints()
myBar:Point("TOP", health, "TOP")
myBar:Point("BOTTOM", health, "BOTTOM")
myBar:Point("LEFT", healthTexture, "RIGHT")
myBar:Point("TOP", health)
myBar:Point("BOTTOM", health)
myBar:Point(p1, healthTexture, p2)
myBar:SetReverseFill(false)
otherBar:Size(width, 0)
otherBar:SetSize(width, height)
otherBar:ClearAllPoints()
otherBar:Point("TOP", health, "TOP")
otherBar:Point("BOTTOM", health, "BOTTOM")
otherBar:Point("LEFT", myBar:GetStatusBarTexture(), "RIGHT")
otherBar:Point("TOP", health)
otherBar:Point("BOTTOM", health)
otherBar:Point(p1, healPrediction.myBarTexture, p2)
otherBar:SetReverseFill(false)
absorbBar:SetSize(width, height)
absorbBar:ClearAllPoints()
absorbBar:Point("TOP", health)
absorbBar:Point("BOTTOM", health)
absorbBar:Point(p1, healthTexture, p2)
absorbBar:SetReverseFill(false)
healAbsorbBar:SetSize(width, height)
healAbsorbBar:ClearAllPoints()
healAbsorbBar:Point("TOP", health)
healAbsorbBar:Point("BOTTOM", health)
healAbsorbBar:Point(p2, healthTexture, p2)
healAbsorbBar:SetReverseFill(true)
else
local height = health:GetHeight()
height = (height > 0 and height) or health.HEIGHT
local healthTexture = health:GetStatusBarTexture()
local p1 = "BOTTOM"
local p2 = "TOP"
myBar:Size(0, height)
healPrediction.anchor1 = p1
healPrediction.anchor2 = p2
myBar:SetSize(width, height)
myBar:ClearAllPoints()
myBar:Point("LEFT", health, "LEFT")
myBar:Point("RIGHT", health, "RIGHT")
myBar:Point("BOTTOM", healthTexture, "TOP")
myBar:Point("LEFT", health)
myBar:Point("RIGHT", health)
myBar:Point(p1, healthTexture, p2)
myBar:SetReverseFill(false)
otherBar:Size(0, height)
otherBar:SetSize(width, height)
otherBar:ClearAllPoints()
otherBar:Point("LEFT", health, "LEFT")
otherBar:Point("RIGHT", health, "RIGHT")
otherBar:Point("BOTTOM", myBar:GetStatusBarTexture(), "TOP")
otherBar:Point("LEFT", health)
otherBar:Point("RIGHT", health)
otherBar:Point(p1, healPrediction.myBarTexture, p2)
otherBar:SetReverseFill(false)
absorbBar:SetSize(width, height)
absorbBar:ClearAllPoints()
absorbBar:Point("LEFT", health)
absorbBar:Point("RIGHT", health)
absorbBar:Point(p1, healthTexture, p2)
absorbBar:SetReverseFill(false)
healAbsorbBar:SetSize(width, height)
healAbsorbBar:ClearAllPoints()
healAbsorbBar:Point("LEFT", health)
healAbsorbBar:Point("RIGHT", health)
healAbsorbBar:Point(p2, healthTexture, p2)
healAbsorbBar:SetReverseFill(true)
end
end
myBar:SetStatusBarColor(c.personal.r, c.personal.g, c.personal.b, c.personal.a)
otherBar:SetStatusBarColor(c.others.r, c.others.g, c.others.b, c.others.a)
absorbBar:SetStatusBarColor(c.absorbs.r, c.absorbs.g, c.absorbs.b, c.absorbs.a)
healAbsorbBar:SetStatusBarColor(c.healAbsorbs.r, c.healAbsorbs.g, c.healAbsorbs.b, c.healAbsorbs.a)
elseif frame:IsElementEnabled("HealComm4") then
frame:DisableElement("HealComm4")
end
end
local function UpdateFillBar(frame, previousTexture, bar, amount)
if amount == 0 then
bar:Hide()
return previousTexture
end
local orientation = frame:GetOrientation()
local function AnchorPredictionBar(bar, health, orientation, anchorTexture, hasEnoughSpace, overflowMode, p1, p2, reverseAnchorTexture)
bar:ClearAllPoints()
if orientation == "HORIZONTAL" then
bar:SetPoint("TOPLEFT", previousTexture, "TOPRIGHT")
bar:SetPoint("BOTTOMLEFT", previousTexture, "BOTTOMRIGHT")
else
bar:SetPoint("BOTTOMRIGHT", previousTexture, "TOPRIGHT")
bar:SetPoint("BOTTOMLEFT", previousTexture, "TOPLEFT")
bar:Point("TOP", health)
bar:Point("BOTTOM", health)
else -- VERTICAL
bar:Point("LEFT", health)
bar:Point("RIGHT", health)
end
local totalWidth, totalHeight = frame:GetSize()
if orientation == "HORIZONTAL" then
bar:Width(totalWidth)
if overflowMode then
bar:Point(p1, anchorTexture, p2)
bar:SetReverseFill(false)
elseif hasEnoughSpace then
bar:Point(p1, anchorTexture, p2)
bar:SetReverseFill(false)
else
bar:Height(totalHeight)
local reverseAnchor = reverseAnchorTexture or health
bar:Point(p2, reverseAnchor, p2)
bar:SetReverseFill(true)
end
return bar:GetStatusBarTexture()
end
function UF:UpdateHealComm(_, myIncomingHeal, allIncomingHeal)
local health = self.health
local previousTexture = health:GetStatusBarTexture()
function UF:UpdateHealComm(unit, myIncomingHeal, allIncomingHeal, totalAbsorb, myCurrentHealAbsorb, allHealAbsorb)
if not self.frame or not self.health then return end
previousTexture = UpdateFillBar(health, previousTexture, self.myBar, myIncomingHeal)
UpdateFillBar(health, previousTexture, self.otherBar, allIncomingHeal)
local health = self.health
local healthTexture = self.healthBarTexture or health:GetStatusBarTexture()
local orientation = health:GetOrientation()
local currentHealth = UnitHealth(unit) or 0
local maxHealth = UnitHealthMax(unit) or 1
local missingHealth = maxHealth - currentHealth
local otherIncomingHeal = allIncomingHeal - myIncomingHeal
local totalIncomingHeal = myIncomingHeal + otherIncomingHeal
local p1 = self.anchor1 or (orientation == "HORIZONTAL" and "LEFT" or "BOTTOM")
local p2 = self.anchor2 or (orientation == "HORIZONTAL" and "RIGHT" or "TOP")
local overflowHeals = self.overflowHeals or false
local overflowAbsorbs = self.overflowAbsorbs or false
AnchorPredictionBar(self.myBar, health, orientation, healthTexture, missingHealth >= myIncomingHeal, overflowHeals, p1, p2)
AnchorPredictionBar(self.otherBar, health, orientation, self.myBarTexture, missingHealth >= totalIncomingHeal, overflowHeals, p1, p2)
AnchorPredictionBar(self.absorbBar, health, orientation, healthTexture, missingHealth >= totalAbsorb, overflowAbsorbs, p1, p2)
AnchorPredictionBar(self.healAbsorbBar, health, orientation, healthTexture, false, false, p1, p2, healthTexture)
end