Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

castbar: Add override for unit checks #677

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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