Skip to content

Commit

Permalink
elements: review unit handling
Browse files Browse the repository at this point in the history
NOTE: the unit check is needed because of the possibility for mixed event registration

- 💄
- fixed early exit for pvpindicator when the event is HONOR_LEVEL_UPDATE
- resurrect and summon indicators now use the event unit
  • Loading branch information
Rainrider committed Dec 29, 2018
1 parent 76f0b5f commit 0738959
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion elements/assistantindicator.lua
Expand Up @@ -27,6 +27,7 @@ local oUF = ns.oUF
local function Update(self, event)
local element = self.AssistantIndicator
local unit = self.unit
--[[ Callback: AssistantIndicator:PreUpdate()
Called before the element has been updated.
Expand All @@ -37,7 +38,6 @@ local function Update(self, event)
element:PreUpdate()
end
local unit = self.unit
local isAssistant = UnitInRaid(unit) and UnitIsGroupAssistant(unit) and not UnitIsGroupLeader(unit)
if(isAssistant) then
element:Show()
Expand Down
2 changes: 1 addition & 1 deletion elements/grouproleindicator.lua
Expand Up @@ -97,7 +97,7 @@ local function Disable(self)
element:Hide()
self:UnregisterEvent('PLAYER_ROLES_ASSIGNED', Path)
self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path)
self:UnregisterEvent('GROUP_ROSTER_UPDATE', Path, true)
end
end
Expand Down
2 changes: 1 addition & 1 deletion elements/leaderindicator.lua
Expand Up @@ -27,6 +27,7 @@ local oUF = ns.oUF
local function Update(self, event)
local element = self.LeaderIndicator
local unit = self.unit
--[[ Callback: LeaderIndicator:PreUpdate()
Called before the element has been updated.
Expand All @@ -37,7 +38,6 @@ local function Update(self, event)
element:PreUpdate()
end
local unit = self.unit
local isLeader = (UnitInParty(unit) or UnitInRaid(unit)) and UnitIsGroupLeader(unit)
if(isLeader) then
element:Show()
Expand Down
12 changes: 7 additions & 5 deletions elements/phaseindicator.lua
Expand Up @@ -25,7 +25,9 @@ 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(self.unit ~= unit) then return end
local element = self.PhaseIndicator
--[[ Callback: PhaseIndicator:PreUpdate()
Expand All @@ -37,8 +39,8 @@ local function Update(self, event)
element:PreUpdate()
end
local isInSamePhase = UnitInPhase(self.unit) and not UnitIsWarModePhased(self.unit)
if(not isInSamePhase and UnitIsPlayer(self.unit) and UnitIsConnected(self.unit)) then
local isInSamePhase = UnitInPhase(unit) and not UnitIsWarModePhased(unit)
if(not isInSamePhase and UnitIsPlayer(unit) and UnitIsConnected(unit)) then
element:Show()
else
element:Hide()
Expand Down Expand Up @@ -67,7 +69,7 @@ local function Path(self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate')
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
Expand All @@ -76,7 +78,7 @@ local function Enable(self)
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_PHASE', Path, true)
self:RegisterEvent('UNIT_PHASE', Path)
if(element:IsObjectType('Texture') and not element:GetTexture()) then
element:SetTexture([[Interface\TargetingFrame\UI-PhasingIcon]])
Expand Down
3 changes: 2 additions & 1 deletion elements/pvpindicator.lua
Expand Up @@ -36,9 +36,10 @@ local _, ns = ...
local oUF = ns.oUF
local function Update(self, event, unit)
if(unit ~= self.unit) then return end
if(unit and unit ~= self.unit) then return end
local element = self.PvPIndicator
unit = unit or self.unit
--[[ Callback: PvPIndicator:PreUpdate(unit)
Called before the element has been updated.
Expand Down
3 changes: 1 addition & 2 deletions elements/raidroleindicator.lua
Expand Up @@ -29,9 +29,8 @@ local MAINTANK_ICON = [[Interface\GROUPFRAME\UI-GROUP-MAINTANKICON]]
local MAINASSIST_ICON = [[Interface\GROUPFRAME\UI-GROUP-MAINASSISTICON]]
local function Update(self, event)
local unit = self.unit
local element = self.RaidRoleIndicator
local unit = self.unit
--[[ Callback: RaidRoleIndicator:PreUpdate()
Called before the element has been updated.
Expand Down
2 changes: 1 addition & 1 deletion elements/readycheckindicator.lua
Expand Up @@ -58,6 +58,7 @@ end
local function Update(self, event)
local element = self.ReadyCheckIndicator
local unit = self.unit
--[[ Callback: ReadyCheckIndicator:PreUpdate()
Called before the element has been updated.
Expand All @@ -68,7 +69,6 @@ local function Update(self, event)
element:PreUpdate()
end
local unit = self.unit
local status = GetReadyCheckStatus(unit)
if(UnitExists(unit) and status) then
if(status == 'ready') then
Expand Down
8 changes: 5 additions & 3 deletions elements/resurrectindicator.lua
Expand Up @@ -25,7 +25,9 @@ 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(self.unit ~= unit) then return end
local element = self.ResurrectIndicator
--[[ Callback: ResurrectIndicator:PreUpdate()
Expand All @@ -37,7 +39,7 @@ local function Update(self, event)
element:PreUpdate()
end
local incomingResurrect = UnitHasIncomingResurrection(self.unit)
local incomingResurrect = UnitHasIncomingResurrection(unit)
if(incomingResurrect) then
element:Show()
else
Expand Down Expand Up @@ -67,7 +69,7 @@ local function Path(self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate')
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
Expand Down
10 changes: 6 additions & 4 deletions elements/summonindicator.lua
Expand Up @@ -31,7 +31,9 @@ local SUMMON_STATUS_PENDING = Enum.SummonStatus.Pending or 1
local SUMMON_STATUS_ACCEPTED = Enum.SummonStatus.Accepted or 2
local SUMMON_STATUS_DECLINED = Enum.SummonStatus.Declined or 3
local function Update(self)
local function Update(self, event, unit)
if(self.unit ~= unit) then return end
local element = self.SummonIndicator
--[[ Callback: SummonIndicator:PreUpdate()
Expand All @@ -43,7 +45,7 @@ local function Update(self)
element:PreUpdate()
end
local status = C_IncomingSummon.IncomingSummonStatus(self.unit)
local status = C_IncomingSummon.IncomingSummonStatus(unit)
if(status ~= SUMMON_STATUS_NONE) then
if(status == SUMMON_STATUS_PENDING) then
element:SetAtlas('Raid-Icon-SummonPending')
Expand Down Expand Up @@ -81,7 +83,7 @@ local function Path(self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate')
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
Expand All @@ -90,7 +92,7 @@ local function Enable(self)
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('INCOMING_SUMMON_CHANGED', Path, true)
self:RegisterEvent('INCOMING_SUMMON_CHANGED', Path)
return true
end
Expand Down

0 comments on commit 0738959

Please sign in to comment.