Skip to content

Commit

Permalink
castbar: Add override for unit checks
Browse files Browse the repository at this point in the history
Fixes #676
  • Loading branch information
p3lim committed Apr 17, 2024
1 parent 652c332 commit f5a2618
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions elements/castbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Check warning on line 320 in elements/castbar.lua

View workflow job for this annotation

GitHub Actions / lint

variable 'element' was previously defined on line 315
if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
Expand Down Expand Up @@ -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

Check warning on line 380 in elements/castbar.lua

View workflow job for this annotation

GitHub Actions / lint

variable 'element' was previously defined on line 375
if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
Expand All @@ -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

Check warning on line 405 in elements/castbar.lua

View workflow job for this annotation

GitHub Actions / lint

variable 'element' was previously defined on line 400
if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
Expand Down Expand Up @@ -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

Check warning on line 439 in elements/castbar.lua

View workflow job for this annotation

GitHub Actions / lint

variable 'element' was previously defined on line 434
if(not element:IsShown()) then return end
Expand Down

0 comments on commit f5a2618

Please sign in to comment.