From d36ad994eabeae1cba4355532efad1bff2bf77a8 Mon Sep 17 00:00:00 2001 From: Bluewhale1337 <295648290+Bluewhale1337@users.noreply.github.com> Date: Wed, 22 Jul 2026 09:20:22 +0200 Subject: [PATCH] feat: add support for dynamic unit appending during combat and improve layout handling --- HealBot_Controller_Events.lua | 2 +- HealBot_View_Layout.lua | 149 +++++++++++++++++++++++++++++++++- README.md | 3 +- 3 files changed, 150 insertions(+), 4 deletions(-) diff --git a/HealBot_Controller_Events.lua b/HealBot_Controller_Events.lua index aaa6887..ab094dd 100644 --- a/HealBot_Controller_Events.lua +++ b/HealBot_Controller_Events.lua @@ -376,7 +376,7 @@ end function HealBot_OnEvent_PlayerRegenEnabled(this) HealBot_IsFighting = false; - -- Removed HealBot_Delay_RecalcParty = 1; + HealBot_Delay_RecalcParty = 1; end function HealBot_OnEvent_PlayerTargetChanged(this) diff --git a/HealBot_View_Layout.lua b/HealBot_View_Layout.lua index e6579c1..c058d63 100644 --- a/HealBot_View_Layout.lua +++ b/HealBot_View_Layout.lua @@ -109,6 +109,11 @@ function HealBot_Action_EnableButton(button) local maxhlth = state.maxHealth local name = state.name if not name then name = UnitName(unit) end -- fallback + + if not name or name == "Unknown" then + button:Hide() + return + end local bar = HealBot_Action_HealthBar(button); local bar2 = HealBot_Action_HealthBar2(button); @@ -415,8 +420,12 @@ function HealBot_Action_SetHealButton(index, unit) end function HealBot_Action_PartyChanged() - if not HealBot_IsFighting then - local numBars = 0; + if HealBot_IsFighting then + HealBot_Action_AppendNewUnits() + return + end + + local numBars = 0; local numHeaders = 0; local TempMaxH = 0; local HeaderPos = {}; @@ -899,6 +908,16 @@ function HealBot_Action_PartyChanged() end end + HealBot_Grid_LastI = i; + HealBot_Grid_LastH = h; + HealBot_Grid_LastZ = z; + HealBot_Grid_OffsetX = OffsetX; + HealBot_Grid_OffsetY = OffsetY; + HealBot_Grid_MaxOffsetX = MaxOffsetX; + HealBot_Grid_MaxOffsetY = MaxOffsetY; + HealBot_Grid_Limit = limit; + HealBot_Grid_NumBars = numBars; + if HealBot_Config.HideOptions == 1 then HealBot_Action_OptionsButton:Hide(); else @@ -993,3 +1012,129 @@ function HealBot_Action_Refresh(unit) end end end +function HealBot_Action_AppendUnit(unit) + if not HealBot_Grid_LastI then return end + if HealBot_Grid_LastI >= 100 then return end + + HealBot_Grid_LastI = HealBot_Grid_LastI + 1 + HealBot_Grid_NumBars = HealBot_Grid_NumBars + 1 + + local button = HealBot_Action_SetHealButton(HealBot_Grid_LastI, unit) + if not button then return end + + local orientation = (HealBot_Config.GridOrientation and HealBot_Config.GridOrientation[HealBot_Config.Current_Skin]) or 1 + local bwidth = (HealBot_Config.bwidth and HealBot_Config.bwidth[HealBot_Config.Current_Skin]) or 85 + local bheight = (HealBot_Config.bheight and HealBot_Config.bheight[HealBot_Config.Current_Skin]) or 18 + local bcspace = (HealBot_Config.bcspace and HealBot_Config.bcspace[HealBot_Config.Current_Skin]) or 3 + local brspace = (HealBot_Config.brspace and HealBot_Config.brspace[HealBot_Config.Current_Skin]) or 3 + local bpadding = (HealBot_Config.bpadding and HealBot_Config.bpadding[HealBot_Config.Current_Skin]) or 10 + + if orientation == 1 then + HealBot_Grid_OffsetY = HealBot_Action_PositionButton(button, HealBot_Grid_OffsetX, HealBot_Grid_OffsetY, bwidth, bheight, false, nil) + if HealBot_Grid_LastH == HealBot_Grid_Limit then + HealBot_Grid_LastH = 0 + if HealBot_Grid_MaxOffsetY < HealBot_Grid_OffsetY then HealBot_Grid_MaxOffsetY = HealBot_Grid_OffsetY end + HealBot_Grid_OffsetY = bpadding + HealBot_Grid_OffsetX = HealBot_Grid_OffsetX + bwidth + bcspace + end + else + HealBot_Grid_OffsetX = HealBot_Action_PositionButtonHorizontal(button, HealBot_Grid_OffsetX, HealBot_Grid_OffsetY, bwidth, bheight, false, nil) + if HealBot_Grid_LastH == HealBot_Grid_Limit then + HealBot_Grid_LastH = 0 + if HealBot_Grid_MaxOffsetX < HealBot_Grid_OffsetX then HealBot_Grid_MaxOffsetX = HealBot_Grid_OffsetX end + HealBot_Grid_OffsetX = bpadding + HealBot_Grid_OffsetY = HealBot_Grid_OffsetY + bheight + brspace + end + end + + HealBot_Grid_LastH = HealBot_Grid_LastH + 1 + HealBot_Grid_LastZ = HealBot_Grid_LastZ + 1 + + local bar = HealBot_Action_HealthBar(button) + local bar2 = HealBot_Action_HealthBar2(button) + bar.txt = getglobal(bar:GetName() .. "_text") + bar:SetHeight(bheight) + local btexture = (HealBot_Config.btexture and HealBot_Config.btexture[HealBot_Config.Current_Skin]) or 5 + HealBot_Action_SetTexture(bar, btexture) + local btextheight = (HealBot_Config.btextheight and HealBot_Config.btextheight[HealBot_Config.Current_Skin]) or 10 + bar.txt:SetTextHeight(btextheight) + bar2:SetHeight(bheight) + HealBot_Action_SetTexture(bar2, btexture) + + local totalOffsetX = HealBot_Grid_OffsetX + local totalOffsetY = HealBot_Grid_OffsetY + if orientation == 1 then + if HealBot_Grid_MaxOffsetY < totalOffsetY then HealBot_Grid_MaxOffsetY = totalOffsetY end + totalOffsetY = HealBot_Grid_MaxOffsetY + else + if HealBot_Grid_MaxOffsetX < totalOffsetX then HealBot_Grid_MaxOffsetX = totalOffsetX end + totalOffsetX = HealBot_Grid_MaxOffsetX + totalOffsetY = totalOffsetY + bheight + brspace + end + + HealBot_Action_SetHeightWidth(totalOffsetX, totalOffsetY + bpadding, bwidth) +end +function HealBot_Action_AppendNewUnits() + if not HealBot_Grid_LastI then return end + + local unitsToCheck = {} + + -- Gather units based on config, similar to PartyChanged + if HealBot_Config.GroupHeals == 1 then + for _, unit in ipairs(HealBot_Action_HealGroup) do + table.insert(unitsToCheck, unit) + end + end + + if HealBot_Config.TankHeals == 1 and GetNumRaidMembers() > 0 and CT_RA_MainTanks then + for j = 1, 10 do + if CT_RA_MainTanks[j] then + for k = 1, GetNumRaidMembers() do + local unit = "raid" .. k + if UnitName(unit) == CT_RA_MainTanks[j] then + table.insert(unitsToCheck, unit) + end + end + end + end + end + + if HealBot_Config.TargetHeals == 1 then + for _, unit in ipairs(HealBot_Action_HealTarget) do + table.insert(unitsToCheck, unit) + end + table.insert(unitsToCheck, "target") + end + + if HealBot_Config.EmergencyHeals == 1 then + if GetNumRaidMembers() > 0 then + for j = 1, 40 do + table.insert(unitsToCheck, "raid" .. j) + end + else + for j = 1, 4 do + table.insert(unitsToCheck, "party" .. j) + end + table.insert(unitsToCheck, "player") + end + end + + if HealBot_Config.PetHeals == 1 then + if GetNumRaidMembers() > 0 then + for j = 1, 40 do + table.insert(unitsToCheck, "raidpet" .. j) + end + else + for j = 1, 4 do + table.insert(unitsToCheck, "partypet" .. j) + end + table.insert(unitsToCheck, "pet") + end + end + + for _, unit in ipairs(unitsToCheck) do + if not HealBot_Action_UnitButtons[unit] and HealBot_MayHeal(unit) then + HealBot_Action_AppendUnit(unit) + end + end +end diff --git a/README.md b/README.md index 89d1812..eb5874e 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,8 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\ ### Change Log **v1.6.1** -* **Hotfix** - With class colours toggled extra frames for player pets were given some classy mint colour. +* **Hotfix - pet frames** - With class colours toggled extra frames for player pets were given some classy mint colour. +* **Hotfi - raidframes in combat** - Modfied how frames behave when player leaves during combat. **v1.6** * **Event Loop Decoupling:** Ripped out redundant synchronous UI redraws that were bypassed by the new MVC architecture. High-frequency events (mana regen, health ticks) now fully rely on the `HealBot_OnUpdate` dirty queue, severely reducing CPU bottlenecks.