mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-28 10:26:02 +00:00
prediction: display predictive healing
This commit is contained in:
@@ -423,221 +423,6 @@ pfUI:RegisterModule("thirdparty", function ()
|
||||
end)
|
||||
end)
|
||||
|
||||
AddIntegration("HealComm", function()
|
||||
if C.thirdparty.healcomm.enable == "0" then return end
|
||||
|
||||
if AceLibrary and AceLibrary:HasInstance("HealComm-1.0") then
|
||||
pfUI.healComm = {}
|
||||
|
||||
local HealComm = AceLibrary("HealComm-1.0")
|
||||
local AceEvent = AceLibrary("AceEvent-2.0")
|
||||
|
||||
function pfUI.healComm.createIncHeal(unit)
|
||||
if pfUI.uf.player and unit == "player" then
|
||||
if not pfUI.uf.player.hp then return end
|
||||
|
||||
if pfUI.uf.player and not pfUI.uf.player.incHeal then
|
||||
pfUI.uf.player.incHeal = CreateFrame("StatusBar", "PlayerFrameIncHealBar", pfUI.uf.player)
|
||||
pfUI.uf.player.incHeal:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
|
||||
pfUI.uf.player.incHeal:SetFrameStrata("MEDIUM")
|
||||
pfUI.uf.player.incHeal:SetMinMaxValues(0, 1)
|
||||
pfUI.uf.player.incHeal:SetValue(1)
|
||||
pfUI.uf.player.incHeal:SetStatusBarColor(0, 1, 0, 0.5)
|
||||
pfUI.uf.player.incHeal:Hide()
|
||||
end
|
||||
return pfUI.uf.player
|
||||
end
|
||||
|
||||
if pfUI.uf.target and unit == "target" then
|
||||
if not pfUI.uf.target.hp then return end
|
||||
|
||||
if not pfUI.uf.target.incHeal then
|
||||
pfUI.uf.target.incHeal = CreateFrame("StatusBar", "PlayerFrameIncHealBar", pfUI.uf.target)
|
||||
pfUI.uf.target.incHeal:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
|
||||
pfUI.uf.target.incHeal:SetFrameStrata("MEDIUM")
|
||||
pfUI.uf.target.incHeal:SetMinMaxValues(0, 1)
|
||||
pfUI.uf.target.incHeal:SetValue(1)
|
||||
pfUI.uf.target.incHeal:SetStatusBarColor(0, 1, 0, 0.5)
|
||||
pfUI.uf.target.incHeal:Hide()
|
||||
end
|
||||
return pfUI.uf.target
|
||||
end
|
||||
|
||||
if pfUI.uf.group and strsub(unit,0,5) == "party" then
|
||||
local id = tonumber(strsub(unit,6))
|
||||
if pfUI.uf.group[id] then
|
||||
if not pfUI.uf.group[id].hp then return end
|
||||
|
||||
if not pfUI.uf.group[id].incHeal then
|
||||
pfUI.uf.group[id].incHeal = CreateFrame("StatusBar", "PlayerFrameIncHealBar", pfUI.uf.group[id])
|
||||
pfUI.uf.group[id].incHeal:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
|
||||
pfUI.uf.group[id].incHeal:SetFrameStrata("MEDIUM")
|
||||
pfUI.uf.group[id].incHeal:SetMinMaxValues(0, 1)
|
||||
pfUI.uf.group[id].incHeal:SetValue(1)
|
||||
pfUI.uf.group[id].incHeal:SetStatusBarColor(0, 1, 0, 0.5)
|
||||
pfUI.uf.group[id].incHeal:Hide()
|
||||
end
|
||||
return pfUI.uf.group[id]
|
||||
end
|
||||
end
|
||||
|
||||
if pfUI.uf.raid and strsub(unit,0,4) == "raid" then
|
||||
local rid = tonumber(strsub(unit,5))
|
||||
local id = nil
|
||||
|
||||
for i=1,40 do
|
||||
if not pfUI.uf.raid then break end
|
||||
if pfUI.uf.raid[i] and pfUI.uf.raid[i].id == rid then id = i end
|
||||
end
|
||||
|
||||
if id == nil then return end
|
||||
if pfUI.uf.raid[id] then
|
||||
if not pfUI.uf.raid[id].hp then return end
|
||||
|
||||
if not pfUI.uf.raid[id].incHeal then
|
||||
pfUI.uf.raid[id].incHeal = CreateFrame("StatusBar", "PlayerFrameIncHealBar", pfUI.uf.raid[id])
|
||||
pfUI.uf.raid[id].incHeal:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
|
||||
pfUI.uf.raid[id].incHeal:SetFrameStrata("MEDIUM")
|
||||
pfUI.uf.raid[id].incHeal:SetMinMaxValues(0, 1)
|
||||
pfUI.uf.raid[id].incHeal:SetValue(1)
|
||||
pfUI.uf.raid[id].incHeal:SetStatusBarColor(0, 1, 0, 0.5)
|
||||
pfUI.uf.raid[id].incHeal:Hide()
|
||||
end
|
||||
return pfUI.uf.raid[id]
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
function pfUI.healComm.onEvent(unitname)
|
||||
if UnitName("target") == unitname then
|
||||
pfUI.healComm.onHeal("target")
|
||||
end
|
||||
|
||||
if UnitName("player") == unitname then
|
||||
pfUI.healComm.onHeal("player")
|
||||
end
|
||||
|
||||
if UnitInRaid("player") then
|
||||
for i=1,40 do
|
||||
if UnitName("raid" .. i) == unitname then
|
||||
pfUI.healComm.onHeal("raid" .. i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i=1,4 do
|
||||
if UnitName("party" .. i) == unitname then
|
||||
pfUI.healComm.onHeal("party" .. i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pfUI.healComm.onEventHealthChange(unit)
|
||||
pfUI.healComm.onHeal(unit)
|
||||
end
|
||||
|
||||
function pfUI.healComm.TargetChanged()
|
||||
pfUI.healComm.onHeal("target")
|
||||
end
|
||||
|
||||
function pfUI.healComm.onHeal(unit)
|
||||
OVERHEALPERCENT = OVERHEALPERCENT or 20
|
||||
|
||||
local frame = pfUI.healComm.createIncHeal(unit)
|
||||
if not frame then return end
|
||||
|
||||
local healed = HealComm:getHeal(UnitName(unit))
|
||||
|
||||
local health, maxHealth = UnitHealth(unit), UnitHealthMax(unit)
|
||||
|
||||
if( healed > 0 and (health < maxHealth or OVERHEALPERCENT > 0 )) and frame:IsVisible() then
|
||||
frame.incHeal:Show()
|
||||
frame.incHeal:SetFrameStrata("BACKGROUND")
|
||||
frame.incHeal:ClearAllPoints()
|
||||
|
||||
local width = frame.hp.bar:GetWidth() / frame.hp.bar:GetEffectiveScale()
|
||||
local height = frame.hp.bar:GetHeight() / frame.hp.bar:GetEffectiveScale()
|
||||
|
||||
if frame.config.verticalbar == "0" then
|
||||
local healthWidth = width * (health / maxHealth)
|
||||
local incWidth = width * healed / maxHealth
|
||||
if healthWidth + incWidth > width * (1+(OVERHEALPERCENT/100)) then
|
||||
incWidth = width * (1+OVERHEALPERCENT/100) - healthWidth
|
||||
end
|
||||
|
||||
frame.incHeal:SetPoint("TOPLEFT", frame.hp.bar, "TOPLEFT", 0, 0)
|
||||
frame.incHeal:SetHeight(height)
|
||||
frame.incHeal:SetWidth(incWidth + healthWidth)
|
||||
|
||||
if frame.config.invert_healthbar == "1" then
|
||||
frame.incHeal:SetWidth(incWidth)
|
||||
frame.incHeal:SetFrameStrata("HIGH")
|
||||
end
|
||||
else
|
||||
local healthHeight = height * (health / maxHealth)
|
||||
local incHeight = height * healed / maxHealth
|
||||
if healthHeight + incHeight > height * (1+(OVERHEALPERCENT/100)) then
|
||||
incHeight = height * (1+OVERHEALPERCENT/100) - healthHeight
|
||||
end
|
||||
|
||||
frame.incHeal:SetPoint("BOTTOM", frame.hp.bar, "BOTTOM", 0, 0)
|
||||
frame.incHeal:SetWidth(width)
|
||||
frame.incHeal:SetHeight(incHeight + healthHeight)
|
||||
|
||||
if frame.config.invert_healthbar == "1" then
|
||||
frame.incHeal:SetHeight(incHeight)
|
||||
frame.incHeal:SetFrameStrata("HIGH")
|
||||
end
|
||||
end
|
||||
else
|
||||
frame.incHeal:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function pfUI.healComm.onEventRes(unitname)
|
||||
for _, f in pairs(pfUI.uf.frames) do
|
||||
if f.label and f.id and UnitName(f.label .. f.id) == unitname then
|
||||
|
||||
if not f.ressIcon then
|
||||
f.ressIcon = CreateFrame("Frame", nil, f.hp.bar)
|
||||
f.ressIcon:SetFrameLevel(1)
|
||||
f.ressIcon.base = f
|
||||
f.ressIcon:RegisterEvent("PLAYER_TARGET_CHANGED")
|
||||
f.ressIcon:SetScript("OnEvent", function()
|
||||
if HealComm:UnitisResurrecting(UnitName(this.base.label .. this.base.id)) then
|
||||
this:Show()
|
||||
else
|
||||
this:Hide()
|
||||
end
|
||||
end)
|
||||
|
||||
f.ressIcon:SetWidth(32)
|
||||
f.ressIcon:SetHeight(32)
|
||||
f.ressIcon:SetPoint("CENTER", f, "CENTER", 0, 4)
|
||||
f.ressIcon.texture = f.ressIcon:CreateTexture(nil,"BACKGROUND")
|
||||
f.ressIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\ress")
|
||||
f.ressIcon.texture:SetAllPoints(f.ressIcon)
|
||||
end
|
||||
|
||||
if HealComm:UnitisResurrecting(unitname) then
|
||||
f.ressIcon:Show()
|
||||
else
|
||||
f.ressIcon:Hide()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AceEvent:RegisterEvent("HealComm_Healupdate", pfUI.healComm.onEvent)
|
||||
AceEvent:RegisterEvent("HealComm_Ressupdate", pfUI.healComm.onEventRes)
|
||||
AceEvent:RegisterEvent("UNIT_HEALTH", pfUI.healComm.onEventHealthChange)
|
||||
AceEvent:RegisterEvent("PLAYER_TARGET_CHANGED", pfUI.healComm.TargetChanged)
|
||||
end
|
||||
end)
|
||||
|
||||
AddIntegration("SortBags", function()
|
||||
if C.thirdparty.sortbags.enable == "0" then return end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user