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

combatindicator: Support more units #692

Merged
merged 3 commits into from
Nov 30, 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
17 changes: 8 additions & 9 deletions elements/combatindicator.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--[[
# Element: Combat Indicator
Toggles the visibility of an indicator based on the player's combat status.
Toggles the visibility of an indicator based on the unit's combat status.
## Widget
Expand All @@ -25,7 +25,8 @@ A default texture will be applied if the widget is a Texture and doesn't have a
local _, ns = ...
local oUF = ns.oUF

local function Update(self, event)
local function Update(self, event, unit)
if(not unit or self.unit ~= unit) then return end
local element = self.CombatIndicator

--[[ Callback: CombatIndicator:PreUpdate()
Expand All @@ -37,7 +38,7 @@ local function Update(self, event)
element:PreUpdate()
end

local inCombat = UnitAffectingCombat('player')
local inCombat = UnitAffectingCombat(unit)
if(inCombat) then
element:Show()
else
Expand All @@ -48,7 +49,7 @@ local function Update(self, event)
Called after the element has been updated.
* self - the CombatIndicator element
* inCombat - indicates if the player is affecting combat (boolean)
* inCombat - indicates if the unit is affecting combat (boolean)
--]]
if(element.PostUpdate) then
return element:PostUpdate(inCombat)
Expand All @@ -71,12 +72,11 @@ end

local function Enable(self, unit)
local element = self.CombatIndicator
if(element and UnitIsUnit(unit, 'player')) then
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate

self:RegisterEvent('PLAYER_REGEN_DISABLED', Path, true)
self:RegisterEvent('PLAYER_REGEN_ENABLED', Path, true)
self:RegisterEvent('UNIT_FLAGS', Path)

if(element:IsObjectType('Texture') and not element:GetTexture()) then
element:SetTexture([[Interface\CharacterFrame\UI-StateIcon]])
Expand All @@ -92,8 +92,7 @@ local function Disable(self)
if(element) then
element:Hide()

self:UnregisterEvent('PLAYER_REGEN_DISABLED', Path)
self:UnregisterEvent('PLAYER_REGEN_ENABLED', Path)
self:UnregisterEvent('UNIT_FLAGS', Path)
end
end

Expand Down