From 026d4093aaf90820de382c3655116443e283acd6 Mon Sep 17 00:00:00 2001
From: Bluewhale1337 <295648290+Bluewhale1337@users.noreply.github.com>
Date: Tue, 21 Jul 2026 11:21:35 +0200
Subject: [PATCH] refactor: optimize event processing, move global UI buttons,
and reorganize options layout
---
HealBot_Controller_Events.lua | 43 ++++++--------
HealBot_Controller_Spells.lua | 4 +-
HealBot_Options.lua | 2 +-
HealBot_Options.xml | 35 +----------
HealBot_Options_General.xml | 34 ++++++++++-
HealBot_Options_Skins.xml | 106 +++++++++++++++++-----------------
HealBot_View_Layout.lua | 53 ++++++++++++++---
README.md | 2 +
8 files changed, 155 insertions(+), 124 deletions(-)
diff --git a/HealBot_Controller_Events.lua b/HealBot_Controller_Events.lua
index 228fb0e..c10d4b2 100644
--- a/HealBot_Controller_Events.lua
+++ b/HealBot_Controller_Events.lua
@@ -30,9 +30,7 @@ function HealBot_OnLoad(this)
end)
HealBot_Model:RegisterObserver("EQUIPMENT_CHANGED", function(unitID)
if unitID == "player" then
- HealBot_BonusScanner:ScanEquipment()
- HealBot_CalcEquipBonus = true;
- HealBot_RecalcSpells();
+ HealBot_EquipChangeTimer = 1
end
end)
end
@@ -76,10 +74,20 @@ function HealBot_OnUpdate(this, arg1)
end
-- Process Dirty Queue for MVC View
- if next(HealBot_View_DirtyUnits) ~= nil then
- for unitID in pairs(HealBot_View_DirtyUnits) do
- HealBot_Action_RefreshButtons(unitID)
- HealBot_View_DirtyUnits[unitID] = nil
+ local unitID, _ = next(HealBot_View_DirtyUnits)
+ while unitID do
+ HealBot_Action_RefreshButtons(unitID)
+ HealBot_View_DirtyUnits[unitID] = nil
+ unitID, _ = next(HealBot_View_DirtyUnits)
+ end
+
+ if HealBot_EquipChangeTimer > 0 then
+ HealBot_EquipChangeTimer = HealBot_EquipChangeTimer - arg1
+ if HealBot_EquipChangeTimer <= 0 then
+ HealBot_EquipChangeTimer = 0
+ HealBot_BonusScanner:ScanEquipment()
+ HealBot_CalcEquipBonus = true;
+ HealBot_RecalcSpells();
end
end
@@ -93,15 +101,7 @@ function HealBot_OnUpdate(this, arg1)
HealsIn_Timer = 0;
end
- if HealBot_EquipChangeTimer > 0 then
- HealBot_EquipChangeTimer = HealBot_EquipChangeTimer - arg1
- if HealBot_EquipChangeTimer <= 0 then
- HealBot_EquipChangeTimer = 0
- HealBot_BonusScanner:ScanEquipment()
- HealBot_CalcEquipBonus = true;
- HealBot_RecalcSpells();
- end
- end
+
if HealBot_SpellsInitFlag > 1 then
HealBot_SpellsInitFlag = HealBot_SpellsInitFlag + 1;
@@ -138,32 +138,24 @@ local HealBot_EventHandlers = {
if HealBot_Model:UpdateUnitPower(arg1) then
HealBot_Model:NotifyObservers("UNIT_POWER_CHANGED", arg1)
end
- if (arg1 == "player") then HealBot_RecalcHeals(); end
- HealBot_Action_RefreshButtons(arg1);
end,
["UNIT_RAGE"] = function(this, arg1)
if arg1 ~= "player" and HealBot_Config.ShowManaBars == 0 then return end
if HealBot_Model:UpdateUnitPower(arg1) then
HealBot_Model:NotifyObservers("UNIT_POWER_CHANGED", arg1)
end
- if (arg1 == "player") then HealBot_RecalcHeals(); end
- HealBot_Action_RefreshButtons(arg1);
end,
["UNIT_ENERGY"] = function(this, arg1)
if arg1 ~= "player" and HealBot_Config.ShowManaBars == 0 then return end
if HealBot_Model:UpdateUnitPower(arg1) then
HealBot_Model:NotifyObservers("UNIT_POWER_CHANGED", arg1)
end
- if (arg1 == "player") then HealBot_RecalcHeals(); end
- HealBot_Action_RefreshButtons(arg1);
end,
["UNIT_DISPLAYPOWER"] = function(this, arg1)
if arg1 ~= "player" and HealBot_Config.ShowManaBars == 0 then return end
if HealBot_Model:UpdateUnitPower(arg1) then
HealBot_Model:NotifyObservers("UNIT_POWER_CHANGED", arg1)
end
- if (arg1 == "player") then HealBot_RecalcHeals(); end
- HealBot_Action_RefreshButtons(arg1);
end,
["UNIT_AURA"] = function(this, arg1)
HealBot_Model:MarkAuraChanged(arg1)
@@ -321,7 +313,6 @@ end
function HealBot_OnEvent_UnitHealth(this, unit)
if (not HealBot_Heals[unit]) then return end
HealBot_CheckCasting(unit);
- HealBot_RecalcHeals(unit);
if unit == HealBot_Action_TooltipUnit then
HealBot_Action_RefreshTooltip(HealBot_Action_TooltipUnit);
end
@@ -379,7 +370,7 @@ end
function HealBot_OnEvent_PlayerTargetChanged(this)
if HealBot_Action_UnitButtons and HealBot_Action_UnitButtons["target"] then
- HealBot_Action_RefreshButtons("target");
+ HealBot_View_DirtyUnits["target"] = true
HealBot_OnEvent_UnitAura(nil, "target");
end
end
diff --git a/HealBot_Controller_Spells.lua b/HealBot_Controller_Spells.lua
index 38784c1..5c6bde5 100644
--- a/HealBot_Controller_Spells.lua
+++ b/HealBot_Controller_Spells.lua
@@ -593,9 +593,7 @@ function HealBot_InitSpells()
end
id = id + 1;
end
- if class == "PRIEST" or class == "DRUID" or class == "PALADIN" or class == "SHAMAN" then
- HealBot_AddChat("Initiated HealBot_CurrentSpells with " .. cnt .. " Spells");
- end
+
return cnt;
end
diff --git a/HealBot_Options.lua b/HealBot_Options.lua
index 61ef947..9a974cc 100644
--- a/HealBot_Options.lua
+++ b/HealBot_Options.lua
@@ -234,7 +234,7 @@ function HealBot_Options_OnLoad(this)
table.insert(UISpecialFrames,this:GetName());
-- Tabs
- PanelTemplates_SetNumTabs(this,7);
+ PanelTemplates_SetNumTabs(this,8);
this.selectedTab = 1;
PanelTemplates_UpdateTabs(this);
HealBot_Options_ShowPanel(this.selectedTab);
diff --git a/HealBot_Options.xml b/HealBot_Options.xml
index c2c12a2..6380dd1 100644
--- a/HealBot_Options.xml
+++ b/HealBot_Options.xml
@@ -94,7 +94,7 @@
-
+
@@ -215,38 +215,7 @@
-
-
+
HealBot_Options_OnLoad(this);
diff --git a/HealBot_Options_General.xml b/HealBot_Options_General.xml
index 0193047..0742fed 100644
--- a/HealBot_Options_General.xml
+++ b/HealBot_Options_General.xml
@@ -265,8 +265,38 @@
-
-
+
+
diff --git a/HealBot_Options_Skins.xml b/HealBot_Options_Skins.xml
index f8cb68a..fb8abf9 100644
--- a/HealBot_Options_Skins.xml
+++ b/HealBot_Options_Skins.xml
@@ -266,9 +266,9 @@
-
+
-
+
@@ -277,62 +277,14 @@
HealBot_Options_FramePaddingS_OnValueChanged(this)
-
-
-
-
-
-
-
-
-
-
-
-
- HealBot_Options_val_OnLoad(this,"Solid Border",1,10)
- HealBot_Options_BorderThicknessS_OnValueChanged(this)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- HealBot_Options_val_OnLoad(this,"Max Rows",0,40)
- HealBot_Options_BarMaxRowsS_OnValueChanged(this)
-
-
-
-
-
-
-
-
-
-
-
-
- getglobal(this:GetName().."Text"):SetText("Horizontal Grid");
-
-
- HealBot_Options_GridOrientation_OnClick(this);
-
-
-
+
-
+
@@ -409,6 +361,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ HealBot_Options_val_OnLoad(this,"Solid Border",1,10)
+ HealBot_Options_BorderThicknessS_OnValueChanged(this)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ HealBot_Options_val_OnLoad(this,"Max Rows",0,40)
+ HealBot_Options_BarMaxRowsS_OnValueChanged(this)
+
+
+
+
+
+
+
+
+
+
+
+
+ getglobal(this:GetName().."Text"):SetText("Horizontal Grid");
+
+
+ HealBot_Options_GridOrientation_OnClick(this);
+
+
+
+