Skip to content

Commit

Permalink
[Bugfix] Fix CombatIcon not properly displaying combat status for som…
Browse files Browse the repository at this point in the history
…e units
  • Loading branch information
Krealle committed Sep 26, 2024
1 parent c8a63a7 commit ad79bb8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Widgets/Icons/CombatIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ Handler:RegisterWidget(W.UpdateCombatIconWidget, const.WIDGET_KIND.COMBAT_ICON)
-------------------------------------------------

---@param button CUFUnitButton
---@param event? "PLAYER_REGEN_DISABLED" | "PLAYER_REGEN_ENABLED"
---@param event? "PLAYER_REGEN_DISABLED" | "PLAYER_REGEN_ENABLED" | "UNIT_FLAGS"
local function Update(button, event)
local unit = button.states.displayedUnit
if not unit then return end

local combatIcon = button.widgets.combatIcon

if combatIcon.enabled
and (InCombatLockdown()
or event == "PLAYER_REGEN_DISABLED"
and (event == "PLAYER_REGEN_DISABLED"
or UnitAffectingCombat(unit)
or combatIcon._isSelected) then
combatIcon:Show()
else
Expand All @@ -56,16 +56,24 @@ end

---@param self CombatIconWidget
local function Enable(self)
self._owner:AddEventListener("PLAYER_REGEN_DISABLED", Update, true)
self._owner:AddEventListener("PLAYER_REGEN_ENABLED", Update, true)
if self._owner.states.unit == "player" then
self._owner:AddEventListener("PLAYER_REGEN_DISABLED", Update, true)
self._owner:AddEventListener("PLAYER_REGEN_ENABLED", Update, true)
else
self._owner:AddEventListener("UNIT_FLAGS", Update)
end

return true
end

---@param self CombatIconWidget
local function Disable(self)
self._owner:RemoveEventListener("PLAYER_REGEN_DISABLED", Update)
self._owner:RemoveEventListener("PLAYER_REGEN_ENABLED", Update)
if self._owner.states.unit == "player" then
self._owner:RemoveEventListener("PLAYER_REGEN_DISABLED", Update)
self._owner:RemoveEventListener("PLAYER_REGEN_ENABLED", Update)
else
self._owner:RemoveEventListener("UNIT_FLAGS", Update)
end
end

-------------------------------------------------
Expand Down

0 comments on commit ad79bb8

Please sign in to comment.