Commit c93c0cef authored by Simpy's avatar Simpy 🐹

heal prediction stuffs: not exactly sure how he wants this to work but maybe...

heal prediction stuffs: not exactly sure how he wants this to work but maybe this will help a little :)
parent cef18e6d
local MER, E, L, V, P, G = unpack(select(2, ...))
local module = MER:GetModule("muiUnits")
local UF = E.UnitFrames
local ElvUF = ElvUF
--Cache global variables
--Lua functions
local _G = _G
local pairs = pairs
--WoW API / Variables
local UnitGetTotalAbsorbs = UnitGetTotalAbsorbs
local UnitHealthMax = UnitHealthMax
local UnitIsConnected = UnitIsConnected
local hooksecurefunc = hooksecurefunc
-- GLOBALS:
function module:Construct_HealComm(frame)
local healPrediction = frame.HealthPrediction
--healPrediction.absorbBar.overlay = healPrediction.absorbBar:CreateTexture(nil, "ARTWORK", nil, 1)
--healPrediction.absorbBar.overlay:SetAllPoints(healPrediction.absorbBar:GetStatusBarTexture())
--healPrediction.absorbBar.overlay:SetTexture("Interface\\RaidFrame\\Shield-Overlay", true, true)
--healPrediction.absorbBar.overlay.tileSize = 32
if not healPrediction.overAbsorb then
local overAbsorb = frame.Health:CreateTexture(nil, "OVERLAY")
overAbsorb:SetPoint('TOP')
overAbsorb:SetPoint('BOTTOM')
overAbsorb:SetPoint('LEFT', frame.Health, 'RIGHT')
overAbsorb:SetWidth(10)
healPrediction.overAbsorb = overAbsorb
end
end
function module:Configure_HealComm(frame)
if frame.db and frame.db.healPrediction and frame.db.healPrediction.enable then
......@@ -23,13 +35,6 @@ function module:Configure_HealComm(frame)
local reverseFill = health:GetReverseFill()
local overAbsorbTexture = "Interface\\RaidFrame\\Shield-Overshield"
if healPrediction.absorbBar and not healPrediction.absorbBar.overlay then
healPrediction.absorbBar.overlay = healPrediction.absorbBar:CreateTexture(nil, "ARTWORK", nil, 1)
healPrediction.absorbBar.overlay:SetAllPoints(healPrediction.absorbBar:GetStatusBarTexture())
healPrediction.absorbBar.overlay:SetTexture("Interface\\RaidFrame\\Shield-Overlay", true, true)
healPrediction.absorbBar.overlay.tileSize = 32
end
if orientation == "HORIZONTAL" then
if healPrediction.overAbsorb then
healPrediction.overAbsorb:SetTexture(overAbsorbTexture)
......@@ -62,39 +67,49 @@ function module:Configure_HealComm(frame)
end
end
end
end
end
if healPrediction.overAbsorb then
healPrediction.overAbsorb:SetVertexColor(1, 1, 1, 1)
healPrediction.overAbsorb:SetParent(frame.RaisedElementParent)
end
do
--local tileSize = 32
function module:UpdateHealComm(unit, myIncomingHeal, otherIncomingHeal, absorb, healAbsorb, hasOverAbsorb, hasOverHealAbsorb, health, maxHealth)
if --[[not self.absorbBar.overlay or]] not UnitIsConnected(unit) then return end
if healPrediction.absorbBar then
healPrediction.absorbBar:SetStatusBarColor(0.66, 1, 1, .6)
--local totalWidth, totalHeight = self.frame.Health:GetSize()
--local barSize = (absorb / maxHealth) * totalWidth
--self.absorbBar.overlay:SetTexCoord(0, barSize / tileSize, 0, totalHeight / tileSize)
if hasOverAbsorb and health == maxHealth then
local db = self.frame.db and self.frame.db.healPrediction
if db and db.absorbStyle == 'NORMAL' then
self.absorbBar:SetValue(0)
end
end
end
end
function module:UpdateHealComm(unit, myIncomingHeal, otherIncomingHeal, absorb, healAbsorb, hasOverAbsorb, hasOverHealAbsorb)
if not self.absorbBar.overlay or not UnitIsConnected(unit) then return end
if self.absorbBar then
self.absorbBar:SetStatusBarColor(0.66, 1, 1, .6)
end
local pred = self.frame and self.frame.db and self.frame.db.healPrediction
local totalWidth, totalHeight = self.frame.Health:GetSize()
local totalMax = UnitHealthMax(unit)
absorb = pred and UnitGetTotalAbsorbs(unit) or absorb
local barSize = (absorb / totalMax) * totalWidth
local tileSize = 32
self.absorbBar.overlay:SetTexCoord(0, barSize / tileSize, 0, totalHeight / tileSize)
if self.overAbsorb then
self.overAbsorb:SetVertexColor(1, 1, 1, 1)
end
end
end
function module:HealPrediction()
if E.private.unitframe.enable ~= true or E.db.mui.unitframes.healPrediction ~= true then return end
hooksecurefunc(UF, "Construct_HealComm", module.Construct_HealComm)
hooksecurefunc(UF, "Configure_HealComm", module.Configure_HealComm)
for _, object in pairs(_G.ElvUF.objects) do
if object.HealthPrediction and object.HealthPrediction.PostUpdate then
hooksecurefunc(object.HealthPrediction, "PostUpdate", module.UpdateHealComm)
for _, object in pairs(ElvUF.objects) do
if object.HealthPrediction then
module:Construct_HealComm(object)
module:Configure_HealComm(object)
if object.HealthPrediction.PostUpdate then
hooksecurefunc(object.HealthPrediction, "PostUpdate", module.UpdateHealComm)
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment