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
+1
View File
@@ -2,6 +2,7 @@
<Script file="Core.lua"/>
<Script file="Math.lua"/>
<Script file="API.lua"/>
<Script file="ReversibleStatusBar.lua"/>
<Script file="AprilFools.lua"/>
<Script file="Fonts.lua"/>
<Script file="Install.lua"/>
+221
View File
@@ -0,0 +1,221 @@
local E = unpack(select(2, ...))
local type = type
local assert = assert
local setmetatable = setmetatable
local CreateFrame = CreateFrame
local barFrame = CreateFrame("Frame")
local reversibleBar_SetScript = barFrame.SetScript
local function reversibleBar_Update(self, sizeChanged, width, height)
local progress = (self.VALUE - self.MINVALUE) / (self.MAXVALUE - self.MINVALUE)
local align1, align2
local TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy
local TLx_, TLy_, BLx_, BLy_, TRx_, TRy_, BRx_, BRy_
local xprogress, yprogress
width = width or self:GetWidth()
height = height or self:GetHeight()
if self.ORIENTATION == "HORIZONTAL" then
xprogress = width * progress
if self.FILLSTYLE == "CENTER" then
align1, align2 = "TOP", "BOTTOM"
elseif self.REVERSE or self.FILLSTYLE == "REVERSE" then
align1, align2 = "TOPRIGHT", "BOTTOMRIGHT"
else
align1, align2 = "TOPLEFT", "BOTTOMLEFT"
end
elseif self.ORIENTATION == "VERTICAL" then
yprogress = height * progress
if self.FILLSTYLE == "CENTER" then
align1, align2 = "LEFT", "RIGHT"
elseif self.REVERSE or self.FILLSTYLE == "REVERSE" then
align1, align2 = "TOPLEFT", "TOPRIGHT"
else
align1, align2 = "BOTTOMLEFT", "BOTTOMRIGHT"
end
end
if self.ROTATE then
TLx, TLy = 0.0, 1.0
TRx, TRy = 0.0, 0.0
BLx, BLy = 1.0, 1.0
BRx, BRy = 1.0, 0.0
TLx_, TLy_ = TLx, TLy
TRx_, TRy_ = TRx, TRy
BLx_, BLy_ = BLx * progress, BLy
BRx_, BRy_ = BRx * progress, BRy
else
TLx, TLy = 0.0, 0.0
TRx, TRy = 1.0, 0.0
BLx, BLy = 0.0, 1.0
BRx, BRy = 1.0, 1.0
TLx_, TLy_ = TLx, TLy
TRx_, TRy_ = TRx * progress, TRy
BLx_, BLy_ = BLx, BLy
BRx_, BRy_ = BRx * progress, BRy
end
if not sizeChanged then
self.bg:ClearAllPoints()
self.bg:SetAllPoints()
self.bg:SetTexCoord(TLx, TLy, BLx, BLy, TRx, TRy, BRx, BRy)
self.fg:ClearAllPoints()
self.fg:SetPoint(align1)
self.fg:SetPoint(align2)
self.fg:SetTexCoord(TLx_, TLy_, BLx_, BLy_, TRx_, TRy_, BRx_, BRy_)
end
if xprogress then
self.fg:SetWidth(xprogress > 0 and xprogress or 0.1)
end
if yprogress then
self.fg:SetHeight(yprogress > 0 and yprogress or 0.1)
end
end
local function reversibleBar_OnSizeChanged(self, width, height)
reversibleBar_Update(self, true, width, height)
end
local function WithinRange(value, minValue, maxValue)
return value >= minValue and value <= maxValue
end
local reversibleBar = setmetatable({
MINVALUE = 0.0,
MAXVALUE = 1.0,
VALUE = 1.0,
ROTATE = true,
REVERSE = false,
ORIENTATION = "HORIZONTAL",
FILLSTYLE = "STANDARD",
SetMinMaxValues = function(self, minValue, maxValue)
assert(
(type(minValue) == "number" and type(maxValue) == "number"),
"Usage: StatusBar:SetMinMaxValues(number, number)"
)
if maxValue > minValue then
self.MINVALUE = minValue
self.MAXVALUE = maxValue
else
self.MINVALUE = 0
self.MAXVALUE = 1
end
if not self.VALUE or self.VALUE > self.MAXVALUE then
self.VALUE = self.MAXVALUE
elseif not self.VALUE or self.VALUE < self.MINVALUE then
self.VALUE = self.MINVALUE
end
reversibleBar_Update(self)
end,
GetMinMaxValues = function(self)
return self.MINVALUE, self.MAXVALUE
end,
SetValue = function(self, value)
assert(type(value) == "number", "Usage: StatusBar:SetValue(number)")
if WithinRange(value, self.MINVALUE, self.MAXVALUE) then
self.VALUE = value
reversibleBar_Update(self)
end
end,
GetValue = function(self)
return self.VALUE
end,
SetOrientation = function(self, orientation)
if orientation == "HORIZONTAL" or orientation == "VERTICAL" then
self.ORIENTATION = orientation
reversibleBar_Update(self)
end
end,
GetOrientation = function(self)
return self.ORIENTATION
end,
SetRotatesTexture = function(self, rotate)
self.ROTATE = (rotate ~= nil and rotate ~= false)
reversibleBar_Update(self)
end,
GetRotatesTexture = function(self)
return self.ROTATE
end,
SetReverseFill = function(self, reverse)
self.REVERSE = (reverse == true)
reversibleBar_Update(self)
end,
GetReverseFill = function(self)
return self.REVERSE
end,
SetFillStyle = function(self, style)
assert(type(style) == "string" or style == nil, "Usage: StatusBar:SetFillStyle(string)")
if style and style:lower() == "center" then
self.FILLSTYLE = "CENTER"
reversibleBar_Update(self)
elseif style and style:lower() == "reverse" then
self.FILLSTYLE = "REVERSE"
reversibleBar_Update(self)
else
self.FILLSTYLE = "STANDARD"
reversibleBar_Update(self)
end
end,
GetFillStyle = function(self)
return self.FILLSTYLE
end,
SetStatusBarTexture = function(self, texture)
self.fg:SetTexture(texture)
self.bg:SetTexture(texture)
end,
GetStatusBarTexture = function(self)
return self.fg
end,
SetStatusBarColor = function(self, r, g, b, a)
self.fg:SetVertexColor(r, g, b, a)
end,
GetStatusBarColor = function(self)
return self.fg:GetVertexColor()
end,
SetVertexColor = function(self, r, g, b, a)
self.fg:SetVertexColor(r, g, b, a)
end,
GetVertexColor = function(self)
return self.fg:GetVertexColor()
end,
GetObjectType = function(self)
return "StatusBar"
end,
IsObjectType = function(self, otype)
return (otype == "StatusBar") and 1 or nil
end,
SetScript = function(self, event, callback)
reversibleBar_SetScript(self, event, callback)
end,
Show = function(self)
self:SetAlpha(1)
end,
Hide = function(self)
self:SetAlpha(0)
end,
SetAlpha = function(self, alpha)
self:GetParent().SetAlpha(self, alpha)
end
}, {__index = barFrame})
local reversibleBar_mt = {__index = reversibleBar}
function E:CreateReversibleStatusBar(name, parent)
local bar = setmetatable(CreateFrame("Frame", name, parent), reversibleBar_mt)
bar.fg = bar.fg or bar:CreateTexture(name and "$parent.Texture", "ARTWORK")
bar.bg = bar.bg or bar:CreateTexture(name and "$parent.Background", "BACKGROUND")
bar.bg:Hide()
bar:HookScript("OnSizeChanged", reversibleBar_OnSizeChanged)
bar:SetRotatesTexture(false)
return bar
end
+34
View File
@@ -59,6 +59,8 @@ local UnitPVPName = UnitPVPName
local UnitPVPRank = UnitPVPRank
local UnitReaction = UnitReaction
local UnitSex = UnitSex
local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs
local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs
local C_QuestLog_GetTitleForQuestID = GetTitleForQuestID
local C_QuestLog_GetQuestDifficultyLevel = function(questID)
@@ -441,6 +443,34 @@ E:AddTag('health:deficit-percent:name', 'UNIT_HEALTH UNIT_MAXHEALTH UNIT_NAME_UP
end
end)
E:AddTag('health:absorb', 'UNIT_ABSORB_AMOUNT_CHANGED', function(unit)
local absorb = UnitGetTotalAbsorbs(unit) or 0
if absorb > 0 then
return E:GetFormattedText('CURRENT', absorb, UnitHealthMax(unit))
end
end)
E:AddTag('health:absorb:shortvalue', 'UNIT_ABSORB_AMOUNT_CHANGED', function(unit)
local absorb = UnitGetTotalAbsorbs(unit) or 0
if absorb > 0 then
return E:GetFormattedText('CURRENT', absorb, UnitHealthMax(unit), nil, true)
end
end)
E:AddTag('health:healAbsorb', 'UNIT_HEAL_ABSORB_AMOUNT_CHANGED', function(unit)
local healAbsorb = UnitGetTotalHealAbsorbs(unit) or 0
if healAbsorb > 0 then
return E:GetFormattedText('CURRENT', healAbsorb, UnitHealthMax(unit))
end
end)
E:AddTag('health:healAbsorb:shortvalue', 'UNIT_HEAL_ABSORB_AMOUNT_CHANGED', function(unit)
local healAbsorb = UnitGetTotalHealAbsorbs(unit) or 0
if healAbsorb > 0 then
return E:GetFormattedText('CURRENT', healAbsorb, UnitHealthMax(unit), nil, true)
end
end)
E:AddTag('power:max', 'UNIT_DISPLAYPOWER UNIT_MAXPOWER', function(unit)
local powerType = UnitPowerType(unit)
local max = UnitPowerMax(unit, powerType)
@@ -1344,6 +1374,10 @@ E.TagInfo = {
['health:deficit'] = { category = 'Health', description = "Displays the health of the unit as a deficit (Total Health - Current Health = -Deficit)" },
['health:max:shortvalue'] = { category = 'Health', description = "Shortvalue of the unit's maximum health" },
['health:max'] = { category = 'Health', description = "Displays the maximum health of the unit" },
['health:absorb'] = { category = 'Health', description = "Displays the amount of damage absorbed by shields on the unit" },
['health:absorb:shortvalue'] = { category = 'Health', description = "Shortvalue of the amount of damage absorbed by shields on the unit" },
['health:healAbsorb'] = { category = 'Health', description = "Displays the amount of healing absorbed by debuffs on the unit" },
['health:healAbsorb:shortvalue'] = { category = 'Health', description = "Shortvalue of the amount of healing absorbed by debuffs on the unit" },
['health:percent-nostatus'] = { category = 'Health', description = "Displays the unit's current health as a percentage, without status" },
['health:percent'] = { category = 'Health', description = "Displays the current health of the unit as a percentage" },
['maxhp'] = { category = 'Health', description = "Displays max HP without decimals" },
@@ -53,6 +53,8 @@ local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitName = UnitName
local UnitGetIncomingHeals = UnitGetIncomingHeals
local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs
local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs
local enabledUF, enabled = {}, nil
@@ -72,19 +74,39 @@ local function Update(self)
local myIncomingHeal = UnitGetIncomingHeals(unit, UnitName("player")) or 0
local allIncomingHeal = UnitGetIncomingHeals(unit) or 0
local absorb = UnitGetTotalAbsorbs and UnitGetTotalAbsorbs(unit) or 0
local healAbsorb = UnitGetTotalHealAbsorbs and UnitGetTotalHealAbsorbs(unit) or 0
local health = UnitHealth(unit)
local maxHealth = UnitHealthMax(unit)
local maxOverflowHP = maxHealth * element.maxOverflow
local otherIncomingHeal = 0
if health + allIncomingHeal > maxOverflowHP then
allIncomingHeal = maxOverflowHP - health
if healAbsorb > allIncomingHeal then
healAbsorb = healAbsorb - allIncomingHeal
allIncomingHeal = 0
myIncomingHeal = 0
else
allIncomingHeal = allIncomingHeal - healAbsorb
healAbsorb = 0
if element.overflowHeals then
if health + allIncomingHeal > maxOverflowHP then
allIncomingHeal = maxOverflowHP - health
end
end
if allIncomingHeal < myIncomingHeal then
myIncomingHeal = allIncomingHeal
else
otherIncomingHeal = allIncomingHeal - myIncomingHeal
end
end
if allIncomingHeal < myIncomingHeal then
myIncomingHeal = allIncomingHeal
else
otherIncomingHeal = allIncomingHeal - myIncomingHeal
if element.overflowAbsorbs then
local maxAbsorb = maxOverflowHP - health
if absorb > maxAbsorb then
absorb = maxAbsorb > 0 and maxAbsorb or 0
end
end
if element.myBar then
@@ -99,16 +121,38 @@ local function Update(self)
element.otherBar:Show()
end
--[[ Callback: HealthPrediction:PostUpdate(unit, myIncomingHeal, otherIncomingHeal)
if element.absorbBar then
element.absorbBar:SetMinMaxValues(0, maxHealth)
element.absorbBar:SetValue(absorb)
if absorb > 0 then
element.absorbBar:Show()
else
element.absorbBar:Hide()
end
end
if element.healAbsorbBar then
element.healAbsorbBar:SetMinMaxValues(0, maxHealth)
element.healAbsorbBar:SetValue(healAbsorb)
if healAbsorb > 0 then
element.healAbsorbBar:Show()
else
element.healAbsorbBar:Hide()
end
end
--[[ Callback: HealthPrediction:PostUpdate(unit, myIncomingHeal, otherIncomingHeal, absorb, healAbsorb)
Called after the element has been updated.
* self - the HealthPrediction element
* unit - the unit for which the update has been triggered (string)
* myIncomingHeal - the amount of incoming healing done by the player (number)
* otherIncomingHeal - the amount of incoming healing done by others (number)
* absorb - the amount of damage the unit can absorb without losing health (number)
* healAbsorb - the amount of healing the unit can absorb without gaining health (number)
--]]
if element.PostUpdate then
return element:PostUpdate(unit, myIncomingHeal, otherIncomingHeal)
return element:PostUpdate(unit, myIncomingHeal, otherIncomingHeal, absorb, healAbsorb)
end
end
@@ -154,17 +198,19 @@ local function Enable(self)
self:RegisterEvent("UNIT_HEALTH", Path)
self:RegisterEvent("UNIT_MAXHEALTH", Path)
self:RegisterEvent("UNIT_HEAL_PREDICTION", Path)
self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", Path)
self:RegisterEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", Path)
if not element.maxOverflow then
element.maxOverflow = 1.05
end
if element.myBar and element.myBar:IsObjectType("StatusBar") and not element.myBar:GetStatusBarTexture() then
element.myBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
if element.absorbBar and element.absorbBar:IsObjectType("StatusBar") and not element.absorbBar:GetStatusBarTexture() then
element.absorbBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
if element.otherBar and element.otherBar:IsObjectType("StatusBar") and not element.otherBar:GetStatusBarTexture() then
element.otherBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
if element.healAbsorbBar and element.healAbsorbBar:IsObjectType("StatusBar") and not element.healAbsorbBar:GetStatusBarTexture() then
element.healAbsorbBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
enabledUF[#enabledUF + 1] = self
@@ -184,9 +230,19 @@ local function Disable(self)
element.otherBar:Hide()
end
if element.absorbBar then
element.absorbBar:Hide()
end
if element.healAbsorbBar then
element.healAbsorbBar:Hide()
end
self:UnregisterEvent("UNIT_HEALTH", Path)
self:UnregisterEvent("UNIT_MAXHEALTH", Path)
self:UnregisterEvent("UNIT_HEAL_PREDICTION", Path)
self:UnregisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", Path)
self:UnregisterEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", Path)
end
end
+172 -59
View File
@@ -140,8 +140,25 @@ function NP:Update_HealComm(nameplate)
nameplate:EnableElement('HealCommBar')
end
nameplate.HealCommBar.myBar:SetStatusBarColor(NP.db.colors.healPrediction.personal.r, NP.db.colors.healPrediction.personal.g, NP.db.colors.healPrediction.personal.b)
nameplate.HealCommBar.otherBar:SetStatusBarColor(NP.db.colors.healPrediction.others.r, NP.db.colors.healPrediction.others.g, NP.db.colors.healPrediction.others.b)
local c = NP.db.colors.healPrediction
nameplate.HealCommBar.myBar:SetStatusBarColor(c.personal.r, c.personal.g, c.personal.b)
nameplate.HealCommBar.otherBar:SetStatusBarColor(c.others.r, c.others.g, c.others.b)
if nameplate.HealCommBar.absorbBar then
nameplate.HealCommBar.absorbBar:SetStatusBarColor(c.absorbs.r, c.absorbs.g, c.absorbs.b, c.absorbs.a)
end
if nameplate.HealCommBar.healAbsorbBar then
nameplate.HealCommBar.healAbsorbBar:SetStatusBarColor(c.healAbsorbs.r, c.healAbsorbs.g, c.healAbsorbs.b, c.healAbsorbs.a)
end
if nameplate.HealCommBar.overAbsorb then
nameplate.HealCommBar.overAbsorb:SetVertexColor(c.overAbsorbs.r, c.overAbsorbs.g, c.overAbsorbs.b, c.overAbsorbs.a)
end
if nameplate.HealCommBar.overHealAbsorb then
nameplate.HealCommBar.overHealAbsorb:SetVertexColor(c.overHealAbsorbs.r, c.overHealAbsorbs.g, c.overHealAbsorbs.b, c.overHealAbsorbs.a)
end
elseif nameplate:IsElementEnabled('HealCommBar') then
nameplate:DisableElement('HealCommBar')
end
@@ -158,6 +175,12 @@ end
function NP:SetAlpha_HealComm(obj, show)
obj.myBar:SetAlpha(show and 1 or 0)
obj.otherBar:SetAlpha(show and 1 or 0)
if obj.absorbBar then
obj.absorbBar:SetAlpha(show and 1 or 0)
end
if obj.healAbsorbBar then
obj.healAbsorbBar:SetAlpha(show and 1 or 0)
end
end
function NP:SetVisibility_HealComm(obj)
@@ -171,9 +194,21 @@ function NP:SetVisibility_HealComm(obj)
if obj.maxOverflow > 1 then
obj.myBar:SetParent(obj.health)
obj.otherBar:SetParent(obj.health)
if obj.absorbBar then
obj.absorbBar:SetParent(obj.health)
end
if obj.healAbsorbBar then
obj.healAbsorbBar:SetParent(obj.health)
end
else
obj.myBar:SetParent(obj.parent)
obj.otherBar:SetParent(obj.parent)
if obj.absorbBar then
obj.absorbBar:SetParent(obj.parent)
end
if obj.healAbsorbBar then
obj.healAbsorbBar:SetParent(obj.parent)
end
end
end
@@ -181,18 +216,27 @@ function NP: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(health:GetFrameLevel()+1)
otherBar:SetFrameLevel(health:GetFrameLevel()+1)
myBar:SetFrameLevel(health:GetFrameLevel()+2)
otherBar:SetFrameLevel(health:GetFrameLevel()+2)
absorbBar:SetFrameLevel(health:GetFrameLevel()+2)
healAbsorbBar:SetFrameLevel(health:GetFrameLevel()+2)
NP.StatusBars[myBar] = true
NP.StatusBars[otherBar] = true
local texture = health:GetStatusBarTexture() or E.media.blankTex
myBar:SetStatusBarTexture(texture)
otherBar:SetStatusBarTexture(texture)
absorbBar:SetStatusBarTexture(texture)
healAbsorbBar:SetStatusBarTexture(texture)
local healPrediction = {
myBar = myBar,
otherBar = otherBar,
absorbBar = absorbBar,
healAbsorbBar = healAbsorbBar,
PostUpdate = NP.UpdateHealComm,
maxOverflow = 1,
health = health,
@@ -214,8 +258,15 @@ function NP:Configure_HealComm(frame)
end
local healPrediction = frame.HealCommBar
local myBar = healPrediction.myBar
local otherBar = healPrediction.otherBar
local absorbBar = healPrediction.absorbBar
local healAbsorbBar = healPrediction.healAbsorbBar
local c = db.colors.healPrediction
healPrediction.maxOverflow = 1 + (c.maxOverflow or 0)
healPrediction.overflowHeals = c.overflowHeals
healPrediction.overflowAbsorbs = c.overflowAbsorbs
if healPrediction.allowClippingUpdate then
NP:SetVisibility_HealComm(healPrediction)
@@ -223,84 +274,146 @@ function NP:Configure_HealComm(frame)
local health = frame.Health
local orientation = health:GetOrientation()
local myBar = healPrediction.myBar
local otherBar = healPrediction.otherBar
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")
else
local height = health:GetHeight()
height = (height > 0 and height) or health.HEIGHT
local healthTexture = health:GetStatusBarTexture()
otherBar:Point("TOP", health)
otherBar:Point("BOTTOM", health)
otherBar:Point(p1, healPrediction.myBarTexture, p2)
otherBar:SetReverseFill(false)
myBar:Size(0, height)
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 -- VERTICAL
local p1 = "BOTTOM"
local p2 = "TOP"
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
frame.HealCommBar.myBar:SetStatusBarColor(NP.db.colors.healPrediction.personal.r, NP.db.colors.healPrediction.personal.g, NP.db.colors.healPrediction.personal.b)
frame.HealCommBar.otherBar:SetStatusBarColor(NP.db.colors.healPrediction.others.r, NP.db.colors.healPrediction.others.g, NP.db.colors.healPrediction.others.b)
local hpc = NP.db.colors.healPrediction
frame.HealCommBar.myBar:SetStatusBarColor(hpc.personal.r, hpc.personal.g, hpc.personal.b)
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)
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 NP:UpdateHealComm(_, myIncomingHeal, allIncomingHeal)
function NP:UpdateHealComm(unit, myIncomingHeal, allIncomingHeal, totalAbsorb, myCurrentHealAbsorb, allHealAbsorb)
if not self.frame or not self.health then return end
local health = self.health
local previousTexture = health:GetStatusBarTexture()
local healthTexture = self.healthBarTexture or health:GetStatusBarTexture()
local orientation = health:GetOrientation()
previousTexture = UpdateFillBar(health, previousTexture, self.myBar, myIncomingHeal)
UpdateFillBar(health, previousTexture, self.otherBar, allIncomingHeal)
end
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
+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
+9 -1
View File
@@ -541,6 +541,10 @@ P.nameplates = {
healPrediction = {
personal = {r = 0, g = 1, b = 0.5, a = 0.25},
others = {r = 0, g = 1, b = 0, a = 0.25},
absorbs = {r = 1, g = 1, b = 1, a = 0.35},
healAbsorbs = {r = 1, g = 0, b = 0, a = 0.35},
overflowHeals = false,
overflowAbsorbs = false,
},
threat = {
goodColor = {r = 0.20, g = 0.71, b = 0.00},
@@ -1107,7 +1111,11 @@ P.unitframe = {
healPrediction = {
personal = {r = 0, g = 1, b = 0.5, a = 0.25},
others = {r = 0, g = 1, b = 0, a = 0.25},
maxOverflow = 0
absorbs = {r = 1, g = 1, b = 1, a = 0.35},
healAbsorbs = {r = 1, g = 0, b = 0, a = 0.35},
maxOverflow = 0,
overflowHeals = false,
overflowAbsorbs = false,
},
classResources = {
comboPoints = {
+6
View File
@@ -1404,3 +1404,9 @@ L["Allows Raid Members to send you Map Markers"] = true
L["MAP_MARKER_DISCRIPTION"] = "Allows Map Markers to be created by middle clicking (Mouse3) on the world map.\nMarkers are automatically shared with raid members."
L["Ranged"] = "Ranged"
L["Melee"] = "Melee"
L["Absorbs"] = true
L["Heal Absorbs"] = true
L["Overflow Heals"] = true
L["Overflow Absorbs"] = true
L["When enabled, incoming heals overflow past the health bar, otherwise bar is reverse filled."] = true
L["When enabled, absorb shields overflow past the health bar, otherwise bar is reverse filled."] = true
+29 -1
View File
@@ -3901,8 +3901,20 @@ E.Options.args.unitframe = {
name = L["Others"],
hasAlpha = true
},
maxOverflow = {
absorbs = {
order = 4,
type = "color",
name = L["Absorbs"],
hasAlpha = true
},
healAbsorbs = {
order = 5,
type = "color",
name = L["Heal Absorbs"],
hasAlpha = true
},
maxOverflow = {
order = 6,
type = "range",
name = L["Max Overflow"],
desc = L["Max amount of overflow allowed to extend past the end of the health bar."],
@@ -3910,6 +3922,22 @@ E.Options.args.unitframe = {
min = 0, max = 1, step = 0.01,
get = function(info) return E.db.unitframe.colors.healPrediction.maxOverflow end,
set = function(info, value) E.db.unitframe.colors.healPrediction.maxOverflow = value UF:Update_AllFrames() end
},
overflowHeals = {
order = 7,
type = "toggle",
name = L["Overflow Heals"],
desc = L["When enabled, incoming heals overflow past the health bar, otherwise bar is reverse filled."],
get = function(info) return E.db.unitframe.colors.healPrediction.overflowHeals end,
set = function(info, value) E.db.unitframe.colors.healPrediction.overflowHeals = value UF:Update_AllFrames() end
},
overflowAbsorbs = {
order = 8,
type = "toggle",
name = L["Overflow Absorbs"],
desc = L["When enabled, absorb shields overflow past the health bar, otherwise bar is reverse filled."],
get = function(info) return E.db.unitframe.colors.healPrediction.overflowAbsorbs end,
set = function(info, value) E.db.unitframe.colors.healPrediction.overflowAbsorbs = value UF:Update_AllFrames() end
}
}
},