Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5823bf839c |
No files matched your search
@@ -90,3 +90,17 @@ function StatusBar:SetColor(r, g, b)
|
|||||||
self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b)
|
self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b)
|
||||||
end
|
end
|
||||||
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
@@ -97,14 +97,18 @@ function UnitFrame:Init(unit, config)
|
|||||||
|
|
||||||
self.hp = StatusBar:new(self, width, height, 0, true, texture, texture)
|
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.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:SetColor(unpack(colors.absorb))
|
||||||
self.absorb:SetFillStyle(Enum.StatusBarFillStyle.Reverse)
|
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:SetColor(unpack(colors.shield))
|
||||||
self.shield:SetRange(0, 1)
|
self.shield:SetRange(0, 1)
|
||||||
self.shield:SetValue(0.6)
|
self.shield:SetValue(0.6)
|
||||||
@@ -444,6 +448,7 @@ function UnitFrame:RegisterEvents()
|
|||||||
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
||||||
secure:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit)
|
secure:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit)
|
||||||
secure:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit)
|
secure:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit)
|
||||||
|
secure:RegisterUnitEvent("UNIT_HEAL_PREDICTION", unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns whether or not the unit guid has changed since the last call to this
|
-- returns whether or not the unit guid has changed since the last call to this
|
||||||
@@ -504,6 +509,7 @@ function UnitFrame:UNIT_HEALTH()
|
|||||||
end
|
end
|
||||||
self:UpdateHealth()
|
self:UpdateHealth()
|
||||||
self:UpdateHealthColor()
|
self:UpdateHealthColor()
|
||||||
|
self:UpdateIncomingHeals()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UnitFrame:UNIT_MAXHEALTH()
|
function UnitFrame:UNIT_MAXHEALTH()
|
||||||
@@ -513,6 +519,15 @@ function UnitFrame:UNIT_MAXHEALTH()
|
|||||||
end
|
end
|
||||||
self:UpdateHealth()
|
self:UpdateHealth()
|
||||||
self:UpdateHealthColor()
|
self:UpdateHealthColor()
|
||||||
|
self:UpdateIncomingHeals()
|
||||||
|
end
|
||||||
|
|
||||||
|
function UnitFrame:UNIT_HEAL_PREDICTION()
|
||||||
|
if self:HasUnitChanged() then
|
||||||
|
self:UpdateAll(true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:UpdateIncomingHeals()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UnitFrame:UNIT_TARGET()
|
function UnitFrame:UNIT_TARGET()
|
||||||
@@ -603,6 +618,7 @@ function UnitFrame:UpdateAll(unitChanged)
|
|||||||
end
|
end
|
||||||
self:UpdateHealth()
|
self:UpdateHealth()
|
||||||
self:UpdateHealthColor()
|
self:UpdateHealthColor()
|
||||||
|
self:UpdateIncomingHeals()
|
||||||
self:UpdateAbsorb()
|
self:UpdateAbsorb()
|
||||||
self:UpdateShield()
|
self:UpdateShield()
|
||||||
self:UpdateRange()
|
self:UpdateRange()
|
||||||
@@ -700,3 +716,21 @@ function UnitFrame:UpdateName()
|
|||||||
end
|
end
|
||||||
self.name:SetText(utf8_truncate((UnitName(self.unit)), 5))
|
self.name:SetText(utf8_truncate((UnitName(self.unit)), 5))
|
||||||
end
|
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
|
||||||
Reference in new issue
Block a user