From f5a2618a56595553bf803f3ba444ec02b604e9a3 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Wed, 17 Apr 2024 19:12:34 +0200 Subject: [PATCH 1/2] castbar: Add override for unit checks Fixes #676 --- elements/castbar.lua | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/elements/castbar.lua b/elements/castbar.lua index 70171b12..f6c64e5c 100644 --- a/elements/castbar.lua +++ b/elements/castbar.lua @@ -200,10 +200,22 @@ local function UpdatePips(element, numStages) end end -local function CastStart(self, event, unit) - if(self.unit ~= unit) then return end +--[[ Override: Castbar:ShouldShow(unit) +Handles check for which unit the castbar should show for. +Defaults to the object unit. +* self - the Castbar widget +* unit - the unit for which the update has been triggered (string) +--]] +local function ShouldShow(element, unit) + return element.__owner.unit == unit +end + +local function CastStart(self, event, unit) local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local numStages, _ local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit) @@ -300,7 +312,10 @@ local function CastStart(self, event, unit) end local function CastUpdate(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end + local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -357,7 +372,10 @@ local function CastUpdate(self, event, unit, castID, spellID) end local function CastStop(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end + local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -379,7 +397,10 @@ local function CastStop(self, event, unit, castID, spellID) end local function CastFail(self, event, unit, castID, spellID) - if(self.unit ~= unit) then return end + local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then @@ -410,7 +431,10 @@ local function CastFail(self, event, unit, castID, spellID) end local function CastInterruptible(self, event, unit) - if(self.unit ~= unit) then return end + local element = self.Castbar + if(not (element.ShouldShow or ShouldShow) (element, unit)) then + return + end local element = self.Castbar if(not element:IsShown()) then return end From f0bac0c76737733401ac2f96739d9bb57b459b80 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Wed, 17 Apr 2024 19:19:14 +0200 Subject: [PATCH 2/2] Fix duplicate references --- elements/castbar.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/elements/castbar.lua b/elements/castbar.lua index f6c64e5c..9e8f1511 100644 --- a/elements/castbar.lua +++ b/elements/castbar.lua @@ -317,7 +317,6 @@ local function CastUpdate(self, event, unit, castID, spellID) return end - local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -377,7 +376,6 @@ local function CastStop(self, event, unit, castID, spellID) return end - local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -402,7 +400,6 @@ local function CastFail(self, event, unit, castID, spellID) return end - local element = self.Castbar if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then return end @@ -436,7 +433,6 @@ local function CastInterruptible(self, event, unit) return end - local element = self.Castbar if(not element:IsShown()) then return end element.notInterruptible = event == 'UNIT_SPELLCAST_NOT_INTERRUPTIBLE'