Added absorb display to the player health bar

The player health bar will now show a (by default) faded white bar above the health for the amount of absorption the player currently has. The incoming heal bar starts above both the player health and the absorb, if any is present.
Also disabled the PlayerAbsorb bar by default since it's redundant. It can still be enabled separately if desired.
This commit is contained in:
Parnic
2016-10-12 23:18:27 -05:00
parent e26ccdfba1
commit 60a3293095
2 changed files with 93 additions and 2 deletions

View File

@ -13,6 +13,7 @@ function PlayerAbsorb.prototype:GetDefaultSettings()
settings["side"] = IceCore.Side.Left settings["side"] = IceCore.Side.Left
settings["offset"] = 3 settings["offset"] = 3
settings["enabled"] = false
return settings return settings
end end

View File

@ -5,6 +5,7 @@ local IceHUD = _G.IceHUD
PlayerHealth.prototype.resting = nil PlayerHealth.prototype.resting = nil
PlayerHealth.prototype.pendingBlizzardPartyHide = false PlayerHealth.prototype.pendingBlizzardPartyHide = false
PlayerHealth.prototype.absorbAmount = 0
local configMode = false local configMode = false
local HealComm local HealComm
@ -16,6 +17,7 @@ function PlayerHealth.prototype:init()
self:SetDefaultColor("PlayerHealth", 37, 164, 30) self:SetDefaultColor("PlayerHealth", 37, 164, 30)
self:SetDefaultColor("PlayerHealthHealAmount", 37, 164, 30) self:SetDefaultColor("PlayerHealthHealAmount", 37, 164, 30)
self:SetDefaultColor("PlayerHealthAbsorbAmount", 220, 220, 220)
end end
@ -31,8 +33,10 @@ function PlayerHealth.prototype:GetDefaultSettings()
settings["allowMouseInteraction"] = false settings["allowMouseInteraction"] = false
settings["allowMouseInteractionCombat"] = false settings["allowMouseInteractionCombat"] = false
settings["healAlpha"] = 0.6 settings["healAlpha"] = 0.6
settings["absorbAlpha"] = 0.6
settings["lockIconAlpha"] = false settings["lockIconAlpha"] = false
settings["showIncomingHeals"] = true settings["showIncomingHeals"] = true
settings["showAbsorbs"] = true
settings["showStatusIcon"] = true settings["showStatusIcon"] = true
settings["statusIconOffset"] = {x=110, y=0} settings["statusIconOffset"] = {x=110, y=0}
@ -107,6 +111,8 @@ function PlayerHealth.prototype:Enable(core)
self:RegisterEvent("UNIT_HEAL_PREDICTION", "IncomingHealPrediction") self:RegisterEvent("UNIT_HEAL_PREDICTION", "IncomingHealPrediction")
end end
self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateAbsorbAmount")
if (self.moduleSettings.hideBlizz) then if (self.moduleSettings.hideBlizz) then
self:HideBlizz() self:HideBlizz()
end end
@ -164,6 +170,11 @@ function PlayerHealth.prototype:IncomingHealPrediction(event, unit)
end end
end end
function PlayerHealth.prototype:UpdateAbsorbAmount()
self.absorbAmount = UnitGetTotalAbsorbs(self.unit) or 0
self:Update()
end
-- OVERRIDE -- OVERRIDE
function PlayerHealth.prototype:GetOptions() function PlayerHealth.prototype:GetOptions()
@ -327,6 +338,52 @@ function PlayerHealth.prototype:GetOptions()
order = 43.7 order = 43.7
} }
opts["showAbsorbs"] =
{
type = 'toggle',
name = L["Show absorbs"],
desc = L["Whether or not to show absorb amounts as a lighter-colored bar on top of your current health."],
get = function()
return self.moduleSettings.showAbsorbs
end,
set = function(info, v)
if not v then
self.absorbFrame.bar:Hide()
else
self.absorbFrame.bar:Show()
end
self.moduleSettings.showAbsorbs = v
self:Update()
end,
disabled = function()
return not (self.moduleSettings.enabled and IceHUD.WowVer >= 70000)
end,
order = 43.8
}
opts["absorbAlpha"] =
{
type = "range",
name = L["Absorb bar alpha"],
desc = L["What alpha value to use for the bar that displays how much effective health you have including absorbs (This gets multiplied by the bar's current alpha to stay in line with the bar on top of it)"],
min = 0,
max = 100,
step = 5,
get = function()
return self.moduleSettings.absorbAlpha * 100
end,
set = function(info, v)
self.moduleSettings.absorbAlpha = v / 100.0
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled or not self.moduleSettings.showAbsorbs
end,
order = 43.9
}
opts["iconSettings"] = opts["iconSettings"] =
{ {
type = 'group', type = 'group',
@ -824,6 +881,7 @@ function PlayerHealth.prototype:CreateFrame()
PlayerHealth.super.prototype.CreateFrame(self) PlayerHealth.super.prototype.CreateFrame(self)
self:CreateHealBar() self:CreateHealBar()
self:CreateAbsorbBar()
end end
@ -880,6 +938,18 @@ function PlayerHealth.prototype:CreateHealBar()
end end
end end
function PlayerHealth.prototype:CreateAbsorbBar()
self.absorbFrame = self:BarFactory(self.absorbFrame, "LOW","BACKGROUND")
self.absorbFrame.bar:SetVertexColor(self:GetColor("PlayerHealthAbsorbAmount", self.alpha * self.moduleSettings.absorbAlpha))
self:UpdateBar(1, "undef")
if not self.moduleSettings.showAbsorbs or UnitGetTotalAbsorbs == nil then
self.absorbFrame.bar:Hide()
end
end
function PlayerHealth.prototype:EnableClickTargeting(bEnable) function PlayerHealth.prototype:EnableClickTargeting(bEnable)
if bEnable then if bEnable then
@ -1216,7 +1286,7 @@ function PlayerHealth.prototype:Update(unit)
local percent local percent
if incomingHealAmt > 0 then if incomingHealAmt > 0 then
percent = self.maxHealth ~= 0 and ((self.health + incomingHealAmt) / self.maxHealth) or 0 percent = self.maxHealth ~= 0 and ((self.health + (self.absorbAmount or 0) + incomingHealAmt) / self.maxHealth) or 0
if self.moduleSettings.reverse then if self.moduleSettings.reverse then
percent = 1 - percent percent = 1 - percent
-- Rokiyo: I'm thinking the frama strata should also to be set to medium if we're in reverse. -- Rokiyo: I'm thinking the frama strata should also to be set to medium if we're in reverse.
@ -1230,6 +1300,23 @@ function PlayerHealth.prototype:Update(unit)
self:SetBarCoord(self.healFrame, percent) self:SetBarCoord(self.healFrame, percent)
end end
if self.moduleSettings.showAbsorbs and self.absorbFrame and self.absorbFrame.bar and self.absorbAmount then
local percent
if self.absorbAmount > 0 then
percent = self.maxHealth ~= 0 and ((self.health + self.absorbAmount) / self.maxHealth) or 0
if self.moduleSettings.reverse then
percent = 1 - percent
end
else
percent = 0
end
percent = IceHUD:Clamp(percent, 0, 1)
self:SetBarCoord(self.absorbFrame, percent)
end
if not IceHUD.IceCore:ShouldUseDogTags() then if not IceHUD.IceCore:ShouldUseDogTags() then
self:SetBottomText1(math.floor(self.healthPercentage * 100)) self:SetBottomText1(math.floor(self.healthPercentage * 100))
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor) self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), textColor)
@ -1399,6 +1486,9 @@ function PlayerHealth.prototype:UpdateBar(scale, color, alpha)
if self.healFrame and self.healFrame.bar then if self.healFrame and self.healFrame.bar then
self.healFrame.bar:SetVertexColor(self:GetColor("PlayerHealthHealAmount", self.alpha * self.moduleSettings.healAlpha)) self.healFrame.bar:SetVertexColor(self:GetColor("PlayerHealthHealAmount", self.alpha * self.moduleSettings.healAlpha))
end end
if self.absorbFrame and self.absorbFrame.bar then
self.absorbFrame.bar:SetVertexColor(self:GetColor("PlayerHealthAbsorbAmount", self.alpha * self.moduleSettings.absorbAlpha))
end
--[[ seems to be causing taint. oh well --[[ seems to be causing taint. oh well
if self.frame.button then if self.frame.button then
if self.alpha == 0 then if self.alpha == 0 then