Skip to content

Commit

Permalink
castbar: Add override for unit checks (#677)
Browse files Browse the repository at this point in the history
Fixes #676
  • Loading branch information
p3lim authored Apr 17, 2024
1 parent 652c332 commit 07f7153
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 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,9 +312,11 @@ 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

if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
return
end
Expand Down Expand Up @@ -357,9 +371,11 @@ 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

if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
return
end
Expand All @@ -379,9 +395,11 @@ 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

if(not element:IsShown() or element.castID ~= castID or element.spellID ~= spellID) then
return
end
Expand Down Expand Up @@ -410,9 +428,11 @@ 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

if(not element:IsShown()) then return end

element.notInterruptible = event == 'UNIT_SPELLCAST_NOT_INTERRUPTIBLE'
Expand Down

0 comments on commit 07f7153

Please sign in to comment.