1 Commits
Author SHA1 Message Date
Andreas 5823bf839c Add a status bar for incoming heals
This shows a prediction of incoming direct heals.
2026-11-01 16:34:52 +01:00
2 changed files with 51 additions and 3 deletions

No files matched your search

+14
View File
@@ -90,3 +90,17 @@ function StatusBar:SetColor(r, g, b)
self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b)
end
end
function StatusBar:SetAlpha(alpha)
self.bar:SetAlpha(alpha)
end
function StatusBar:GetColor()
local r, g, b = self.bar:GetStatusBarColor()
return r, g, b
end
function StatusBar:AttachTo(statusBar, point, relativePoint)
self.bar:ClearAllPoints()
self.bar:SetPoint(point, statusBar.bar:GetStatusBarTexture(), relativePoint)
end
+37 -3
View File
@@ -97,14 +97,18 @@ function UnitFrame:Init(unit, config)
self.hp = StatusBar:new(self, width, height, 0, true, texture, texture)
self.power = StatusBar:new(self, width, 6, 2, false, texture, texture)
self.power = StatusBar:new(self, width, 6, 3, false, texture, texture)
self.power:Hide()
self.absorb = StatusBar:new(self, width, height, 1, true, texture_top)
self.incomingHeals = StatusBar:new(self, width, height, 1, true, texture)
self.incomingHeals:AttachTo(self.hp, "TOPLEFT", "TOPRIGHT")
self.incomingHeals:Hide()
self.absorb = StatusBar:new(self, width, height, 2, true, texture_top)
self.absorb:SetColor(unpack(colors.absorb))
self.absorb:SetFillStyle(Enum.StatusBarFillStyle.Reverse)
self.shield = StatusBar:new(self, width, height, 1, true, texture_bot)
self.shield = StatusBar:new(self, width, height, 2, true, texture_bot)
self.shield:SetColor(unpack(colors.shield))
self.shield:SetRange(0, 1)
self.shield:SetValue(0.6)
@@ -444,6 +448,7 @@ function UnitFrame:RegisterEvents()
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
secure:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit)
secure:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit)
secure:RegisterUnitEvent("UNIT_HEAL_PREDICTION", unit)
end
-- returns whether or not the unit guid has changed since the last call to this
@@ -504,6 +509,7 @@ function UnitFrame:UNIT_HEALTH()
end
self:UpdateHealth()
self:UpdateHealthColor()
self:UpdateIncomingHeals()
end
function UnitFrame:UNIT_MAXHEALTH()
@@ -513,6 +519,15 @@ function UnitFrame:UNIT_MAXHEALTH()
end
self:UpdateHealth()
self:UpdateHealthColor()
self:UpdateIncomingHeals()
end
function UnitFrame:UNIT_HEAL_PREDICTION()
if self:HasUnitChanged() then
self:UpdateAll(true)
return
end
self:UpdateIncomingHeals()
end
function UnitFrame:UNIT_TARGET()
@@ -603,6 +618,7 @@ function UnitFrame:UpdateAll(unitChanged)
end
self:UpdateHealth()
self:UpdateHealthColor()
self:UpdateIncomingHeals()
self:UpdateAbsorb()
self:UpdateShield()
self:UpdateRange()
@@ -700,3 +716,21 @@ function UnitFrame:UpdateName()
end
self.name:SetText(utf8_truncate((UnitName(self.unit)), 5))
end
function UnitFrame:UpdateIncomingHeals()
local incoming = UnitGetIncomingHeals(self.unit) or 0
local health = UnitHealth(self.unit)
local maxHealth = UnitHealthMax(self.unit)
incoming = math.min(incoming, maxHealth - health)
if incoming <= 0 then
self.incomingHeals:Hide()
else
local r, g, b = self.hp:GetColor()
self.incomingHeals:SetColor(r, g, b)
self.incomingHeals:SetAlpha(0.4)
self.incomingHeals:SetRange(0, maxHealth)
self.incomingHeals:SetValue(incoming)
self.incomingHeals:Show()
end
end