Commit ae7a12c6 authored by Val Voronov's avatar Val Voronov Committed by GitHub

portrait: Fix updates for *target units (#399)

parent 5220a4e6
...@@ -36,7 +36,7 @@ local _, ns = ... ...@@ -36,7 +36,7 @@ local _, ns = ...
local oUF = ns.oUF local oUF = ns.oUF
local function Update(self, event, unit) local function Update(self, event, unit)
if(self.unit ~= unit) then return end if(not unit or not UnitIsUnit(self.unit, unit)) then return end
local element = self.Portrait local element = self.Portrait
...@@ -48,25 +48,29 @@ local function Update(self, event, unit) ...@@ -48,25 +48,29 @@ local function Update(self, event, unit)
--]] --]]
if(element.PreUpdate) then element:PreUpdate(unit) end if(element.PreUpdate) then element:PreUpdate(unit) end
if(element:IsObjectType('PlayerModel')) then local guid = UnitGUID(unit)
local guid = UnitGUID(unit) local isAvailable = UnitIsConnected(unit) and UnitIsVisible(unit)
if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then if(event ~= 'OnUpdate' or element.guid ~= guid or element.state ~= isAvailable) then
element:SetCamDistanceScale(0.25) if(element:IsObjectType('PlayerModel')) then
element:SetPortraitZoom(0) if(not isAvailable) then
element:SetPosition(0, 0, 0.5) element:SetCamDistanceScale(0.25)
element:ClearModel() element:SetPortraitZoom(0)
element:SetModel([[Interface\Buttons\TalkToMeQuestionMark.m2]]) element:SetPosition(0, 0, 0.25)
element.guid = nil element:ClearModel()
elseif(element.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then element:SetModel([[Interface\Buttons\TalkToMeQuestionMark.m2]])
element:SetCamDistanceScale(1) else
element:SetPortraitZoom(1) element:SetCamDistanceScale(1)
element:SetPosition(0, 0, 0) element:SetPortraitZoom(1)
element:ClearModel() element:SetPosition(0, 0, 0)
element:SetUnit(unit) element:ClearModel()
element.guid = guid element:SetUnit(unit)
end
else
SetPortraitTexture(element, unit)
end end
else
SetPortraitTexture(element, unit) element.guid = guid
element.state = isAvailable
end end
--[[ Callback: Portrait:PostUpdate(unit) --[[ Callback: Portrait:PostUpdate(unit)
...@@ -101,7 +105,6 @@ local function Enable(self, unit) ...@@ -101,7 +105,6 @@ local function Enable(self, unit)
element.__owner = self element.__owner = self
element.ForceUpdate = ForceUpdate element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_PORTRAIT_UPDATE', Path)
self:RegisterEvent('UNIT_MODEL_CHANGED', Path) self:RegisterEvent('UNIT_MODEL_CHANGED', Path)
self:RegisterEvent('UNIT_CONNECTION', Path) self:RegisterEvent('UNIT_CONNECTION', Path)
...@@ -126,7 +129,6 @@ local function Disable(self) ...@@ -126,7 +129,6 @@ local function Disable(self)
if(element) then if(element) then
element:Hide() element:Hide()
self:UnregisterEvent('UNIT_PORTRAIT_UPDATE', Path)
self:UnregisterEvent('UNIT_MODEL_CHANGED', Path) self:UnregisterEvent('UNIT_MODEL_CHANGED', Path)
self:UnregisterEvent('PARTY_MEMBER_ENABLE', Path) self:UnregisterEvent('PARTY_MEMBER_ENABLE', Path)
self:UnregisterEvent('UNIT_CONNECTION', Path) self:UnregisterEvent('UNIT_CONNECTION', Path)
......
...@@ -66,8 +66,9 @@ registering events. ...@@ -66,8 +66,9 @@ registering events.
automatically considered unitless (boolean) automatically considered unitless (boolean)
--]] --]]
function frame_metatable.__index:RegisterEvent(event, func, unitless) function frame_metatable.__index:RegisterEvent(event, func, unitless)
-- Block OnUpdate polled frames from registering events. -- Block OnUpdate polled frames from registering events except for
if(self.__eventless) then return end -- UNIT_MODEL_CHANGED which is used for portrait updates.
if(self.__eventless and event ~= 'UNIT_MODEL_CHANGED') then return end
argcheck(event, 2, 'string') argcheck(event, 2, 'string')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment